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
@@ -70,13 +70,10 @@ void LogicalOperatorVisitor::EnumerateExpressions(LogicalOperator &op,
70
70
  case LogicalOperatorType::LOGICAL_DELIM_JOIN:
71
71
  case LogicalOperatorType::LOGICAL_DEPENDENT_JOIN:
72
72
  case LogicalOperatorType::LOGICAL_COMPARISON_JOIN: {
73
- if (op.type == LogicalOperatorType::LOGICAL_DELIM_JOIN) {
74
- auto &delim_join = op.Cast<LogicalDelimJoin>();
75
- for (auto &expr : delim_join.duplicate_eliminated_columns) {
76
- callback(&expr);
77
- }
78
- }
79
73
  auto &join = op.Cast<LogicalComparisonJoin>();
74
+ for (auto &expr : join.duplicate_eliminated_columns) {
75
+ callback(&expr);
76
+ }
80
77
  for (auto &cond : join.conditions) {
81
78
  callback(&cond.left);
82
79
  callback(&cond.right);
@@ -1,7 +1,6 @@
1
1
  #include "duckdb/common/field_writer.hpp"
2
2
  #include "duckdb/common/string_util.hpp"
3
3
  #include "duckdb/planner/operator/logical_comparison_join.hpp"
4
- #include "duckdb/planner/operator/logical_delim_join.hpp"
5
4
  #include "duckdb/planner/expression/bound_comparison_expression.hpp"
6
5
  #include "duckdb/common/enum_util.hpp"
7
6
  namespace duckdb {
@@ -26,6 +25,7 @@ void LogicalComparisonJoin::Serialize(FieldWriter &writer) const {
26
25
  LogicalJoin::Serialize(writer);
27
26
  writer.WriteRegularSerializableList(mark_types);
28
27
  writer.WriteRegularSerializableList(conditions);
28
+ writer.WriteSerializableList(duplicate_eliminated_columns);
29
29
  }
30
30
 
31
31
  void LogicalComparisonJoin::Deserialize(LogicalComparisonJoin &comparison_join, LogicalDeserializationState &state,
@@ -33,6 +33,7 @@ void LogicalComparisonJoin::Deserialize(LogicalComparisonJoin &comparison_join,
33
33
  LogicalJoin::Deserialize(comparison_join, state, reader);
34
34
  comparison_join.mark_types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
35
35
  comparison_join.conditions = reader.ReadRequiredSerializableList<JoinCondition, JoinCondition>(state.gstate);
36
+ comparison_join.duplicate_eliminated_columns = reader.ReadRequiredSerializableList<Expression>(state.gstate);
36
37
  }
37
38
 
38
39
  unique_ptr<LogicalOperator> LogicalComparisonJoin::Deserialize(LogicalDeserializationState &state,
@@ -42,17 +43,4 @@ unique_ptr<LogicalOperator> LogicalComparisonJoin::Deserialize(LogicalDeserializ
42
43
  return std::move(result);
43
44
  }
44
45
 
45
- unique_ptr<LogicalOperator> LogicalComparisonJoin::FromDelimJoin(LogicalDelimJoin &delim_join) {
46
- auto new_join = make_uniq<LogicalComparisonJoin>(delim_join.join_type);
47
- new_join->children = std::move(delim_join.children);
48
- new_join->conditions = std::move(delim_join.conditions);
49
- new_join->types = std::move(delim_join.types);
50
- new_join->mark_types = std::move(delim_join.mark_types);
51
- new_join->mark_index = delim_join.mark_index;
52
- new_join->left_projection_map = std::move(delim_join.left_projection_map);
53
- new_join->right_projection_map = std::move(delim_join.right_projection_map);
54
- new_join->join_stats = std::move(delim_join.join_stats);
55
- return std::move(new_join);
56
- }
57
-
58
46
  } // namespace duckdb
@@ -59,6 +59,14 @@ unique_ptr<LogicalOperator> LogicalCopyToFile::Deserialize(LogicalDeserializatio
59
59
  return std::move(result);
60
60
  }
61
61
 
62
+ void LogicalCopyToFile::FormatSerialize(FormatSerializer &serializer) const {
63
+ throw SerializationException("LogicalCopyToFile not implemented yet");
64
+ }
65
+
66
+ unique_ptr<LogicalOperator> LogicalCopyToFile::FormatDeserialize(FormatDeserializer &deserializer) {
67
+ throw SerializationException("LogicalCopyToFile not implemented yet");
68
+ }
69
+
62
70
  idx_t LogicalCopyToFile::EstimateCardinality(ClientContext &context) {
63
71
  return 1;
64
72
  }
@@ -6,11 +6,9 @@
6
6
 
7
7
  namespace duckdb {
8
8
 
9
- LogicalCreateIndex::LogicalCreateIndex(unique_ptr<FunctionData> bind_data_p, unique_ptr<CreateIndexInfo> info_p,
10
- vector<unique_ptr<Expression>> expressions_p, TableCatalogEntry &table_p,
11
- TableFunction function_p)
12
- : LogicalOperator(LogicalOperatorType::LOGICAL_CREATE_INDEX), bind_data(std::move(bind_data_p)),
13
- info(std::move(info_p)), table(table_p), function(std::move(function_p)) {
9
+ LogicalCreateIndex::LogicalCreateIndex(unique_ptr<CreateIndexInfo> info_p, vector<unique_ptr<Expression>> expressions_p,
10
+ TableCatalogEntry &table_p)
11
+ : LogicalOperator(LogicalOperatorType::LOGICAL_CREATE_INDEX), info(std::move(info_p)), table(table_p) {
14
12
 
15
13
  for (auto &expr : expressions_p) {
16
14
  this->unbound_expressions.push_back(expr->Copy());
@@ -22,12 +20,21 @@ LogicalCreateIndex::LogicalCreateIndex(unique_ptr<FunctionData> bind_data_p, uni
22
20
  }
23
21
  }
24
22
 
23
+ LogicalCreateIndex::LogicalCreateIndex(ClientContext &context, unique_ptr<CreateInfo> info_p,
24
+ vector<unique_ptr<Expression>> expressions_p)
25
+ : LogicalOperator(LogicalOperatorType::LOGICAL_CREATE_INDEX),
26
+ info(unique_ptr_cast<CreateInfo, CreateIndexInfo>(std::move(info_p))), table(BindTable(context, *info)) {
27
+ for (auto &expr : expressions_p) {
28
+ this->unbound_expressions.push_back(expr->Copy());
29
+ }
30
+ this->expressions = std::move(expressions_p);
31
+ }
32
+
25
33
  void LogicalCreateIndex::Serialize(FieldWriter &writer) const {
26
34
  writer.WriteOptional(info);
27
35
  writer.WriteString(table.catalog.GetName());
28
36
  writer.WriteString(table.schema.name);
29
37
  writer.WriteString(table.name);
30
- FunctionSerializer::SerializeBase<TableFunction>(writer, function, bind_data.get());
31
38
  writer.WriteSerializableList(unbound_expressions);
32
39
  }
33
40
 
@@ -38,10 +45,6 @@ unique_ptr<LogicalOperator> LogicalCreateIndex::Deserialize(LogicalDeserializati
38
45
  auto catalog = reader.ReadRequired<string>();
39
46
  auto schema = reader.ReadRequired<string>();
40
47
  auto table_name = reader.ReadRequired<string>();
41
- unique_ptr<FunctionData> bind_data;
42
- bool has_deserialize;
43
- auto function = FunctionSerializer::DeserializeBaseInternal<TableFunction, TableFunctionCatalogEntry>(
44
- reader, state.gstate, CatalogType::TABLE_FUNCTION_ENTRY, bind_data, has_deserialize);
45
48
  auto unbound_expressions = reader.ReadRequiredSerializableList<Expression>(state.gstate);
46
49
  if (info->type != CatalogType::INDEX_ENTRY) {
47
50
  throw InternalException("Unexpected type: '%s', expected '%s'", CatalogTypeToString(info->type),
@@ -49,12 +52,18 @@ unique_ptr<LogicalOperator> LogicalCreateIndex::Deserialize(LogicalDeserializati
49
52
  }
50
53
  auto index_info = unique_ptr_cast<CreateInfo, CreateIndexInfo>(std::move(info));
51
54
  auto &table = Catalog::GetEntry<TableCatalogEntry>(context, catalog, schema, table_name);
52
- return make_uniq<LogicalCreateIndex>(std::move(bind_data), std::move(index_info), std::move(unbound_expressions),
53
- table, std::move(function));
55
+ return make_uniq<LogicalCreateIndex>(std::move(index_info), std::move(unbound_expressions), table);
54
56
  }
55
57
 
56
58
  void LogicalCreateIndex::ResolveTypes() {
57
59
  types.emplace_back(LogicalType::BIGINT);
58
60
  }
59
61
 
62
+ TableCatalogEntry &LogicalCreateIndex::BindTable(ClientContext &context, CreateIndexInfo &info) {
63
+ auto &catalog = info.catalog;
64
+ auto &schema = info.schema;
65
+ auto &table_name = info.table;
66
+ return Catalog::GetEntry<TableCatalogEntry>(context, catalog, schema, table_name);
67
+ }
68
+
60
69
  } // namespace duckdb
@@ -1,5 +1,7 @@
1
1
  #include "duckdb/planner/operator/logical_extension_operator.hpp"
2
2
  #include "duckdb/main/config.hpp"
3
+ #include "duckdb/common/serializer/format_serializer.hpp"
4
+ #include "duckdb/common/serializer/format_deserializer.hpp"
3
5
 
4
6
  namespace duckdb {
5
7
  unique_ptr<LogicalExtensionOperator> LogicalExtensionOperator::Deserialize(LogicalDeserializationState &state,
@@ -15,4 +17,26 @@ unique_ptr<LogicalExtensionOperator> LogicalExtensionOperator::Deserialize(Logic
15
17
 
16
18
  throw SerializationException("No serialization method exists for extension: " + extension_name);
17
19
  }
20
+
21
+ void LogicalExtensionOperator::FormatSerialize(FormatSerializer &serializer) const {
22
+ LogicalOperator::FormatSerialize(serializer);
23
+ serializer.WriteProperty("extension_name", GetExtensionName());
24
+ }
25
+
26
+ unique_ptr<LogicalOperator> LogicalExtensionOperator::FormatDeserialize(FormatDeserializer &deserializer) {
27
+ auto &config = DBConfig::GetConfig(deserializer.Get<ClientContext &>());
28
+ auto extension_name = deserializer.ReadProperty<string>("extension_name");
29
+ for (auto &extension : config.operator_extensions) {
30
+ if (extension->GetName() == extension_name) {
31
+ return extension->FormatDeserialize(deserializer);
32
+ }
33
+ }
34
+ throw SerializationException("No deserialization method exists for extension: " + extension_name);
35
+ }
36
+
37
+ string LogicalExtensionOperator::GetExtensionName() const {
38
+ throw SerializationException("LogicalExtensionOperator::GetExtensionName not implemented which is required for "
39
+ "serializing extension operators");
40
+ }
41
+
18
42
  } // namespace duckdb
@@ -8,9 +8,14 @@
8
8
  #include "duckdb/function/table/table_scan.hpp"
9
9
  #include "duckdb/main/config.hpp"
10
10
  #include "duckdb/storage/data_table.hpp"
11
+ #include "duckdb/common/serializer/format_serializer.hpp"
12
+ #include "duckdb/common/serializer/format_deserializer.hpp"
11
13
 
12
14
  namespace duckdb {
13
15
 
16
+ LogicalGet::LogicalGet() : LogicalOperator(LogicalOperatorType::LOGICAL_GET) {
17
+ }
18
+
14
19
  LogicalGet::LogicalGet(idx_t table_index, TableFunction function, unique_ptr<FunctionData> bind_data,
15
20
  vector<LogicalType> returned_types, vector<string> returned_names)
16
21
  : LogicalOperator(LogicalOperatorType::LOGICAL_GET), table_index(table_index), function(std::move(function)),
@@ -199,6 +204,70 @@ unique_ptr<LogicalOperator> LogicalGet::Deserialize(LogicalDeserializationState
199
204
  return std::move(result);
200
205
  }
201
206
 
207
+ void LogicalGet::FormatSerialize(FormatSerializer &serializer) const {
208
+ LogicalOperator::FormatSerialize(serializer);
209
+ serializer.WriteProperty("table_index", table_index);
210
+ serializer.WriteProperty("returned_types", returned_types);
211
+ serializer.WriteProperty("names", names);
212
+ serializer.WriteProperty("column_ids", column_ids);
213
+ serializer.WriteProperty("projection_ids", projection_ids);
214
+ serializer.WriteProperty("table_filters", table_filters);
215
+ FunctionSerializer::FormatSerialize(serializer, function, bind_data.get());
216
+ if (!function.format_serialize) {
217
+ D_ASSERT(!function.format_deserialize);
218
+ // no serialize method: serialize input values and named_parameters for rebinding purposes
219
+ serializer.WriteProperty("parameters", parameters);
220
+ serializer.WriteProperty("named_parameters", named_parameters);
221
+ serializer.WriteProperty("input_table_types", input_table_types);
222
+ serializer.WriteProperty("input_table_names", input_table_names);
223
+ }
224
+ serializer.WriteProperty("projected_input", projected_input);
225
+ }
226
+
227
+ unique_ptr<LogicalOperator> LogicalGet::FormatDeserialize(FormatDeserializer &deserializer) {
228
+ auto result = unique_ptr<LogicalGet>(new LogicalGet());
229
+ deserializer.ReadProperty("table_index", result->table_index);
230
+ deserializer.ReadProperty("returned_types", result->returned_types);
231
+ deserializer.ReadProperty("names", result->names);
232
+ deserializer.ReadProperty("column_ids", result->column_ids);
233
+ deserializer.ReadProperty("projection_ids", result->projection_ids);
234
+ deserializer.ReadProperty("table_filters", result->table_filters);
235
+ auto entry = FunctionSerializer::FormatDeserializeBase<TableFunction, TableFunctionCatalogEntry>(
236
+ deserializer, CatalogType::TABLE_FUNCTION_ENTRY);
237
+ auto &function = entry.first;
238
+ auto has_serialize = entry.second;
239
+
240
+ unique_ptr<FunctionData> bind_data;
241
+ if (!has_serialize) {
242
+ deserializer.ReadProperty("parameters", result->parameters);
243
+ deserializer.ReadProperty("named_parameters", result->named_parameters);
244
+ deserializer.ReadProperty("input_table_types", result->input_table_types);
245
+ deserializer.ReadProperty("input_table_names", result->input_table_names);
246
+ TableFunctionBindInput input(result->parameters, result->named_parameters, result->input_table_types,
247
+ result->input_table_names, function.function_info.get());
248
+
249
+ vector<LogicalType> bind_return_types;
250
+ vector<string> bind_names;
251
+ if (!function.bind) {
252
+ throw InternalException("Table function \"%s\" has neither bind nor (de)serialize", function.name);
253
+ }
254
+ bind_data = function.bind(deserializer.Get<ClientContext &>(), input, bind_return_types, bind_names);
255
+ if (result->returned_types != bind_return_types) {
256
+ throw SerializationException(
257
+ "Table function deserialization failure - bind returned different return types than were serialized");
258
+ }
259
+ // names can actually be different because of aliases - only the sizes cannot be different
260
+ if (result->names.size() != bind_names.size()) {
261
+ throw SerializationException(
262
+ "Table function deserialization failure - bind returned different returned names than were serialized");
263
+ }
264
+ } else {
265
+ bind_data = FunctionSerializer::FunctionDeserialize(deserializer, function);
266
+ }
267
+ deserializer.ReadProperty("projected_input", result->projected_input);
268
+ return std::move(result);
269
+ }
270
+
202
271
  vector<idx_t> LogicalGet::GetTableIndex() const {
203
272
  return vector<idx_t> {table_index};
204
273
  }
@@ -176,7 +176,6 @@ void Planner::VerifyPlan(ClientContext &context, unique_ptr<LogicalOperator> &op
176
176
  }
177
177
 
178
178
  BufferedSerializer serializer;
179
- serializer.is_query_plan = true;
180
179
  try {
181
180
  op->Serialize(serializer);
182
181
  } catch (NotImplementedException &ex) {
@@ -131,7 +131,6 @@ void SingleFileCheckpointReader::LoadFromStorage() {
131
131
  con.BeginTransaction();
132
132
  // create the MetaBlockReader to read from the storage
133
133
  MetaBlockReader reader(block_manager, meta_block);
134
- reader.SetCatalog(catalog.GetAttached().GetCatalog());
135
134
  reader.SetContext(*con.context);
136
135
  LoadCheckpoint(*con.context, reader);
137
136
  con.Commit();
@@ -414,10 +413,7 @@ void CheckpointWriter::WriteType(TypeCatalogEntry &type) {
414
413
 
415
414
  void CheckpointReader::ReadType(ClientContext &context, MetaBlockReader &reader) {
416
415
  auto info = TypeCatalogEntry::Deserialize(reader);
417
- auto &catalog_entry = catalog.CreateType(context, *info)->Cast<TypeCatalogEntry>();
418
- if (info->type.id() == LogicalTypeId::ENUM) {
419
- EnumType::SetCatalog(info->type, &catalog_entry);
420
- }
416
+ catalog.CreateType(context, info->Cast<CreateTypeInfo>());
421
417
  }
422
418
 
423
419
  //===--------------------------------------------------------------------===//
@@ -43,10 +43,6 @@ ClientContext &MetaBlockReader::GetContext() {
43
43
  return *context;
44
44
  }
45
45
 
46
- optional_ptr<Catalog> MetaBlockReader::GetCatalog() {
47
- return catalog;
48
- }
49
-
50
46
  void MetaBlockReader::ReadNewBlock(block_id_t id) {
51
47
  auto &buffer_manager = block_manager.buffer_manager;
52
48
 
@@ -65,11 +61,6 @@ void MetaBlockReader::ReadNewBlock(block_id_t id) {
65
61
  offset = sizeof(block_id_t);
66
62
  }
67
63
 
68
- void MetaBlockReader::SetCatalog(Catalog &catalog_p) {
69
- D_ASSERT(!catalog);
70
- catalog = &catalog_p;
71
- }
72
-
73
64
  void MetaBlockReader::SetContext(ClientContext &context_p) {
74
65
  D_ASSERT(!context);
75
66
  context = &context_p;
@@ -75,6 +75,7 @@ unique_ptr<CreateInfo> CreateInfo::FormatDeserialize(FormatDeserializer &deseria
75
75
  void CreateIndexInfo::FormatSerialize(FormatSerializer &serializer) const {
76
76
  CreateInfo::FormatSerialize(serializer);
77
77
  serializer.WriteProperty("name", index_name);
78
+ serializer.WriteProperty("table", table);
78
79
  serializer.WriteProperty("index_type", index_type);
79
80
  serializer.WriteProperty("constraint_type", constraint_type);
80
81
  serializer.WriteProperty("parsed_expressions", parsed_expressions);
@@ -85,6 +86,7 @@ void CreateIndexInfo::FormatSerialize(FormatSerializer &serializer) const {
85
86
  unique_ptr<CreateInfo> CreateIndexInfo::FormatDeserialize(FormatDeserializer &deserializer) {
86
87
  auto result = duckdb::unique_ptr<CreateIndexInfo>(new CreateIndexInfo());
87
88
  deserializer.ReadProperty("name", result->index_name);
89
+ deserializer.ReadProperty("table", result->table);
88
90
  deserializer.ReadProperty("index_type", result->index_type);
89
91
  deserializer.ReadProperty("constraint_type", result->constraint_type);
90
92
  deserializer.ReadProperty("parsed_expressions", result->parsed_expressions);
@@ -22,6 +22,9 @@ unique_ptr<Expression> Expression::FormatDeserialize(FormatDeserializer &deseria
22
22
  deserializer.Set<ExpressionType>(type);
23
23
  unique_ptr<Expression> result;
24
24
  switch (expression_class) {
25
+ case ExpressionClass::BOUND_AGGREGATE:
26
+ result = BoundAggregateExpression::FormatDeserialize(deserializer);
27
+ break;
25
28
  case ExpressionClass::BOUND_BETWEEN:
26
29
  result = BoundBetweenExpression::FormatDeserialize(deserializer);
27
30
  break;
@@ -46,6 +49,9 @@ unique_ptr<Expression> Expression::FormatDeserialize(FormatDeserializer &deseria
46
49
  case ExpressionClass::BOUND_DEFAULT:
47
50
  result = BoundDefaultExpression::FormatDeserialize(deserializer);
48
51
  break;
52
+ case ExpressionClass::BOUND_FUNCTION:
53
+ result = BoundFunctionExpression::FormatDeserialize(deserializer);
54
+ break;
49
55
  case ExpressionClass::BOUND_LAMBDA:
50
56
  result = BoundLambdaExpression::FormatDeserialize(deserializer);
51
57
  break;
@@ -64,6 +70,9 @@ unique_ptr<Expression> Expression::FormatDeserialize(FormatDeserializer &deseria
64
70
  case ExpressionClass::BOUND_UNNEST:
65
71
  result = BoundUnnestExpression::FormatDeserialize(deserializer);
66
72
  break;
73
+ case ExpressionClass::BOUND_WINDOW:
74
+ result = BoundWindowExpression::FormatDeserialize(deserializer);
75
+ break;
67
76
  default:
68
77
  throw SerializationException("Unsupported type for deserialization of Expression!");
69
78
  }
@@ -31,6 +31,9 @@ unique_ptr<LogicalOperator> LogicalOperator::FormatDeserialize(FormatDeserialize
31
31
  case LogicalOperatorType::LOGICAL_ANY_JOIN:
32
32
  result = LogicalAnyJoin::FormatDeserialize(deserializer);
33
33
  break;
34
+ case LogicalOperatorType::LOGICAL_ASOF_JOIN:
35
+ result = LogicalComparisonJoin::FormatDeserialize(deserializer);
36
+ break;
34
37
  case LogicalOperatorType::LOGICAL_ATTACH:
35
38
  result = LogicalSimple::FormatDeserialize(deserializer);
36
39
  break;
@@ -40,6 +43,12 @@ unique_ptr<LogicalOperator> LogicalOperator::FormatDeserialize(FormatDeserialize
40
43
  case LogicalOperatorType::LOGICAL_COMPARISON_JOIN:
41
44
  result = LogicalComparisonJoin::FormatDeserialize(deserializer);
42
45
  break;
46
+ case LogicalOperatorType::LOGICAL_COPY_TO_FILE:
47
+ result = LogicalCopyToFile::FormatDeserialize(deserializer);
48
+ break;
49
+ case LogicalOperatorType::LOGICAL_CREATE_INDEX:
50
+ result = LogicalCreateIndex::FormatDeserialize(deserializer);
51
+ break;
43
52
  case LogicalOperatorType::LOGICAL_CREATE_MACRO:
44
53
  result = LogicalCreate::FormatDeserialize(deserializer);
45
54
  break;
@@ -70,6 +79,9 @@ unique_ptr<LogicalOperator> LogicalOperator::FormatDeserialize(FormatDeserialize
70
79
  case LogicalOperatorType::LOGICAL_DELIM_GET:
71
80
  result = LogicalDelimGet::FormatDeserialize(deserializer);
72
81
  break;
82
+ case LogicalOperatorType::LOGICAL_DELIM_JOIN:
83
+ result = LogicalComparisonJoin::FormatDeserialize(deserializer);
84
+ break;
73
85
  case LogicalOperatorType::LOGICAL_DETACH:
74
86
  result = LogicalSimple::FormatDeserialize(deserializer);
75
87
  break;
@@ -94,9 +106,15 @@ unique_ptr<LogicalOperator> LogicalOperator::FormatDeserialize(FormatDeserialize
94
106
  case LogicalOperatorType::LOGICAL_EXPRESSION_GET:
95
107
  result = LogicalExpressionGet::FormatDeserialize(deserializer);
96
108
  break;
109
+ case LogicalOperatorType::LOGICAL_EXTENSION_OPERATOR:
110
+ result = LogicalExtensionOperator::FormatDeserialize(deserializer);
111
+ break;
97
112
  case LogicalOperatorType::LOGICAL_FILTER:
98
113
  result = LogicalFilter::FormatDeserialize(deserializer);
99
114
  break;
115
+ case LogicalOperatorType::LOGICAL_GET:
116
+ result = LogicalGet::FormatDeserialize(deserializer);
117
+ break;
100
118
  case LogicalOperatorType::LOGICAL_INSERT:
101
119
  result = LogicalInsert::FormatDeserialize(deserializer);
102
120
  break;
@@ -255,6 +273,7 @@ void LogicalComparisonJoin::FormatSerialize(FormatSerializer &serializer) const
255
273
  serializer.WriteProperty("right_projection_map", right_projection_map);
256
274
  serializer.WriteProperty("conditions", conditions);
257
275
  serializer.WriteProperty("mark_types", mark_types);
276
+ serializer.WriteProperty("duplicate_eliminated_columns", duplicate_eliminated_columns);
258
277
  }
259
278
 
260
279
  unique_ptr<LogicalOperator> LogicalComparisonJoin::FormatDeserialize(FormatDeserializer &deserializer) {
@@ -265,6 +284,7 @@ unique_ptr<LogicalOperator> LogicalComparisonJoin::FormatDeserialize(FormatDeser
265
284
  deserializer.ReadProperty("right_projection_map", result->right_projection_map);
266
285
  deserializer.ReadProperty("conditions", result->conditions);
267
286
  deserializer.ReadProperty("mark_types", result->mark_types);
287
+ deserializer.ReadProperty("duplicate_eliminated_columns", result->duplicate_eliminated_columns);
268
288
  return std::move(result);
269
289
  }
270
290
 
@@ -279,6 +299,19 @@ unique_ptr<LogicalOperator> LogicalCreate::FormatDeserialize(FormatDeserializer
279
299
  return std::move(result);
280
300
  }
281
301
 
302
+ void LogicalCreateIndex::FormatSerialize(FormatSerializer &serializer) const {
303
+ LogicalOperator::FormatSerialize(serializer);
304
+ serializer.WriteProperty("info", *info);
305
+ serializer.WriteProperty("unbound_expressions", unbound_expressions);
306
+ }
307
+
308
+ unique_ptr<LogicalOperator> LogicalCreateIndex::FormatDeserialize(FormatDeserializer &deserializer) {
309
+ auto info = deserializer.ReadProperty<unique_ptr<CreateInfo>>("info");
310
+ auto unbound_expressions = deserializer.ReadProperty<vector<unique_ptr<Expression>>>("unbound_expressions");
311
+ auto result = duckdb::unique_ptr<LogicalCreateIndex>(new LogicalCreateIndex(deserializer.Get<ClientContext &>(), std::move(info), std::move(unbound_expressions)));
312
+ return std::move(result);
313
+ }
314
+
282
315
  void LogicalCreateTable::FormatSerialize(FormatSerializer &serializer) const {
283
316
  LogicalOperator::FormatSerialize(serializer);
284
317
  serializer.WriteProperty("catalog", schema.ParentCatalog().GetName());