duckdb 0.6.1-dev30.0 → 0.6.1-dev38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.6.1-dev30.0",
5
+ "version": "0.6.1-dev38.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -45633,6 +45633,7 @@ hash_t Hash(uint8_t *val, size_t size) {
45633
45633
 
45634
45634
 
45635
45635
 
45636
+
45636
45637
  #include <cmath>
45637
45638
  #include <limits>
45638
45639
 
@@ -46127,6 +46128,13 @@ bool Hugeint::TryConvert(int8_t value, hugeint_t &result) {
46127
46128
  return true;
46128
46129
  }
46129
46130
 
46131
+ template <>
46132
+ bool Hugeint::TryConvert(const char *value, hugeint_t &result) {
46133
+ auto len = strlen(value);
46134
+ string_t string_val(value, len);
46135
+ return TryCast::Operation<string_t, hugeint_t>(string_val, result, true);
46136
+ }
46137
+
46130
46138
  template <>
46131
46139
  bool Hugeint::TryConvert(int16_t value, hugeint_t &result) {
46132
46140
  result = HugeintConvertInteger<int16_t>(value);
@@ -131311,14 +131319,16 @@ void UDFWrapper::RegisterAggrFunction(AggregateFunction aggr_function, ClientCon
131311
131319
 
131312
131320
 
131313
131321
 
131322
+
131314
131323
  namespace duckdb {
131315
131324
 
131316
- BaseAppender::BaseAppender(Allocator &allocator) : allocator(allocator), column(0) {
131325
+ BaseAppender::BaseAppender(Allocator &allocator, AppenderType type_p)
131326
+ : allocator(allocator), column(0), appender_type(type_p) {
131317
131327
  }
131318
131328
 
131319
- BaseAppender::BaseAppender(Allocator &allocator_p, vector<LogicalType> types_p)
131329
+ BaseAppender::BaseAppender(Allocator &allocator_p, vector<LogicalType> types_p, AppenderType type_p)
131320
131330
  : allocator(allocator_p), types(move(types_p)), collection(make_unique<ColumnDataCollection>(allocator, types)),
131321
- column(0) {
131331
+ column(0), appender_type(type_p) {
131322
131332
  InitializeChunk();
131323
131333
  }
131324
131334
 
@@ -131338,7 +131348,8 @@ void BaseAppender::Destructor() {
131338
131348
  }
131339
131349
 
131340
131350
  InternalAppender::InternalAppender(ClientContext &context_p, TableCatalogEntry &table_p)
131341
- : BaseAppender(Allocator::DefaultAllocator(), table_p.GetTypes()), context(context_p), table(table_p) {
131351
+ : BaseAppender(Allocator::DefaultAllocator(), table_p.GetTypes(), AppenderType::PHYSICAL), context(context_p),
131352
+ table(table_p) {
131342
131353
  }
131343
131354
 
131344
131355
  InternalAppender::~InternalAppender() {
@@ -131346,7 +131357,7 @@ InternalAppender::~InternalAppender() {
131346
131357
  }
131347
131358
 
131348
131359
  Appender::Appender(Connection &con, const string &schema_name, const string &table_name)
131349
- : BaseAppender(Allocator::DefaultAllocator()), context(con.context) {
131360
+ : BaseAppender(Allocator::DefaultAllocator(), AppenderType::LOGICAL), context(con.context) {
131350
131361
  description = con.TableInfo(schema_name, table_name);
131351
131362
  if (!description) {
131352
131363
  // table could not be found
@@ -131390,6 +131401,27 @@ void BaseAppender::AppendValueInternal(Vector &col, SRC input) {
131390
131401
  FlatVector::GetData<DST>(col)[chunk.size()] = Cast::Operation<SRC, DST>(input);
131391
131402
  }
131392
131403
 
131404
+ template <class SRC, class DST>
131405
+ void BaseAppender::AppendDecimalValueInternal(Vector &col, SRC input) {
131406
+ switch (appender_type) {
131407
+ case AppenderType::LOGICAL: {
131408
+ auto &type = col.GetType();
131409
+ D_ASSERT(type.id() == LogicalTypeId::DECIMAL);
131410
+ auto width = DecimalType::GetWidth(type);
131411
+ auto scale = DecimalType::GetScale(type);
131412
+ TryCastToDecimal::Operation<SRC, DST>(input, FlatVector::GetData<DST>(col)[chunk.size()], nullptr, width,
131413
+ scale);
131414
+ return;
131415
+ }
131416
+ case AppenderType::PHYSICAL: {
131417
+ AppendValueInternal<SRC, DST>(col, input);
131418
+ return;
131419
+ }
131420
+ default:
131421
+ throw InternalException("Type not implemented for AppenderType");
131422
+ }
131423
+ }
131424
+
131393
131425
  template <class T>
131394
131426
  void BaseAppender::AppendValueInternal(T input) {
131395
131427
  if (column >= types.size()) {
@@ -131435,18 +131467,20 @@ void BaseAppender::AppendValueInternal(T input) {
131435
131467
  break;
131436
131468
  case LogicalTypeId::DECIMAL:
131437
131469
  switch (col.GetType().InternalType()) {
131438
- case PhysicalType::INT8:
131439
- AppendValueInternal<T, int8_t>(col, input);
131440
- break;
131441
131470
  case PhysicalType::INT16:
131442
- AppendValueInternal<T, int16_t>(col, input);
131471
+ AppendDecimalValueInternal<T, int16_t>(col, input);
131443
131472
  break;
131444
131473
  case PhysicalType::INT32:
131445
- AppendValueInternal<T, int32_t>(col, input);
131474
+ AppendDecimalValueInternal<T, int32_t>(col, input);
131446
131475
  break;
131447
- default:
131448
- AppendValueInternal<T, int64_t>(col, input);
131476
+ case PhysicalType::INT64:
131477
+ AppendDecimalValueInternal<T, int64_t>(col, input);
131449
131478
  break;
131479
+ case PhysicalType::INT128:
131480
+ AppendDecimalValueInternal<T, hugeint_t>(col, input);
131481
+ break;
131482
+ default:
131483
+ throw InternalException("Internal type not recognized for Decimal");
131450
131484
  }
131451
131485
  break;
131452
131486
  case LogicalTypeId::DATE:
package/src/duckdb.hpp CHANGED
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
11
11
  #pragma once
12
12
  #define DUCKDB_AMALGAMATION 1
13
13
  #define DUCKDB_AMALGAMATION_EXTENDED 1
14
- #define DUCKDB_SOURCE_ID "7f70cbe4c6"
15
- #define DUCKDB_VERSION "v0.6.1-dev30"
14
+ #define DUCKDB_SOURCE_ID "bce33302a9"
15
+ #define DUCKDB_VERSION "v0.6.1-dev38"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //
@@ -8269,6 +8269,8 @@ template <>
8269
8269
  bool Hugeint::TryConvert(double value, hugeint_t &result);
8270
8270
  template <>
8271
8271
  bool Hugeint::TryConvert(long double value, hugeint_t &result);
8272
+ template <>
8273
+ bool Hugeint::TryConvert(const char *value, hugeint_t &result);
8272
8274
 
8273
8275
  } // namespace duckdb
8274
8276
 
@@ -21706,6 +21708,11 @@ class DuckDB;
21706
21708
  class TableCatalogEntry;
21707
21709
  class Connection;
21708
21710
 
21711
+ enum class AppenderType : uint8_t {
21712
+ LOGICAL, // Cast input -> LogicalType
21713
+ PHYSICAL // Cast input -> PhysicalType
21714
+ };
21715
+
21709
21716
  //! The Appender class can be used to append elements to a table.
21710
21717
  class BaseAppender {
21711
21718
  protected:
@@ -21721,10 +21728,14 @@ protected:
21721
21728
  DataChunk chunk;
21722
21729
  //! The current column to append to
21723
21730
  idx_t column = 0;
21731
+ //! The type of the appender
21732
+ AppenderType appender_type;
21733
+
21734
+ protected:
21735
+ DUCKDB_API BaseAppender(Allocator &allocator, AppenderType type);
21736
+ DUCKDB_API BaseAppender(Allocator &allocator, vector<LogicalType> types, AppenderType type);
21724
21737
 
21725
21738
  public:
21726
- DUCKDB_API BaseAppender(Allocator &allocator);
21727
- DUCKDB_API BaseAppender(Allocator &allocator, vector<LogicalType> types);
21728
21739
  DUCKDB_API virtual ~BaseAppender();
21729
21740
 
21730
21741
  //! Begins a new row append, after calling this the other AppendX() functions
@@ -21772,6 +21783,8 @@ protected:
21772
21783
  void AppendValueInternal(T value);
21773
21784
  template <class SRC, class DST>
21774
21785
  void AppendValueInternal(Vector &vector, SRC input);
21786
+ template <class SRC, class DST>
21787
+ void AppendDecimalValueInternal(Vector &vector, SRC input);
21775
21788
 
21776
21789
  void AppendRowRecursive() {
21777
21790
  EndRow();