duckdb 0.8.1-dev219.0 → 0.8.1-dev253.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.
Files changed (22) hide show
  1. package/binding.gyp +8 -8
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/icu/icu-makedate.cpp +5 -4
  4. package/src/duckdb/extension/json/json_functions.cpp +3 -0
  5. package/src/duckdb/src/common/multi_file_reader.cpp +3 -0
  6. package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +2 -0
  7. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +7 -5
  8. package/src/duckdb/src/function/cast/list_casts.cpp +2 -4
  9. package/src/duckdb/src/function/scalar/string/regexp/regexp_util.cpp +6 -2
  10. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  11. package/src/duckdb/src/include/duckdb/function/table_function.hpp +2 -1
  12. package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +5 -0
  13. package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +6 -2
  14. package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +4 -0
  15. package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +5 -1
  16. package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +5 -1
  17. package/src/duckdb/src/include/duckdb/planner/operator/logical_pragma.hpp +6 -2
  18. package/src/duckdb/src/include/duckdb/planner/operator/logical_prepare.hpp +4 -0
  19. package/src/duckdb/src/planner/binder/expression/bind_positional_reference_expression.cpp +1 -1
  20. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +18 -1
  21. package/src/duckdb/src/planner/planner.cpp +5 -15
  22. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +5 -5
package/binding.gyp CHANGED
@@ -237,18 +237,18 @@
237
237
  "src/duckdb/third_party/zstd/compress/zstd_lazy.cpp",
238
238
  "src/duckdb/third_party/zstd/compress/zstd_ldm.cpp",
239
239
  "src/duckdb/third_party/zstd/compress/zstd_opt.cpp",
240
- "src/duckdb/extension/icu/./icu-list-range.cpp",
241
- "src/duckdb/extension/icu/./icu-datefunc.cpp",
242
- "src/duckdb/extension/icu/./icu-datepart.cpp",
240
+ "src/duckdb/extension/icu/./icu-dateadd.cpp",
243
241
  "src/duckdb/extension/icu/./icu-datetrunc.cpp",
242
+ "src/duckdb/extension/icu/./icu-datesub.cpp",
244
243
  "src/duckdb/extension/icu/./icu-table-range.cpp",
245
- "src/duckdb/extension/icu/./icu-dateadd.cpp",
244
+ "src/duckdb/extension/icu/./icu-timebucket.cpp",
245
+ "src/duckdb/extension/icu/./icu-list-range.cpp",
246
+ "src/duckdb/extension/icu/./icu-datepart.cpp",
247
+ "src/duckdb/extension/icu/./icu-timezone.cpp",
246
248
  "src/duckdb/extension/icu/./icu-extension.cpp",
247
- "src/duckdb/extension/icu/./icu-strptime.cpp",
248
- "src/duckdb/extension/icu/./icu-datesub.cpp",
249
249
  "src/duckdb/extension/icu/./icu-makedate.cpp",
250
- "src/duckdb/extension/icu/./icu-timezone.cpp",
251
- "src/duckdb/extension/icu/./icu-timebucket.cpp",
250
+ "src/duckdb/extension/icu/./icu-datefunc.cpp",
251
+ "src/duckdb/extension/icu/./icu-strptime.cpp",
252
252
  "src/duckdb/ub_extension_icu_third_party_icu_common.cpp",
253
253
  "src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp",
254
254
  "src/duckdb/extension/icu/third_party/icu/stubdata/stubdata.cpp",
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.8.1-dev219.0",
5
+ "version": "0.8.1-dev253.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -1,3 +1,4 @@
1
+ #include "duckdb/common/operator/cast_operators.hpp"
1
2
  #include "duckdb/common/types/date.hpp"
2
3
  #include "duckdb/common/types/time.hpp"
3
4
  #include "duckdb/common/types/timestamp.hpp"
