duckdb 0.8.2-dev2090.0 → 0.8.2-dev2208.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 (148) hide show
  1. package/binding.gyp +3 -0
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/json/buffered_json_reader.cpp +2 -0
  4. package/src/duckdb/extension/json/include/buffered_json_reader.hpp +5 -19
  5. package/src/duckdb/extension/json/include/json_enums.hpp +60 -0
  6. package/src/duckdb/extension/json/include/json_scan.hpp +14 -10
  7. package/src/duckdb/extension/json/include/json_transform.hpp +3 -0
  8. package/src/duckdb/extension/json/json_enums.cpp +105 -0
  9. package/src/duckdb/extension/json/json_functions/json_transform.cpp +2 -0
  10. package/src/duckdb/extension/json/json_functions.cpp +2 -1
  11. package/src/duckdb/extension/json/json_scan.cpp +44 -0
  12. package/src/duckdb/extension/json/serialize_json.cpp +92 -0
  13. package/src/duckdb/extension/parquet/include/parquet_reader.hpp +3 -0
  14. package/src/duckdb/extension/parquet/parquet_extension.cpp +25 -1
  15. package/src/duckdb/extension/parquet/parquet_reader.cpp +3 -0
  16. package/src/duckdb/extension/parquet/serialize_parquet.cpp +26 -0
  17. package/src/duckdb/src/catalog/catalog.cpp +2 -6
  18. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +1 -4
  19. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +0 -4
  20. package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +7 -26
  21. package/src/duckdb/src/catalog/catalog_set.cpp +0 -63
  22. package/src/duckdb/src/catalog/dependency_manager.cpp +0 -36
  23. package/src/duckdb/src/common/extra_type_info.cpp +24 -46
  24. package/src/duckdb/src/common/field_writer.cpp +0 -1
  25. package/src/duckdb/src/common/file_system.cpp +6 -6
  26. package/src/duckdb/src/common/filename_pattern.cpp +1 -1
  27. package/src/duckdb/src/common/gzip_file_system.cpp +7 -12
  28. package/src/duckdb/src/common/local_file_system.cpp +17 -14
  29. package/src/duckdb/src/common/multi_file_reader.cpp +8 -5
  30. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +0 -9
  31. package/src/duckdb/src/common/serializer/format_serializer.cpp +15 -0
  32. package/src/duckdb/src/common/types.cpp +12 -56
  33. package/src/duckdb/src/common/virtual_file_system.cpp +4 -0
  34. package/src/duckdb/src/core_functions/aggregate/holistic/approximate_quantile.cpp +26 -0
  35. package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +47 -0
  36. package/src/duckdb/src/core_functions/aggregate/holistic/reservoir_quantile.cpp +28 -0
  37. package/src/duckdb/src/core_functions/scalar/date/strftime.cpp +10 -0
  38. package/src/duckdb/src/core_functions/scalar/list/list_lambdas.cpp +22 -3
  39. package/src/duckdb/src/core_functions/scalar/union/union_tag.cpp +1 -1
  40. package/src/duckdb/src/execution/column_binding_resolver.cpp +3 -7
  41. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +1 -1
  42. package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +0 -10
  43. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +2 -1
  44. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +2 -6
  45. package/src/duckdb/src/execution/physical_plan/plan_asof_join.cpp +1 -2
  46. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +14 -1
  47. package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +3 -17
  48. package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +2 -5
  49. package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -5
  50. package/src/duckdb/src/function/aggregate/distributive/count.cpp +0 -11
  51. package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +1 -9
  52. package/src/duckdb/src/function/cast/string_cast.cpp +0 -1
  53. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +27 -0
  54. package/src/duckdb/src/function/scalar_function.cpp +5 -20
  55. package/src/duckdb/src/function/table/read_csv.cpp +20 -1
  56. package/src/duckdb/src/function/table/system/test_all_types.cpp +4 -4
  57. package/src/duckdb/src/function/table/table_scan.cpp +35 -0
  58. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  59. package/src/duckdb/src/function/table_function.cpp +4 -3
  60. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +0 -2
  61. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -4
  62. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +0 -6
  63. package/src/duckdb/src/include/duckdb/common/extra_type_info.hpp +2 -6
  64. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +0 -4
  65. package/src/duckdb/src/include/duckdb/common/file_system.hpp +8 -8
  66. package/src/duckdb/src/include/duckdb/common/filename_pattern.hpp +1 -1
  67. package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +5 -1
  68. package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +3 -1
  69. package/src/duckdb/src/include/duckdb/common/opener_file_system.hpp +4 -0
  70. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +0 -4
  71. package/src/duckdb/src/include/duckdb/common/serializer/format_deserializer.hpp +32 -0
  72. package/src/duckdb/src/include/duckdb/common/serializer/format_serializer.hpp +45 -15
  73. package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +10 -0
  74. package/src/duckdb/src/include/duckdb/common/serializer.hpp +0 -7
  75. package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +14 -10
  76. package/src/duckdb/src/include/duckdb/common/types.hpp +5 -10
  77. package/src/duckdb/src/include/duckdb/common/virtual_file_system.hpp +2 -0
  78. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +2 -0
  79. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +0 -4
  80. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +3 -2
  81. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +11 -2
  82. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +81 -0
  83. package/src/duckdb/src/include/duckdb/function/scalar/strftime_format.hpp +8 -0
  84. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +8 -3
  85. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +7 -0
  86. package/src/duckdb/src/include/duckdb/function/table_function.hpp +8 -0
  87. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +1 -1
  88. package/src/duckdb/src/include/duckdb/optimizer/deliminator.hpp +2 -2
  89. package/src/duckdb/src/include/duckdb/planner/expression/bound_aggregate_expression.hpp +3 -0
  90. package/src/duckdb/src/include/duckdb/planner/expression/bound_function_expression.hpp +4 -0
  91. package/src/duckdb/src/include/duckdb/planner/expression/bound_window_expression.hpp +3 -0
  92. package/src/duckdb/src/include/duckdb/planner/filter/conjunction_filter.hpp +4 -0
  93. package/src/duckdb/src/include/duckdb/planner/filter/constant_filter.hpp +2 -0
  94. package/src/duckdb/src/include/duckdb/planner/filter/null_filter.hpp +4 -0
  95. package/src/duckdb/src/include/duckdb/planner/logical_tokens.hpp +0 -2
  96. package/src/duckdb/src/include/duckdb/planner/operator/list.hpp +1 -2
  97. package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +2 -4
  98. package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +2 -0
  99. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_index.hpp +10 -7
  100. package/src/duckdb/src/include/duckdb/planner/operator/logical_extension_operator.hpp +5 -0
  101. package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +7 -1
  102. package/src/duckdb/src/include/duckdb/planner/operator_extension.hpp +1 -0
  103. package/src/duckdb/src/include/duckdb/planner/table_filter.hpp +7 -1
  104. package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +0 -3
  105. package/src/duckdb/src/main/attached_database.cpp +2 -2
  106. package/src/duckdb/src/main/database.cpp +1 -1
  107. package/src/duckdb/src/main/db_instance_cache.cpp +14 -6
  108. package/src/duckdb/src/main/extension/extension_helper.cpp +13 -0
  109. package/src/duckdb/src/main/extension/extension_install.cpp +1 -1
  110. package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +1 -2
  111. package/src/duckdb/src/optimizer/compressed_materialization.cpp +0 -1
  112. package/src/duckdb/src/optimizer/deliminator.cpp +7 -7
  113. package/src/duckdb/src/optimizer/unnest_rewriter.cpp +3 -5
  114. package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +16 -1
  115. package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +1 -1
  116. package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +3 -3
  117. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +7 -23
  118. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +0 -24
  119. package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +3 -5
  120. package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +23 -0
  121. package/src/duckdb/src/planner/expression/bound_function_expression.cpp +22 -0
  122. package/src/duckdb/src/planner/expression/bound_window_expression.cpp +47 -0
  123. package/src/duckdb/src/planner/logical_operator.cpp +1 -6
  124. package/src/duckdb/src/planner/logical_operator_visitor.cpp +3 -6
  125. package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +2 -14
  126. package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +8 -0
  127. package/src/duckdb/src/planner/operator/logical_create_index.cpp +21 -12
  128. package/src/duckdb/src/planner/operator/logical_extension_operator.cpp +24 -0
  129. package/src/duckdb/src/planner/operator/logical_get.cpp +69 -0
  130. package/src/duckdb/src/planner/planner.cpp +0 -1
  131. package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -5
  132. package/src/duckdb/src/storage/meta_block_reader.cpp +0 -9
  133. package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +2 -0
  134. package/src/duckdb/src/storage/serialization/serialize_expression.cpp +9 -0
  135. package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +33 -0
  136. package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +190 -0
  137. package/src/duckdb/src/storage/serialization/serialize_table_filter.cpp +97 -0
  138. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  139. package/src/duckdb/src/storage/wal_replay.cpp +1 -3
  140. package/src/duckdb/ub_src_common_serializer.cpp +2 -0
  141. package/src/duckdb/ub_src_planner_operator.cpp +0 -4
  142. package/src/duckdb/ub_src_storage_serialization.cpp +2 -0
  143. package/src/statement.cpp +0 -2
  144. package/test/columns.test.ts +1 -2
  145. package/src/duckdb/src/include/duckdb/planner/operator/logical_asof_join.hpp +0 -27
  146. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_join.hpp +0 -32
  147. package/src/duckdb/src/planner/operator/logical_asof_join.cpp +0 -14
  148. package/src/duckdb/src/planner/operator/logical_delim_join.cpp +0 -25
@@ -36,7 +36,6 @@ bool StringEnumCastLoop(const string_t *source_data, ValidityMask &source_mask,
36
36
  template <class T>
37
37
  bool StringEnumCast(Vector &source, Vector &result, idx_t count, CastParameters &parameters) {
38
38
  D_ASSERT(source.GetType().id() == LogicalTypeId::VARCHAR);
39
- auto enum_name = EnumType::GetTypeName(result.GetType());
40
39
  switch (source.GetVectorType()) {
41
40
  case VectorType::CONSTANT_VECTOR: {
42
41
  result.SetVectorType(VectorType::CONSTANT_VECTOR);
@@ -286,6 +286,17 @@ static unique_ptr<FunctionData> ExportStateAggregateDeserialize(PlanDeserializat
286
286
  throw NotImplementedException("FIXME: export state deserialize");
287
287
  }
288
288
 
289
+ static void ExportStateAggregateFormatSerialize(FormatSerializer &serializer,
290
+ const optional_ptr<FunctionData> bind_data_p,
291
+ const AggregateFunction &function) {
292
+ throw SerializationException("FIXME: export state serialize");
293
+ }
294
+
295
+ static unique_ptr<FunctionData> ExportStateAggregateFormatDeserialize(FormatDeserializer &deserializer,
296
+ AggregateFunction &function) {
297
+ throw SerializationException("FIXME: export state deserialize");
298
+ }
299
+
289
300
  static void ExportStateScalarSerialize(FieldWriter &writer, const FunctionData *bind_data_p,
290
301
  const ScalarFunction &function) {
291
302
  throw NotImplementedException("FIXME: export state serialize");
@@ -295,6 +306,16 @@ static unique_ptr<FunctionData> ExportStateScalarDeserialize(PlanDeserialization
295
306
  throw NotImplementedException("FIXME: export state deserialize");
296
307
  }
297
308
 
309
+ static void ExportStateScalarFormatSerialize(FormatSerializer &serializer, const optional_ptr<FunctionData> bind_data_p,
310
+ const ScalarFunction &function) {
311
+ throw SerializationException("FIXME: export state serialize");
312
+ }
313
+
314
+ static unique_ptr<FunctionData> ExportStateScalarFormatDeserialize(FormatDeserializer &deserializer,
315
+ ScalarFunction &function) {
316
+ throw SerializationException("FIXME: export state deserialize");
317
+ }
318
+
298
319
  unique_ptr<BoundAggregateExpression>
299
320
  ExportAggregateFunction::Bind(unique_ptr<BoundAggregateExpression> child_aggregate) {
300
321
  auto &bound_function = child_aggregate->function;
@@ -331,6 +352,8 @@ ExportAggregateFunction::Bind(unique_ptr<BoundAggregateExpression> child_aggrega
331
352
  export_function.null_handling = FunctionNullHandling::SPECIAL_HANDLING;
332
353
  export_function.serialize = ExportStateAggregateSerialize;
333
354
  export_function.deserialize = ExportStateAggregateDeserialize;
355
+ export_function.format_serialize = ExportStateAggregateFormatSerialize;
356
+ export_function.format_deserialize = ExportStateAggregateFormatDeserialize;
334
357
 
335
358
  return make_uniq<BoundAggregateExpression>(export_function, std::move(child_aggregate->children),
336
359
  std::move(child_aggregate->filter), std::move(export_bind_data),
@@ -343,6 +366,8 @@ ScalarFunction ExportAggregateFunction::GetFinalize() {
343
366
  result.null_handling = FunctionNullHandling::SPECIAL_HANDLING;
344
367
  result.serialize = ExportStateScalarSerialize;
345
368
  result.deserialize = ExportStateScalarDeserialize;
369
+ result.format_serialize = ExportStateScalarFormatSerialize;
370
+ result.format_deserialize = ExportStateScalarFormatDeserialize;
346
371
  return result;
347
372
  }
348
373
 
@@ -353,6 +378,8 @@ ScalarFunction ExportAggregateFunction::GetCombine() {
353
378
  result.null_handling = FunctionNullHandling::SPECIAL_HANDLING;
354
379
  result.serialize = ExportStateScalarSerialize;
355
380
  result.deserialize = ExportStateScalarDeserialize;
381
+ result.format_serialize = ExportStateScalarFormatSerialize;
382
+ result.format_deserialize = ExportStateScalarFormatDeserialize;
356
383
  return result;
357
384
  }
358
385
 
@@ -13,7 +13,8 @@ ScalarFunction::ScalarFunction(string name, vector<LogicalType> arguments, Logic
13
13
  : BaseScalarFunction(std::move(name), std::move(arguments), std::move(return_type), side_effects,
14
14
  std::move(varargs), null_handling),
15
15
  function(std::move(function)), bind(bind), init_local_state(init_local_state), dependency(dependency),
16
- statistics(statistics), serialize(nullptr), deserialize(nullptr) {
16
+ statistics(statistics), serialize(nullptr), deserialize(nullptr), format_serialize(nullptr),
17
+ format_deserialize(nullptr) {
17
18
  }
18
19
 
19
20
  ScalarFunction::ScalarFunction(vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
@@ -26,9 +27,10 @@ ScalarFunction::ScalarFunction(vector<LogicalType> arguments, LogicalType return
26
27
  }
27
28
 
28
29
  bool ScalarFunction::operator==(const ScalarFunction &rhs) const {
29
- return CompareScalarFunctionT(rhs.function) && bind == rhs.bind && dependency == rhs.dependency &&
30
- statistics == rhs.statistics;
30
+ return name == rhs.name && arguments == rhs.arguments && return_type == rhs.return_type && varargs == rhs.varargs &&
31
+ bind == rhs.bind && dependency == rhs.dependency && statistics == rhs.statistics;
31
32
  }
33
+
32
34
  bool ScalarFunction::operator!=(const ScalarFunction &rhs) const {
33
35
  return !(*this == rhs);
34
36
  }
@@ -56,23 +58,6 @@ bool ScalarFunction::Equal(const ScalarFunction &rhs) const {
56
58
  return true; // they are equal
57
59
  }
58
60
 
59
- bool ScalarFunction::CompareScalarFunctionT(const scalar_function_t &other) const {
60
- typedef void(scalar_function_ptr_t)(DataChunk &, ExpressionState &, Vector &);
61
-
62
- auto func_ptr = (scalar_function_ptr_t **)function.template target<scalar_function_ptr_t *>(); // NOLINT
63
- auto other_ptr = (scalar_function_ptr_t **)other.template target<scalar_function_ptr_t *>(); // NOLINT
64
-
65
- // Case the functions were created from lambdas the target will return a nullptr
66
- if (!func_ptr && !other_ptr) {
67
- return true;
68
- }
69
- if (func_ptr == nullptr || other_ptr == nullptr) {
70
- // scalar_function_t (std::functions) from lambdas cannot be compared
71
- return false;
72
- }
73
- return CastPointerToValue(*func_ptr) == CastPointerToValue(*other_ptr);
74
- }
75
-
76
61
  void ScalarFunction::NopFunction(DataChunk &input, ExpressionState &state, Vector &result) {
77
62
  D_ASSERT(input.ColumnCount() >= 1);
78
63
  result.Reference(input.data[0]);
@@ -15,6 +15,8 @@
15
15
  #include "duckdb/main/client_data.hpp"
16
16
  #include "duckdb/execution/operator/persistent/csv_line_info.hpp"
17
17
  #include "duckdb/execution/operator/persistent/csv_rejects_table.hpp"
18
+ #include "duckdb/common/serializer/format_serializer.hpp"
19
+ #include "duckdb/common/serializer/format_deserializer.hpp"
18
20
 
19
21
  #include <limits>
20
22
 
@@ -1235,6 +1237,20 @@ static unique_ptr<FunctionData> CSVReaderDeserialize(PlanDeserializationState &s
1235
1237
  return std::move(result_data);
1236
1238
  }
1237
1239
 
1240
+ static void CSVReaderFormatSerialize(FormatSerializer &serializer, const optional_ptr<FunctionData> bind_data_p,
1241
+ const TableFunction &function) {
1242
+ auto &bind_data = bind_data_p->Cast<ReadCSVData>();
1243
+ serializer.WriteProperty("extra_info", function.extra_info);
1244
+ serializer.WriteProperty("csv_data", bind_data);
1245
+ }
1246
+
1247
+ static unique_ptr<FunctionData> CSVReaderFormatDeserialize(FormatDeserializer &deserializer, TableFunction &function) {
1248
+ unique_ptr<ReadCSVData> result;
1249
+ deserializer.ReadProperty("extra_info", function.extra_info);
1250
+ deserializer.ReadProperty("csv_data", result);
1251
+ return std::move(result);
1252
+ }
1253
+
1238
1254
  TableFunction ReadCSVTableFunction::GetFunction() {
1239
1255
  TableFunction read_csv("read_csv", {LogicalType::VARCHAR}, ReadCSVFunction, ReadCSVBind, ReadCSVInitGlobal,
1240
1256
  ReadCSVInitLocal);
@@ -1242,6 +1258,8 @@ TableFunction ReadCSVTableFunction::GetFunction() {
1242
1258
  read_csv.pushdown_complex_filter = CSVComplexFilterPushdown;
1243
1259
  read_csv.serialize = CSVReaderSerialize;
1244
1260
  read_csv.deserialize = CSVReaderDeserialize;
1261
+ read_csv.format_serialize = CSVReaderFormatSerialize;
1262
+ read_csv.format_deserialize = CSVReaderFormatDeserialize;
1245
1263
  read_csv.get_batch_index = CSVReaderGetBatchIndex;
1246
1264
  read_csv.cardinality = CSVReaderCardinality;
1247
1265
  read_csv.projection_pushdown = true;
@@ -1279,7 +1297,8 @@ unique_ptr<TableRef> ReadCSVReplacement(ClientContext &context, const string &ta
1279
1297
  table_function->function = make_uniq<FunctionExpression>("read_csv_auto", std::move(children));
1280
1298
 
1281
1299
  if (!FileSystem::HasGlob(table_name)) {
1282
- table_function->alias = FileSystem::ExtractBaseName(table_name);
1300
+ auto &fs = FileSystem::GetFileSystem(context);
1301
+ table_function->alias = fs.ExtractBaseName(table_name);
1283
1302
  }
1284
1303
 
1285
1304
  return std::move(table_function);
@@ -70,14 +70,14 @@ vector<TestType> TestAllTypesFun::GetTestTypes(bool use_large_enum) {
70
70
  auto small_enum_ptr = FlatVector::GetData<string_t>(small_enum);
71
71
  small_enum_ptr[0] = StringVector::AddStringOrBlob(small_enum, "DUCK_DUCK_ENUM");
72
72
  small_enum_ptr[1] = StringVector::AddStringOrBlob(small_enum, "GOOSE");
73
- result.emplace_back(LogicalType::ENUM("small_enum", small_enum, 2), "small_enum");
73
+ result.emplace_back(LogicalType::ENUM(small_enum, 2), "small_enum");
74
74
 
75
75
  Vector medium_enum(LogicalType::VARCHAR, 300);
76
76
  auto medium_enum_ptr = FlatVector::GetData<string_t>(medium_enum);
77
77
  for (idx_t i = 0; i < 300; i++) {
78
78
  medium_enum_ptr[i] = StringVector::AddStringOrBlob(medium_enum, string("enum_") + to_string(i));
79
79
  }
80
- result.emplace_back(LogicalType::ENUM("medium_enum", medium_enum, 300), "medium_enum");
80
+ result.emplace_back(LogicalType::ENUM(medium_enum, 300), "medium_enum");
81
81
 
82
82
  if (use_large_enum) {
83
83
  // this is a big one... not sure if we should push this one here, but it's required for completeness
@@ -86,13 +86,13 @@ vector<TestType> TestAllTypesFun::GetTestTypes(bool use_large_enum) {
86
86
  for (idx_t i = 0; i < 70000; i++) {
87
87
  large_enum_ptr[i] = StringVector::AddStringOrBlob(large_enum, string("enum_") + to_string(i));
88
88
  }
89
- result.emplace_back(LogicalType::ENUM("large_enum", large_enum, 70000), "large_enum");
89
+ result.emplace_back(LogicalType::ENUM(large_enum, 70000), "large_enum");
90
90
  } else {
91
91
  Vector large_enum(LogicalType::VARCHAR, 2);
92
92
  auto large_enum_ptr = FlatVector::GetData<string_t>(large_enum);
93
93
  large_enum_ptr[0] = StringVector::AddStringOrBlob(large_enum, string("enum_") + to_string(0));
94
94
  large_enum_ptr[1] = StringVector::AddStringOrBlob(large_enum, string("enum_") + to_string(69999));
95
- result.emplace_back(LogicalType::ENUM("large_enum", large_enum, 2), "large_enum");
95
+ result.emplace_back(LogicalType::ENUM(large_enum, 2), "large_enum");
96
96
  }
97
97
 
98
98
  // arrays
@@ -15,6 +15,8 @@
15
15
  #include "duckdb/catalog/dependency_list.hpp"
16
16
  #include "duckdb/function/function_set.hpp"
17
17
  #include "duckdb/storage/table/scan_state.hpp"
18
+ #include "duckdb/common/serializer/format_serializer.hpp"
19
+ #include "duckdb/common/serializer/format_deserializer.hpp"
18
20
 
19
21
  namespace duckdb {
20
22
 
@@ -447,6 +449,35 @@ static unique_ptr<FunctionData> TableScanDeserialize(PlanDeserializationState &s
447
449
  return std::move(result);
448
450
  }
449
451
 
452
+ static void TableScanFormatSerialize(FormatSerializer &serializer, const optional_ptr<FunctionData> bind_data_p,
453
+ const TableFunction &function) {
454
+ auto &bind_data = bind_data_p->Cast<TableScanBindData>();
455
+ serializer.WriteProperty("catalog", bind_data.table.schema.catalog.GetName());
456
+ serializer.WriteProperty("schema", bind_data.table.schema.name);
457
+ serializer.WriteProperty("table", bind_data.table.name);
458
+ serializer.WriteProperty("is_index_scan", bind_data.is_index_scan);
459
+ serializer.WriteProperty("is_create_index", bind_data.is_create_index);
460
+ serializer.WriteProperty("result_ids", bind_data.result_ids);
461
+ serializer.WriteProperty("result_ids", bind_data.result_ids);
462
+ }
463
+
464
+ static unique_ptr<FunctionData> TableScanFormatDeserialize(FormatDeserializer &deserializer, TableFunction &function) {
465
+ auto catalog = deserializer.ReadProperty<string>("catalog");
466
+ auto schema = deserializer.ReadProperty<string>("schema");
467
+ auto table = deserializer.ReadProperty<string>("table");
468
+ auto &catalog_entry =
469
+ Catalog::GetEntry<TableCatalogEntry>(deserializer.Get<ClientContext &>(), catalog, schema, table);
470
+ if (catalog_entry.type != CatalogType::TABLE_ENTRY) {
471
+ throw SerializationException("Cant find table for %s.%s", schema, table);
472
+ }
473
+ auto result = make_uniq<TableScanBindData>(catalog_entry.Cast<DuckTableEntry>());
474
+ deserializer.ReadProperty("is_index_scan", result->is_index_scan);
475
+ deserializer.ReadProperty("is_create_index", result->is_create_index);
476
+ deserializer.ReadProperty("result_ids", result->result_ids);
477
+ deserializer.ReadProperty("result_ids", result->result_ids);
478
+ return std::move(result);
479
+ }
480
+
450
481
  TableFunction TableScanFunction::GetIndexScanFunction() {
451
482
  TableFunction scan_function("index_scan", {}, IndexScanFunction);
452
483
  scan_function.init_local = nullptr;
@@ -462,6 +493,8 @@ TableFunction TableScanFunction::GetIndexScanFunction() {
462
493
  scan_function.filter_pushdown = false;
463
494
  scan_function.serialize = TableScanSerialize;
464
495
  scan_function.deserialize = TableScanDeserialize;
496
+ scan_function.format_serialize = TableScanFormatSerialize;
497
+ scan_function.format_deserialize = TableScanFormatDeserialize;
465
498
  return scan_function;
466
499
  }
467
500
 
@@ -482,6 +515,8 @@ TableFunction TableScanFunction::GetFunction() {
482
515
  scan_function.filter_prune = true;
483
516
  scan_function.serialize = TableScanSerialize;
484
517
  scan_function.deserialize = TableScanDeserialize;
518
+ scan_function.format_serialize = TableScanFormatSerialize;
519
+ scan_function.format_deserialize = TableScanFormatDeserialize;
485
520
  return scan_function;
486
521
  }
487
522
 
@@ -1,8 +1,8 @@
1
1
  #ifndef DUCKDB_VERSION
2
- #define DUCKDB_VERSION "0.8.2-dev2090"
2
+ #define DUCKDB_VERSION "0.8.2-dev2208"
3
3
  #endif
4
4
  #ifndef DUCKDB_SOURCE_ID
5
- #define DUCKDB_SOURCE_ID "8d8f9f1b79"
5
+ #define DUCKDB_SOURCE_ID "accdd3edb9"
6
6
  #endif
7
7
  #include "duckdb/function/table/system_functions.hpp"
8
8
  #include "duckdb/main/database.hpp"
@@ -18,8 +18,8 @@ TableFunction::TableFunction(string name, vector<LogicalType> arguments, table_f
18
18
  init_global(init_global), init_local(init_local), function(function), in_out_function(nullptr),
19
19
  in_out_function_final(nullptr), statistics(nullptr), dependency(nullptr), cardinality(nullptr),
20
20
  pushdown_complex_filter(nullptr), to_string(nullptr), table_scan_progress(nullptr), get_batch_index(nullptr),
21
- get_batch_info(nullptr), serialize(nullptr), deserialize(nullptr), projection_pushdown(false),
22
- filter_pushdown(false), filter_prune(false) {
21
+ get_batch_info(nullptr), serialize(nullptr), deserialize(nullptr), format_serialize(nullptr),
22
+ format_deserialize(nullptr), projection_pushdown(false), filter_pushdown(false), filter_prune(false) {
23
23
  }
24
24
 
25
25
  TableFunction::TableFunction(const vector<LogicalType> &arguments, table_function_t function,
@@ -32,7 +32,8 @@ TableFunction::TableFunction()
32
32
  init_local(nullptr), function(nullptr), in_out_function(nullptr), statistics(nullptr), dependency(nullptr),
33
33
  cardinality(nullptr), pushdown_complex_filter(nullptr), to_string(nullptr), table_scan_progress(nullptr),
34
34
  get_batch_index(nullptr), get_batch_info(nullptr), serialize(nullptr), deserialize(nullptr),
35
- projection_pushdown(false), filter_pushdown(false), filter_prune(false) {
35
+ format_serialize(nullptr), format_deserialize(nullptr), projection_pushdown(false), filter_pushdown(false),
36
+ filter_prune(false) {
36
37
  }
37
38
 
38
39
  bool TableFunction::Equal(const TableFunction &rhs) const {
@@ -71,8 +71,6 @@ public:
71
71
  DUCKDB_API vector<LogicalType> GetTypes();
72
72
  //! Returns a list of the columns of the table
73
73
  DUCKDB_API const ColumnList &GetColumns() const;
74
- //! Returns a mutable list of the columns of the table
75
- DUCKDB_API ColumnList &GetColumnsMutable();
76
74
  //! Returns the underlying storage of the table
77
75
  virtual DataTable &GetStorage();
78
76
  //! Returns a list of the bound constraints of the table
@@ -29,10 +29,7 @@ public:
29
29
  LogicalType user_type;
30
30
 
31
31
  public:
32
- //! Serialize the meta information of the TypeCatalogEntry a serializer
33
- virtual void Serialize(Serializer &serializer) const;
34
- //! Deserializes to a TypeCatalogEntry
35
- static unique_ptr<CreateTypeInfo> Deserialize(Deserializer &source);
32
+ unique_ptr<CreateInfo> GetInfo() const override;
36
33
 
37
34
  string ToSQL() const override;
38
35
  };
@@ -125,12 +125,6 @@ public:
125
125
  void Verify(Catalog &catalog);
126
126
 
127
127
  private:
128
- //! Adjusts table dependencies on the event of an UNDO
129
- void AdjustTableDependencies(CatalogEntry &entry);
130
- //! Adjust one dependency
131
- void AdjustDependency(CatalogEntry &entry, TableCatalogEntry &table, ColumnDefinition &column, bool remove);
132
- //! Adjust User dependency
133
- void AdjustUserDependency(CatalogEntry &entry, ColumnDefinition &column, bool remove);
134
128
  //! Given a root entry, gets the entry valid for this transaction
135
129
  CatalogEntry &GetEntryForTransaction(CatalogTransaction transaction, CatalogEntry &current);
136
130
  CatalogEntry &GetCommittedEntry(CatalogEntry &current);
@@ -35,7 +35,6 @@ struct ExtraTypeInfo {
35
35
 
36
36
  ExtraTypeInfoType type;
37
37
  string alias;
38
- optional_ptr<TypeCatalogEntry> catalog_entry;
39
38
 
40
39
  public:
41
40
  bool Equals(ExtraTypeInfo *other_p) const;
@@ -184,19 +183,17 @@ private:
184
183
  enum EnumDictType : uint8_t { INVALID = 0, VECTOR_DICT = 1 };
185
184
 
186
185
  struct EnumTypeInfo : public ExtraTypeInfo {
187
- explicit EnumTypeInfo(string enum_name_p, Vector &values_insert_order_p, idx_t dict_size_p);
186
+ explicit EnumTypeInfo(Vector &values_insert_order_p, idx_t dict_size_p);
188
187
  EnumTypeInfo(const EnumTypeInfo &) = delete;
189
188
  EnumTypeInfo &operator=(const EnumTypeInfo &) = delete;
190
189
 
191
190
  public:
192
191
  const EnumDictType &GetEnumDictType() const;
193
- const string &GetEnumName() const;
194
- const string GetSchemaName() const;
195
192
  const Vector &GetValuesInsertOrder() const;
196
193
  const idx_t &GetDictSize() const;
197
194
  static PhysicalType DictType(idx_t size);
198
195
 
199
- static LogicalType CreateType(const string &enum_name, Vector &ordered_data, idx_t size);
196
+ static LogicalType CreateType(Vector &ordered_data, idx_t size);
200
197
 
201
198
  void Serialize(FieldWriter &writer) const override;
202
199
  static shared_ptr<ExtraTypeInfo> Deserialize(FieldReader &reader);
@@ -212,7 +209,6 @@ protected:
212
209
 
213
210
  private:
214
211
  EnumDictType dict_type;
215
- string enum_name;
216
212
  idx_t dict_size;
217
213
  };
218
214
 
@@ -167,10 +167,6 @@ public:
167
167
  return root.GetContext();
168
168
  }
169
169
 
170
- optional_ptr<Catalog> GetCatalog() override {
171
- return root.GetCatalog();
172
- }
173
-
174
170
  private:
175
171
  Deserializer &root;
176
172
  idx_t remaining_data;
@@ -185,21 +185,21 @@ public:
185
185
  DUCKDB_API virtual string ExpandPath(const string &path);
186
186
  //! Returns the system-available memory in bytes. Returns DConstants::INVALID_INDEX if the system function fails.
187
187
  DUCKDB_API static idx_t GetAvailableMemory();
188
- //! Path separator for the current file system
189
- DUCKDB_API static string PathSeparator();
188
+ //! Path separator for path
189
+ DUCKDB_API virtual string PathSeparator(const string &path);
190
190
  //! Checks if path is starts with separator (i.e., '/' on UNIX '\\' on Windows)
191
- DUCKDB_API static bool IsPathAbsolute(const string &path);
191
+ DUCKDB_API bool IsPathAbsolute(const string &path);
192
192
  //! Normalize an absolute path - the goal of normalizing is converting "\test.db" and "C:/test.db" into "C:\test.db"
193
193
  //! so that the database system cache can correctly
194
- DUCKDB_API static string NormalizeAbsolutePath(const string &path);
194
+ DUCKDB_API string NormalizeAbsolutePath(const string &path);
195
195
  //! Join two paths together
196
- DUCKDB_API static string JoinPath(const string &a, const string &path);
196
+ DUCKDB_API string JoinPath(const string &a, const string &path);
197
197
  //! Convert separators in a path to the local separators (e.g. convert "/" into \\ on windows)
198
- DUCKDB_API static string ConvertSeparators(const string &path);
198
+ DUCKDB_API string ConvertSeparators(const string &path);
199
199
  //! Extract the base name of a file (e.g. if the input is lib/example.dll the base name is 'example')
200
- DUCKDB_API static string ExtractBaseName(const string &path);
200
+ DUCKDB_API string ExtractBaseName(const string &path);
201
201
  //! Extract the name of a file (e.g if the input is lib/example.dll the name is 'example.dll')
202
- DUCKDB_API static string ExtractName(const string &path);
202
+ DUCKDB_API string ExtractName(const string &path);
203
203
 
204
204
  //! Returns the value of an environment variable - or the empty string if it is not set
205
205
  DUCKDB_API static string GetEnvVariable(const string &name);
@@ -23,7 +23,7 @@ public:
23
23
 
24
24
  public:
25
25
  void SetFilenamePattern(const string &pattern);
26
- string CreateFilename(const FileSystem &fs, const string &path, const string &extension, idx_t offset) const;
26
+ string CreateFilename(FileSystem &fs, const string &path, const string &extension, idx_t offset) const;
27
27
 
28
28
  private:
29
29
  string _base;
@@ -8,7 +8,7 @@
8
8
 
9
9
  #pragma once
10
10
 
11
- #include "duckdb/common/types.hpp"
11
+ #include "duckdb/common/common.hpp"
12
12
  #include "duckdb/common/multi_file_reader_options.hpp"
13
13
  #include "duckdb/common/enums/file_glob_options.hpp"
14
14
  #include "duckdb/common/union_by_name.hpp"
@@ -32,6 +32,8 @@ struct HivePartitioningIndex {
32
32
 
33
33
  DUCKDB_API void Serialize(Serializer &serializer) const;
34
34
  DUCKDB_API static HivePartitioningIndex Deserialize(Deserializer &source);
35
+ DUCKDB_API void FormatSerialize(FormatSerializer &serializer) const;
36
+ DUCKDB_API static HivePartitioningIndex FormatDeserialize(FormatDeserializer &deserializer);
35
37
  };
36
38
 
37
39
  //! The bind data for the multi-file reader, obtained through MultiFileReader::BindReader
@@ -43,6 +45,8 @@ struct MultiFileReaderBindData {
43
45
 
44
46
  DUCKDB_API void Serialize(Serializer &serializer) const;
45
47
  DUCKDB_API static MultiFileReaderBindData Deserialize(Deserializer &source);
48
+ DUCKDB_API void FormatSerialize(FormatSerializer &serializer) const;
49
+ DUCKDB_API static MultiFileReaderBindData FormatDeserialize(FormatDeserializer &deserializer);
46
50
  };
47
51
 
48
52
  struct MultiFileFilterEntry {
@@ -28,9 +28,11 @@ struct MultiFileReaderOptions {
28
28
 
29
29
  DUCKDB_API void Serialize(Serializer &serializer) const;
30
30
  DUCKDB_API static MultiFileReaderOptions Deserialize(Deserializer &source);
31
+ DUCKDB_API void FormatSerialize(FormatSerializer &serializer) const;
32
+ DUCKDB_API static MultiFileReaderOptions FormatDeserialize(FormatDeserializer &source);
31
33
  DUCKDB_API void AddBatchInfo(BindInfo &bind_info) const;
32
34
  DUCKDB_API void AutoDetectHivePartitioning(const vector<string> &files, ClientContext &context);
33
- DUCKDB_API static bool AutoDetectHivePartitioningInternal(const vector<string> &files);
35
+ DUCKDB_API static bool AutoDetectHivePartitioningInternal(const vector<string> &files, ClientContext &context);
34
36
  DUCKDB_API void AutoDetectHiveTypesInternal(const string &file, ClientContext &context);
35
37
  DUCKDB_API void VerifyHiveTypesArePartitions(const std::map<string, string> &partitions) const;
36
38
  DUCKDB_API LogicalType GetHiveLogicalType(const string &hive_partition_column) const;
@@ -103,6 +103,10 @@ public:
103
103
  GetFileSystem().RemoveFile(filename);
104
104
  }
105
105
 
106
+ string PathSeparator(const string &path) override {
107
+ return GetFileSystem().PathSeparator(path);
108
+ }
109
+
106
110
  vector<string> Glob(const string &path, FileOpener *opener = nullptr) override {
107
111
  if (opener) {
108
112
  throw InternalException("OpenerFileSystem cannot take an opener - the opener is pushed automatically");
@@ -37,14 +37,10 @@ public:
37
37
 
38
38
  ClientContext &GetContext() override;
39
39
 
40
- optional_ptr<Catalog> GetCatalog() override;
41
- void SetCatalog(Catalog &catalog);
42
-
43
40
  private:
44
41
  idx_t file_size;
45
42
  idx_t total_read;
46
43
  optional_ptr<ClientContext> context;
47
- optional_ptr<Catalog> catalog;
48
44
  };
49
45
 
50
46
  } // namespace duckdb
@@ -127,6 +127,16 @@ public:
127
127
  return data.Unset<T>();
128
128
  }
129
129
 
130
+ // Manually begin an object - should be followed by EndObject
131
+ void BeginObject(const char *tag) {
132
+ SetTag(tag);
133
+ OnObjectBegin();
134
+ }
135
+
136
+ void EndObject() {
137
+ OnObjectEnd();
138
+ }
139
+
130
140
  private:
131
141
  // Deserialize anything implementing a FormatDeserialize method
132
142
  template <typename T = void>
@@ -208,6 +218,28 @@ private:
208
218
  return map;
209
219
  }
210
220
 
221
+ template <typename T = void>
222
+ inline typename std::enable_if<is_map<T>::value, T>::type Read() {
223
+ using KEY_TYPE = typename is_map<T>::KEY_TYPE;
224
+ using VALUE_TYPE = typename is_map<T>::VALUE_TYPE;
225
+
226
+ T map;
227
+ auto size = OnMapBegin();
228
+ for (idx_t i = 0; i < size; i++) {
229
+ OnMapEntryBegin();
230
+ OnMapKeyBegin();
231
+ auto key = Read<KEY_TYPE>();
232
+ OnMapKeyEnd();
233
+ OnMapValueBegin();
234
+ auto value = Read<VALUE_TYPE>();
235
+ OnMapValueEnd();
236
+ OnMapEntryEnd();
237
+ map[std::move(key)] = std::move(value);
238
+ }
239
+ OnMapEnd();
240
+ return map;
241
+ }
242
+
211
243
  // Deserialize an unordered set
212
244
  template <typename T = void>
213
245
  inline typename std::enable_if<is_unordered_set<T>::value, T>::type Read() {
@@ -28,25 +28,11 @@ protected:
28
28
  public:
29
29
  // Serialize a value
30
30
  template <class T>
31
- typename std::enable_if<!std::is_enum<T>::value, void>::type WriteProperty(const char *tag, const T &value) {
31
+ void WriteProperty(const char *tag, const T &value) {
32
32
  SetTag(tag);
33
33
  WriteValue(value);
34
34
  }
35
35
 
36
- // Serialize an enum
37
- template <class T>
38
- typename std::enable_if<std::is_enum<T>::value, void>::type WriteProperty(const char *tag, T value) {
39
- SetTag(tag);
40
- if (serialize_enum_as_string) {
41
- // Use the enum serializer to lookup tostring function
42
- auto str = EnumUtil::ToChars(value);
43
- WriteValue(str);
44
- } else {
45
- // Use the underlying type
46
- WriteValue(static_cast<typename std::underlying_type<T>::type>(value));
47
- }
48
- }
49
-
50
36
  // Optional pointer
51
37
  template <class POINTER>
52
38
  void WriteOptionalProperty(const char *tag, POINTER &&ptr) {
@@ -67,7 +53,29 @@ public:
67
53
  WriteDataPtr(ptr, count);
68
54
  }
69
55
 
56
+ // Manually begin an object - should be followed by EndObject
57
+ void BeginObject(const char *tag) {
58
+ SetTag(tag);
59
+ OnObjectBegin();
60
+ }
61
+
62
+ void EndObject() {
63
+ OnObjectEnd();
64
+ }
65
+
70
66
  protected:
67
+ template <typename T>
68
+ typename std::enable_if<std::is_enum<T>::value, void>::type WriteValue(const T value) {
69
+ if (serialize_enum_as_string) {
70
+ // Use the enum serializer to lookup tostring function
71
+ auto str = EnumUtil::ToChars(value);
72
+ WriteValue(str);
73
+ } else {
74
+ // Use the underlying type
75
+ WriteValue(static_cast<typename std::underlying_type<T>::type>(value));
76
+ }
77
+ }
78
+
71
79
  // Unique Pointer Ref
72
80
  template <typename T>
73
81
  void WriteValue(const unique_ptr<T> &ptr) {
@@ -160,6 +168,24 @@ protected:
160
168
  OnMapEnd(count);
161
169
  }
162
170
 
171
+ // Map
172
+ template <class K, class V, class HASH, class CMP>
173
+ void WriteValue(const duckdb::map<K, V, HASH, CMP> &map) {
174
+ auto count = map.size();
175
+ OnMapBegin(count);
176
+ for (auto &item : map) {
177
+ OnMapEntryBegin();
178
+ OnMapKeyBegin();
179
+ WriteValue(item.first);
180
+ OnMapKeyEnd();
181
+ OnMapValueBegin();
182
+ WriteValue(item.second);
183
+ OnMapValueEnd();
184
+ OnMapEntryEnd();
185
+ }
186
+ OnMapEnd(count);
187
+ }
188
+
163
189
  // class or struct implementing `FormatSerialize(FormatSerializer& FormatSerializer)`;
164
190
  template <typename T>
165
191
  typename std::enable_if<has_serialize<T>::value>::type WriteValue(const T &value) {
@@ -247,4 +273,8 @@ protected:
247
273
  }
248
274
  };
249
275
 
276
+ // We need to special case vector<bool> because elements of vector<bool> cannot be referenced
277
+ template <>
278
+ void FormatSerializer::WriteValue(const vector<bool> &vec);
279
+
250
280
  } // namespace duckdb
@@ -70,6 +70,16 @@ struct is_unordered_map<typename duckdb::unordered_map<Args...>> : std::true_typ
70
70
  typedef typename std::tuple_element<3, std::tuple<Args...>>::type EQUAL_TYPE;
71
71
  };
72
72
 
73
+ template <typename T>
74
+ struct is_map : std::false_type {};
75
+ template <typename... Args>
76
+ struct is_map<typename duckdb::map<Args...>> : std::true_type {
77
+ typedef typename std::tuple_element<0, std::tuple<Args...>>::type KEY_TYPE;
78
+ typedef typename std::tuple_element<1, std::tuple<Args...>>::type VALUE_TYPE;
79
+ typedef typename std::tuple_element<2, std::tuple<Args...>>::type HASH_TYPE;
80
+ typedef typename std::tuple_element<3, std::tuple<Args...>>::type EQUAL_TYPE;
81
+ };
82
+
73
83
  template <typename T>
74
84
  struct is_unique_ptr : std::false_type {};
75
85