@@ -36,8 +37,8 @@ struct ICUMakeDate : public ICUDateFunc {
36
37
 
37
38
  static bool CastToDate(Vector &source, Vector &result, idx_t count, CastParameters &parameters) {
38
39
  auto &cast_data = parameters.cast_data->Cast<CastData>();
39
- auto info = (BindData *)cast_data.info.get();
40
- CalendarPtr calendar(info->calendar->clone());
40
+ auto &info = cast_data.info->Cast<BindData>();
41
+ CalendarPtr calendar(info.calendar->clone());
41
42
 
42
43
  UnaryExecutor::Execute<timestamp_t, date_t>(
43
44
  source, result, count, [&](timestamp_t input) { return Operation(calendar.get(), input); });
@@ -67,7 +68,7 @@ struct ICUMakeTimestampTZFunc : public ICUDateFunc {
67
68
  static inline timestamp_t Operation(icu::Calendar *calendar, T yyyy, T mm, T dd, T hr, T mn, double ss) {
68
69
  const auto year = yyyy + (yyyy < 0);
69
70
 
70
- const auto secs = int32_t(ss);
71
+ const auto secs = Cast::Operation<double, int32_t>(ss);
71
72
  ss -= secs;
72
73
  ss *= Interval::MSECS_PER_SEC;
73
74
  const auto millis = int32_t(ss);
@@ -87,7 +88,7 @@ struct ICUMakeTimestampTZFunc : public ICUDateFunc {
87
88
  template <typename T>
88
89
  static void Execute(DataChunk &input, ExpressionState &state, Vector &result) {
89
90
  auto &func_expr = state.expr.Cast<BoundFunctionExpression>();
90
- auto &info = (BindData &)*func_expr.bind_info;
91
+ auto &info = func_expr.bind_info->Cast<BindData>();
91
92
  CalendarPtr calendar_ptr(info.calendar->clone());
92
93
  auto calendar = calendar_ptr.get();
93
94
 
@@ -15,6 +15,9 @@ namespace duckdb {
15
15
  static void CheckPath(const Value &path_val, string &path, size_t &len) {
16
16
  string error;
17
17
  Value path_str_val;
18
+ if (path_val.IsNull()) {
19
+ throw InvalidInputException("JSON path cannot be NULL");
20
+ }
18
21
  if (!path_val.DefaultTryCastAs(LogicalType::VARCHAR, path_str_val, &error)) {
19
22
  throw InvalidInputException(error);
20
23
  }
@@ -34,6 +34,9 @@ vector<string> MultiFileReader::GetFileList(ClientContext &context, const Value
34
34
  if (val.IsNull()) {
35
35
  throw ParserException("%s reader cannot take NULL input as parameter", name);
36
36
  }
37
+ if (val.type().id() != LogicalTypeId::VARCHAR) {
38
+ throw ParserException("%s reader can only take a list of strings as a parameter", name);
39
+ }
37
40
  auto glob_files = fs.GlobFiles(StringValue::Get(val), context, options);
38
41
  files.insert(files.end(), glob_files.begin(), glob_files.end());
39
42
  }
@@ -62,12 +62,14 @@ inline string_t TupleDataWithinListValueLoad(const data_ptr_t &location, data_pt
62
62
  return result;
63
63
  }
64
64
 
65
+ #ifdef DEBUG
65
66
  static void ResetCombinedListData(vector<TupleDataVectorFormat> &vector_data) {
66
67
  for (auto &vd : vector_data) {
67
68
  vd.combined_list_data = nullptr;
68
69
  ResetCombinedListData(vd.child_formats);
69
70
  }
70
71
  }
72
+ #endif
71
73
 
72
74
  void TupleDataCollection::ComputeHeapSizes(TupleDataChunkState &chunk_state, const DataChunk &new_chunk,
73
75
  const SelectionVector &append_sel, const idx_t append_count) {
@@ -224,12 +224,14 @@ struct WindowInputColumn {
224
224
  }
225
225
 
226
226
  void Append(DataChunk &input_chunk) {
227
- if (input_expr.expr && (!input_expr.scalar || !count)) {
228
- input_expr.Execute(input_chunk);
229
- auto &source = input_expr.chunk.data[0];
230
- const auto source_count = input_expr.chunk.size();
227
+ if (input_expr.expr) {
228
+ const auto source_count = input_chunk.size();
231
229
  D_ASSERT(count + source_count <= capacity);
232
- VectorOperations::Copy(source, *target, source_count, 0, count);
230
+ if (!input_expr.scalar || !count) {
231
+ input_expr.Execute(input_chunk);
232
+ auto &source = input_expr.chunk.data[0];
233
+ VectorOperations::Copy(source, *target, source_count, 0, count);
234
+ }
233
235
  count += source_count;
234
236
  }
235
237
  }
@@ -51,12 +51,10 @@ bool ListCast::ListToListCast(Vector &source, Vector &result, idx_t count, CastP
51
51
  auto &append_vector = ListVector::GetEntry(result);
52
52
 
53
53
  CastParameters child_parameters(parameters, cast_data.child_cast_info.cast_data, parameters.local_state);
54
- if (!cast_data.child_cast_info.function(source_cc, append_vector, source_size, child_parameters)) {
55
- return false;
56
- }
54
+ bool all_succeeded = cast_data.child_cast_info.function(source_cc, append_vector, source_size, child_parameters);
57
55
  ListVector::SetListSize(result, source_size);
58
56
  D_ASSERT(ListVector::GetListSize(result) == source_size);
59
- return true;
57
+ return all_succeeded;
60
58
  }
61
59
 
62
60
  static bool ListToVarcharCast(Vector &source, Vector &result, idx_t count, CastParameters &parameters) {
@@ -69,9 +69,13 @@ void ParseRegexOptions(ClientContext &context, Expression &expr, RE2::Options &t
69
69
  throw InvalidInputException("Regex options field must be a constant");
70
70
  }
71
71
  Value options_str = ExpressionExecutor::EvaluateScalar(context, expr);
72
- if (!options_str.IsNull() && options_str.type().id() == LogicalTypeId::VARCHAR) {
73
- ParseRegexOptions(StringValue::Get(options_str), target, global_replace);
72
+ if (options_str.IsNull()) {
73
+ throw InvalidInputException("Regex options field must not be NULL");
74
74
  }
75
+ if (options_str.type().id() != LogicalTypeId::VARCHAR) {
76
+ throw InvalidInputException("Regex options field must be a string");
77
+ }
78
+ ParseRegexOptions(StringValue::Get(options_str), target, global_replace);
75
79
  }
76
80
 
77
81
  } // namespace regexp_util
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.8.1-dev219"
2
+ #define DUCKDB_VERSION "0.8.1-dev253"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "fc724f980f"
5
+ #define DUCKDB_SOURCE_ID "0d946c04df"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -9,12 +9,12 @@
9
9
  #pragma once
10
10
 
11
11
  #include "duckdb/common/enums/operator_result_type.hpp"
12
+ #include "duckdb/common/optional_ptr.hpp"
12
13
  #include "duckdb/execution/execution_context.hpp"
13
14
  #include "duckdb/function/function.hpp"
14
15
  #include "duckdb/planner/bind_context.hpp"
15
16
  #include "duckdb/planner/logical_operator.hpp"
16
17
  #include "duckdb/storage/statistics/node_statistics.hpp"
17
- #include "duckdb/common/optional_ptr.hpp"
18
18
 
19
19
  #include <functional>
20
20
 
@@ -265,6 +265,7 @@ public:
265
265
 
266
266
  table_function_serialize_t serialize;
267
267
  table_function_deserialize_t deserialize;
268
+ bool verify_serialization = true;
268
269
 
269
270
  //! Whether or not the table function supports projection pushdown. If not supported a projection will be added
270
271
  //! that filters out unused columns.
@@ -83,6 +83,11 @@ public:
83
83
  return true;
84
84
  }
85
85
 
86
+ //! Allows LogicalOperators to opt out of serialization
87
+ virtual bool SupportSerialization() const {
88
+ return true;
89
+ };
90
+
86
91
  //! Returns the set of table indexes of this operator
87
92
  virtual vector<idx_t> GetTableIndex() const;
88
93
 
@@ -8,10 +8,10 @@
8
8
 
9
9
  #pragma once
10
10
 
11
- #include "duckdb/planner/logical_operator.hpp"
12
- #include "duckdb/function/copy_function.hpp"
13
11
  #include "duckdb/common/filename_pattern.hpp"
14
12
  #include "duckdb/common/local_file_system.hpp"
13
+ #include "duckdb/function/copy_function.hpp"
14
+ #include "duckdb/planner/logical_operator.hpp"
15
15
 
16
16
  namespace duckdb {
17
17
 
@@ -41,6 +41,10 @@ public:
41
41
  void Serialize(FieldWriter &writer) const override;
42
42
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
43
43
  idx_t EstimateCardinality(ClientContext &context) override;
44
+ //! Skips the serialization check in VerifyPlan
45
+ bool SupportSerialization() const override {
46
+ return false;
47
+ }
44
48
 
45
49
  protected:
46
50
  void ResolveTypes() override {
@@ -29,6 +29,10 @@ public:
29
29
  public:
30
30
  void Serialize(FieldWriter &writer) const override;
31
31
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
32
+ //! Skips the serialization check in VerifyPlan
33
+ bool SupportSerialization() const override {
34
+ return false;
35
+ }
32
36
 
33
37
  protected:
34
38
  void ResolveTypes() override {
@@ -8,8 +8,8 @@
8
8
 
9
9
  #pragma once
10
10
 
11
- #include "duckdb/planner/logical_operator.hpp"
12
11
  #include "duckdb/parser/statement/explain_statement.hpp"
12
+ #include "duckdb/planner/logical_operator.hpp"
13
13
 
14
14
  namespace duckdb {
15
15
 
@@ -37,6 +37,10 @@ public:
37
37
  idx_t EstimateCardinality(ClientContext &context) override {
38
38
  return 3;
39
39
  }
40
+ //! Skips the serialization check in VerifyPlan
41
+ bool SupportSerialization() const override {
42
+ return false;
43
+ }
40
44
 
41
45
  protected:
42
46
  void ResolveTypes() override {
@@ -8,8 +8,8 @@
8
8
 
9
9
  #pragma once
10
10
 
11
- #include "duckdb/planner/logical_operator.hpp"
12
11
  #include "duckdb/function/table_function.hpp"
12
+ #include "duckdb/planner/logical_operator.hpp"
13
13
  #include "duckdb/planner/table_filter.hpp"
14
14
 
15
15
  namespace duckdb {
@@ -62,6 +62,10 @@ public:
62
62
  void Serialize(FieldWriter &writer) const override;
63
63
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
64
64
  vector<idx_t> GetTableIndex() const override;
65
+ //! Skips the serialization check in VerifyPlan
66
+ bool SupportSerialization() const override {
67
+ return function.verify_serialization;
68
+ };
65
69
 
66
70
  protected:
67
71
  void ResolveTypes() override;
@@ -8,9 +8,9 @@
8
8
 
9
9
  #pragma once
10
10
 
11
- #include "duckdb/planner/logical_operator.hpp"
12
- #include "duckdb/parser/parsed_data/pragma_info.hpp"
13
11
  #include "duckdb/function/pragma_function.hpp"
12
+ #include "duckdb/parser/parsed_data/pragma_info.hpp"
13
+ #include "duckdb/planner/logical_operator.hpp"
14
14
 
15
15
  namespace duckdb {
16
16
 
@@ -34,6 +34,10 @@ public:
34
34
  void Serialize(FieldWriter &writer) const override;
35
35
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
36
36
  idx_t EstimateCardinality(ClientContext &context) override;
37
+ //! Skips the serialization check in VerifyPlan
38
+ bool SupportSerialization() const override {
39
+ return false;
40
+ }
37
41
 
38
42
  protected:
39
43
  void ResolveTypes() override {
@@ -36,6 +36,10 @@ public:
36
36
  void Serialize(FieldWriter &writer) const override;
37
37
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
38
38
  idx_t EstimateCardinality(ClientContext &context) override;
39
+ //! Skips the serialization check in VerifyPlan
40
+ bool SupportSerialization() const override {
41
+ return false;
42
+ }
39
43
 
40
44
  protected:
41
45
  void ResolveTypes() override {
@@ -8,7 +8,7 @@ BindResult ExpressionBinder::BindPositionalReference(unique_ptr<ParsedExpression
8
8
  bool root_expression) {
9
9
  auto &ref = expr->Cast<PositionalReferenceExpression>();
10
10
  if (depth != 0) {
11
- return BindResult("Positional reference expression could not be bound");
11
+ throw InternalException("Positional reference expression could not be bound");
12
12
  }
13
13
  // replace the positional reference with a column
14
14
  auto column = binder.bind_context.PositionToColumn(ref);
@@ -294,9 +294,26 @@ unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateIn
294
294
  BindLogicalType(context, column.TypeMutable(), &result->schema.catalog);
295
295
  // We add a catalog dependency
296
296
  auto type_dependency = EnumType::GetCatalog(column.Type());
297
+
297
298
  if (type_dependency) {
298
299
  // Only if the USER comes from a create type
299
- result->dependencies.AddDependency(*type_dependency);
300
+ if (!schema.catalog.IsTemporaryCatalog()) {
301
+ // If it is not a TEMP table we add a dependency
302
+ result->dependencies.AddDependency(*type_dependency);
303
+ } else {
304
+ auto enum_type = type_dependency->user_type;
305
+ auto &enum_entries = EnumType::GetValuesInsertOrder(enum_type);
306
+ auto enum_size = EnumType::GetSize(enum_type);
307
+ Vector copy_enum_entries_vec(LogicalType::VARCHAR, enum_size);
308
+ auto copy_enum_entries_ptr = FlatVector::GetData<string_t>(copy_enum_entries_vec);
309
+ auto enum_entries_ptr = FlatVector::GetData<string_t>(enum_entries);
310
+ for (idx_t enum_idx = 0; enum_idx < enum_size; enum_idx++) {
311
+ copy_enum_entries_ptr[enum_idx] =
312
+ StringVector::AddStringOrBlob(copy_enum_entries_vec, enum_entries_ptr[enum_idx]);
313
+ }
314
+ auto copy_type = LogicalType::ENUM(EnumType::GetTypeName(enum_type), copy_enum_entries_vec, enum_size);
315
+ column.SetType(copy_type);
316
+ }
300
317
  }
301
318
  }
302
319
  result->dependencies.VerifyDependencies(schema.catalog, result->Base().table);
@@ -1,14 +1,15 @@
1
1
  #include "duckdb/planner/planner.hpp"
2
- #include "duckdb/main/query_profiler.hpp"
2
+
3
3
  #include "duckdb/common/serializer.hpp"
4
+ #include "duckdb/common/serializer/buffered_deserializer.hpp"
5
+ #include "duckdb/execution/expression_executor.hpp"
4
6
  #include "duckdb/main/client_context.hpp"
5
7
  #include "duckdb/main/client_data.hpp"
6
8
  #include "duckdb/main/database.hpp"
7
9
  #include "duckdb/main/prepared_statement_data.hpp"
10
+ #include "duckdb/main/query_profiler.hpp"
8
11
  #include "duckdb/planner/binder.hpp"
9
12
  #include "duckdb/planner/expression/bound_parameter_expression.hpp"
10
- #include "duckdb/execution/expression_executor.hpp"
11
- #include "duckdb/common/serializer/buffered_deserializer.hpp"
12
13
  #include "duckdb/transaction/meta_transaction.hpp"
13
14
 
14
15
  namespace duckdb {
@@ -142,23 +143,12 @@ void Planner::CreatePlan(unique_ptr<SQLStatement> statement) {
142
143
  }
143
144
 
144
145
  static bool OperatorSupportsSerialization(LogicalOperator &op) {
145
- switch (op.type) {
146
- case LogicalOperatorType::LOGICAL_PREPARE:
147
- case LogicalOperatorType::LOGICAL_EXECUTE:
148
- case LogicalOperatorType::LOGICAL_PRAGMA:
149
- case LogicalOperatorType::LOGICAL_EXPLAIN:
150
- case LogicalOperatorType::LOGICAL_COPY_TO_FILE:
151
- // unsupported (for now)
152
- return false;
153
- default:
154
- break;
155
- }
156
146
  for (auto &child : op.children) {
157
147
  if (!OperatorSupportsSerialization(*child)) {
158
148
  return false;
159
149
  }
160
150
  }
161
- return true;
151
+ return op.SupportSerialization();
162
152
  }
163
153
 
164
154
  void Planner::VerifyPlan(ClientContext &context, unique_ptr<LogicalOperator> &op, bound_parameter_map_t *map) {
@@ -348,17 +348,17 @@
348
348
 
349
349
  #include "extension/icu/third_party/icu/i18n/wintzimpl.cpp"
350
350
 
351
- #include "extension/icu/third_party/icu/i18n/double-conversion-fast-dtoa.cpp"
352
-
353
351
  #include "extension/icu/third_party/icu/i18n/double-conversion-double-to-string.cpp"
354
352
 
355
- #include "extension/icu/third_party/icu/i18n/double-conversion-strtod.cpp"
353
+ #include "extension/icu/third_party/icu/i18n/double-conversion-fast-dtoa.cpp"
356
354
 
357
- #include "extension/icu/third_party/icu/i18n/double-conversion-cached-powers.cpp"
355
+ #include "extension/icu/third_party/icu/i18n/double-conversion-bignum.cpp"
358
356
 
359
357
  #include "extension/icu/third_party/icu/i18n/double-conversion-string-to-double.cpp"
360
358
 
359
+ #include "extension/icu/third_party/icu/i18n/double-conversion-cached-powers.cpp"
360
+
361
361
  #include "extension/icu/third_party/icu/i18n/double-conversion-bignum-dtoa.cpp"
362
362
 
363
- #include "extension/icu/third_party/icu/i18n/double-conversion-bignum.cpp"
363
+ #include "extension/icu/third_party/icu/i18n/double-conversion-strtod.cpp"
364
364