duckdb 0.8.2-dev2133.0 → 0.8.2-dev2278.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 (99) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb/extension/json/json_functions.cpp +2 -1
  3. package/src/duckdb/extension/parquet/parquet_extension.cpp +2 -1
  4. package/src/duckdb/src/catalog/catalog.cpp +2 -6
  5. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +1 -4
  6. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +0 -4
  7. package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +7 -26
  8. package/src/duckdb/src/catalog/catalog_set.cpp +0 -63
  9. package/src/duckdb/src/catalog/dependency_manager.cpp +0 -36
  10. package/src/duckdb/src/common/adbc/adbc.cpp +1 -1
  11. package/src/duckdb/src/common/extra_type_info.cpp +24 -46
  12. package/src/duckdb/src/common/field_writer.cpp +0 -1
  13. package/src/duckdb/src/common/file_system.cpp +6 -6
  14. package/src/duckdb/src/common/filename_pattern.cpp +1 -1
  15. package/src/duckdb/src/common/gzip_file_system.cpp +7 -12
  16. package/src/duckdb/src/common/multi_file_reader.cpp +8 -5
  17. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +0 -9
  18. package/src/duckdb/src/common/types.cpp +12 -56
  19. package/src/duckdb/src/common/virtual_file_system.cpp +4 -0
  20. package/src/duckdb/src/core_functions/scalar/union/union_tag.cpp +1 -1
  21. package/src/duckdb/src/execution/column_binding_resolver.cpp +3 -7
  22. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +1 -1
  23. package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +0 -10
  24. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +2 -1
  25. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +2 -6
  26. package/src/duckdb/src/execution/physical_plan/plan_asof_join.cpp +1 -2
  27. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +14 -1
  28. package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +3 -17
  29. package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +2 -5
  30. package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -5
  31. package/src/duckdb/src/function/cast/string_cast.cpp +0 -1
  32. package/src/duckdb/src/function/scalar_function.cpp +3 -19
  33. package/src/duckdb/src/function/table/arrow.cpp +1 -1
  34. package/src/duckdb/src/function/table/arrow_conversion.cpp +12 -10
  35. package/src/duckdb/src/function/table/read_csv.cpp +2 -1
  36. package/src/duckdb/src/function/table/system/test_all_types.cpp +4 -4
  37. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  38. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +0 -2
  39. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +1 -4
  40. package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +0 -6
  41. package/src/duckdb/src/include/duckdb/common/extra_type_info.hpp +2 -6
  42. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +0 -4
  43. package/src/duckdb/src/include/duckdb/common/file_system.hpp +8 -8
  44. package/src/duckdb/src/include/duckdb/common/filename_pattern.hpp +1 -1
  45. package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +1 -1
  46. package/src/duckdb/src/include/duckdb/common/opener_file_system.hpp +4 -0
  47. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +0 -4
  48. package/src/duckdb/src/include/duckdb/common/serializer.hpp +0 -7
  49. package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +14 -10
  50. package/src/duckdb/src/include/duckdb/common/types.hpp +5 -10
  51. package/src/duckdb/src/include/duckdb/common/virtual_file_system.hpp +2 -0
  52. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +0 -4
  53. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +3 -2
  54. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +0 -3
  55. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +1 -1
  56. package/src/duckdb/src/include/duckdb/optimizer/deliminator.hpp +2 -2
  57. package/src/duckdb/src/include/duckdb/planner/logical_tokens.hpp +0 -2
  58. package/src/duckdb/src/include/duckdb/planner/operator/list.hpp +1 -2
  59. package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +2 -4
  60. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_index.hpp +10 -7
  61. package/src/duckdb/src/include/duckdb/planner/operator/logical_extension_operator.hpp +5 -0
  62. package/src/duckdb/src/include/duckdb/planner/operator_extension.hpp +1 -0
  63. package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +0 -3
  64. package/src/duckdb/src/include/duckdb.h +15 -0
  65. package/src/duckdb/src/main/attached_database.cpp +2 -2
  66. package/src/duckdb/src/main/capi/duckdb-c.cpp +16 -0
  67. package/src/duckdb/src/main/database.cpp +1 -1
  68. package/src/duckdb/src/main/db_instance_cache.cpp +14 -6
  69. package/src/duckdb/src/main/extension/extension_install.cpp +1 -1
  70. package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +1 -2
  71. package/src/duckdb/src/optimizer/compressed_materialization.cpp +0 -1
  72. package/src/duckdb/src/optimizer/deliminator.cpp +7 -7
  73. package/src/duckdb/src/optimizer/unnest_rewriter.cpp +3 -5
  74. package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +16 -1
  75. package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +1 -1
  76. package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +3 -3
  77. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +8 -23
  78. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +0 -24
  79. package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +3 -5
  80. package/src/duckdb/src/planner/logical_operator.cpp +1 -6
  81. package/src/duckdb/src/planner/logical_operator_visitor.cpp +3 -6
  82. package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +2 -14
  83. package/src/duckdb/src/planner/operator/logical_create_index.cpp +21 -12
  84. package/src/duckdb/src/planner/operator/logical_extension_operator.cpp +24 -0
  85. package/src/duckdb/src/planner/planner.cpp +0 -1
  86. package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -5
  87. package/src/duckdb/src/storage/meta_block_reader.cpp +0 -9
  88. package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +2 -0
  89. package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +27 -0
  90. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  91. package/src/duckdb/src/storage/table/list_column_data.cpp +6 -3
  92. package/src/duckdb/src/storage/wal_replay.cpp +1 -3
  93. package/src/duckdb/ub_src_planner_operator.cpp +0 -4
  94. package/src/statement.cpp +0 -2
  95. package/test/columns.test.ts +1 -2
  96. package/src/duckdb/src/include/duckdb/planner/operator/logical_asof_join.hpp +0 -27
  97. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_join.hpp +0 -32
  98. package/src/duckdb/src/planner/operator/logical_asof_join.cpp +0 -14
  99. package/src/duckdb/src/planner/operator/logical_delim_join.cpp +0 -25
@@ -24,7 +24,6 @@
24
24
  #include "duckdb/planner/operator/logical_create_index.hpp"
25
25
  #include "duckdb/planner/operator/logical_create_table.hpp"
26
26
  #include "duckdb/planner/operator/logical_get.hpp"
27
- #include "duckdb/planner/operator/logical_distinct.hpp"
28
27
  #include "duckdb/planner/operator/logical_projection.hpp"
29
28
  #include "duckdb/planner/parsed_data/bound_create_table_info.hpp"
30
29
  #include "duckdb/planner/query_node/bound_select_node.hpp"
@@ -39,6 +38,7 @@
39
38
  #include "duckdb/main/database_manager.hpp"
40
39
  #include "duckdb/main/attached_database.hpp"
41
40
  #include "duckdb/catalog/duck_catalog.hpp"
41
+ #include "duckdb/function/table/table_scan.hpp"
42
42
 
43
43
  namespace duckdb {
44
44
 
@@ -260,23 +260,7 @@ void Binder::BindLogicalType(ClientContext &context, LogicalType &type, optional
260
260
  } else {
261
261
  type = Catalog::GetType(context, INVALID_CATALOG, schema, user_type_name);
262
262
  }
263
- } else if (type.id() == LogicalTypeId::ENUM) {
264
- auto enum_type_name = EnumType::GetTypeName(type);
265
- optional_ptr<TypeCatalogEntry> enum_type_catalog;
266
- if (catalog) {
267
- enum_type_catalog =
268
- catalog->GetEntry<TypeCatalogEntry>(context, schema, enum_type_name, OnEntryNotFound::RETURN_NULL);
269
- if (!enum_type_catalog) {
270
- // look in the system catalog if the type was not found
271
- enum_type_catalog = Catalog::GetEntry<TypeCatalogEntry>(context, SYSTEM_CATALOG, schema, enum_type_name,
272
- OnEntryNotFound::RETURN_NULL);
273
- }
274
- } else {
275
- enum_type_catalog = Catalog::GetEntry<TypeCatalogEntry>(context, INVALID_CATALOG, schema, enum_type_name,
276
- OnEntryNotFound::RETURN_NULL);
277
- }
278
-
279
- EnumType::SetCatalog(type, enum_type_catalog.get());
263
+ BindLogicalType(context, type, catalog, schema);
280
264
  }
281
265
  }
282
266
 
@@ -483,10 +467,14 @@ unique_ptr<LogicalOperator> DuckCatalog::BindCreateIndex(Binder &binder, CreateS
483
467
  create_index_info->scan_types.emplace_back(LogicalType::ROW_TYPE);
484
468
  create_index_info->names = get.names;
485
469
  create_index_info->column_ids = get.column_ids;
470
+ auto &bind_data = get.bind_data->Cast<TableScanBindData>();
471
+ bind_data.is_create_index = true;
472
+ get.column_ids.push_back(COLUMN_IDENTIFIER_ROW_ID);
486
473
 
487
474
  // the logical CREATE INDEX also needs all fields to scan the referenced table
488
- return make_uniq<LogicalCreateIndex>(std::move(get.bind_data), std::move(create_index_info), std::move(expressions),
489
- table, std::move(get.function));
475
+ auto result = make_uniq<LogicalCreateIndex>(std::move(create_index_info), std::move(expressions), table);
476
+ result->children.push_back(std::move(plan));
477
+ return std::move(result);
490
478
  }
491
479
 
492
480
  BoundStatement Binder::Bind(CreateStatement &stmt) {
@@ -548,7 +536,6 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
548
536
  if (plan->type != LogicalOperatorType::LOGICAL_GET) {
549
537
  throw BinderException("Cannot create index on a view!");
550
538
  }
551
-
552
539
  result.plan = table.catalog.BindCreateIndex(*this, stmt, table, std::move(plan));
553
540
  break;
554
541
  }
@@ -653,8 +640,6 @@ BoundStatement Binder::Bind(CreateStatement &stmt) {
653
640
  // We set b to be an alias for the underlying type of a
654
641
  auto inner_type = Catalog::GetType(context, schema.catalog.GetName(), schema.name,
655
642
  UserType::GetTypeName(create_type_info.type));
656
- // clear to nullptr, we don't need this
657
- EnumType::SetCatalog(inner_type, nullptr);
658
643
  inner_type.SetAlias(create_type_info.name);
659
644
  create_type_info.type = inner_type;
660
645
  }
@@ -292,30 +292,6 @@ unique_ptr<BoundCreateTableInfo> Binder::BindCreateTableInfo(unique_ptr<CreateIn
292
292
  ExpressionBinder::TestCollation(context, StringType::GetCollation(column.Type()));
293
293
  }
294
294
  BindLogicalType(context, column.TypeMutable(), &result->schema.catalog);
295
- // We add a catalog dependency
296
- auto type_dependency = EnumType::GetCatalog(column.Type());
297
-
298
- if (type_dependency) {
299
- // Only if the USER comes from a create type
300
- if (schema.catalog.IsTemporaryCatalog() && column.Type().id() == LogicalTypeId::ENUM) {
301
- // for enum types that are used in tables in the temp catalog, we need to
302
- // make a copy of the enum type definition that is accessible there
303
- auto enum_type = type_dependency->user_type;
304
- auto &enum_entries = EnumType::GetValuesInsertOrder(enum_type);
305
- auto enum_size = EnumType::GetSize(enum_type);
306
- Vector copy_enum_entries_vec(LogicalType::VARCHAR, enum_size);
307
- auto copy_enum_entries_ptr = FlatVector::GetData<string_t>(copy_enum_entries_vec);
308
- auto enum_entries_ptr = FlatVector::GetData<string_t>(enum_entries);
309
- for (idx_t enum_idx = 0; enum_idx < enum_size; enum_idx++) {
310
- copy_enum_entries_ptr[enum_idx] =
311
- StringVector::AddStringOrBlob(copy_enum_entries_vec, enum_entries_ptr[enum_idx]);
312
- }
313
- auto copy_type = LogicalType::ENUM(EnumType::GetTypeName(enum_type), copy_enum_entries_vec, enum_size);
314
- column.SetType(copy_type);
315
- } else {
316
- result->dependencies.AddDependency(*type_dependency);
317
- }
318
- }
319
295
  }
320
296
  result->dependencies.VerifyDependencies(schema.catalog, result->Base().table);
321
297
  properties.allow_stream_result = false;
@@ -7,7 +7,6 @@
7
7
  #include "duckdb/planner/expression_iterator.hpp"
8
8
  #include "duckdb/planner/binder.hpp"
9
9
  #include "duckdb/planner/operator/logical_any_join.hpp"
10
- #include "duckdb/planner/operator/logical_asof_join.hpp"
11
10
  #include "duckdb/planner/operator/logical_comparison_join.hpp"
12
11
  #include "duckdb/planner/operator/logical_cross_product.hpp"
13
12
  #include "duckdb/planner/operator/logical_dependent_join.hpp"
@@ -193,12 +192,11 @@ unique_ptr<LogicalOperator> LogicalComparisonJoin::CreateJoin(ClientContext &con
193
192
  } else {
194
193
  // we successfully converted expressions into JoinConditions
195
194
  // create a LogicalComparisonJoin
196
- unique_ptr<LogicalComparisonJoin> comp_join;
195
+ auto logical_type = LogicalOperatorType::LOGICAL_COMPARISON_JOIN;
197
196
  if (reftype == JoinRefType::ASOF) {
198
- comp_join = make_uniq<LogicalAsOfJoin>(type);
199
- } else {
200
- comp_join = make_uniq<LogicalComparisonJoin>(type);
197
+ logical_type = LogicalOperatorType::LOGICAL_ASOF_JOIN;
201
198
  }
199
+ auto comp_join = make_uniq<LogicalComparisonJoin>(type, logical_type);
202
200
  comp_join->conditions = std::move(conditions);
203
201
  comp_join->children.push_back(std::move(left_child));
204
202
  comp_join->children.push_back(std::move(right_child));
@@ -131,7 +131,6 @@ void LogicalOperator::Verify(ClientContext &context) {
131
131
  }
132
132
  BufferedSerializer serializer;
133
133
  // We are serializing a query plan
134
- serializer.is_query_plan = true;
135
134
  try {
136
135
  expressions[expr_idx]->Serialize(serializer);
137
136
  } catch (NotImplementedException &ex) {
@@ -266,12 +265,8 @@ unique_ptr<LogicalOperator> LogicalOperator::Deserialize(Deserializer &deseriali
266
265
  break;
267
266
  case LogicalOperatorType::LOGICAL_JOIN:
268
267
  throw InternalException("LogicalJoin deserialize not supported");
269
- case LogicalOperatorType::LOGICAL_DELIM_JOIN:
270
- result = LogicalDelimJoin::Deserialize(state, reader);
271
- break;
272
268
  case LogicalOperatorType::LOGICAL_ASOF_JOIN:
273
- result = LogicalAsOfJoin::Deserialize(state, reader);
274
- break;
269
+ case LogicalOperatorType::LOGICAL_DELIM_JOIN:
275
270
  case LogicalOperatorType::LOGICAL_COMPARISON_JOIN:
276
271
  result = LogicalComparisonJoin::Deserialize(state, reader);
277
272
  break;
@@ -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
@@ -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
@@ -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);
@@ -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;
@@ -43,6 +46,9 @@ unique_ptr<LogicalOperator> LogicalOperator::FormatDeserialize(FormatDeserialize
43
46
  case LogicalOperatorType::LOGICAL_COPY_TO_FILE:
44
47
  result = LogicalCopyToFile::FormatDeserialize(deserializer);
45
48
  break;
49
+ case LogicalOperatorType::LOGICAL_CREATE_INDEX:
50
+ result = LogicalCreateIndex::FormatDeserialize(deserializer);
51
+ break;
46
52
  case LogicalOperatorType::LOGICAL_CREATE_MACRO:
47
53
  result = LogicalCreate::FormatDeserialize(deserializer);
48
54
  break;
@@ -73,6 +79,9 @@ unique_ptr<LogicalOperator> LogicalOperator::FormatDeserialize(FormatDeserialize
73
79
  case LogicalOperatorType::LOGICAL_DELIM_GET:
74
80
  result = LogicalDelimGet::FormatDeserialize(deserializer);
75
81
  break;
82
+ case LogicalOperatorType::LOGICAL_DELIM_JOIN:
83
+ result = LogicalComparisonJoin::FormatDeserialize(deserializer);
84
+ break;
76
85
  case LogicalOperatorType::LOGICAL_DETACH:
77
86
  result = LogicalSimple::FormatDeserialize(deserializer);
78
87
  break;
@@ -97,6 +106,9 @@ unique_ptr<LogicalOperator> LogicalOperator::FormatDeserialize(FormatDeserialize
97
106
  case LogicalOperatorType::LOGICAL_EXPRESSION_GET:
98
107
  result = LogicalExpressionGet::FormatDeserialize(deserializer);
99
108
  break;
109
+ case LogicalOperatorType::LOGICAL_EXTENSION_OPERATOR:
110
+ result = LogicalExtensionOperator::FormatDeserialize(deserializer);
111
+ break;
100
112
  case LogicalOperatorType::LOGICAL_FILTER:
101
113
  result = LogicalFilter::FormatDeserialize(deserializer);
102
114
  break;
@@ -261,6 +273,7 @@ void LogicalComparisonJoin::FormatSerialize(FormatSerializer &serializer) const
261
273
  serializer.WriteProperty("right_projection_map", right_projection_map);
262
274
  serializer.WriteProperty("conditions", conditions);
263
275
  serializer.WriteProperty("mark_types", mark_types);
276
+ serializer.WriteProperty("duplicate_eliminated_columns", duplicate_eliminated_columns);
264
277
  }
265
278
 
266
279
  unique_ptr<LogicalOperator> LogicalComparisonJoin::FormatDeserialize(FormatDeserializer &deserializer) {
@@ -271,6 +284,7 @@ unique_ptr<LogicalOperator> LogicalComparisonJoin::FormatDeserialize(FormatDeser
271
284
  deserializer.ReadProperty("right_projection_map", result->right_projection_map);
272
285
  deserializer.ReadProperty("conditions", result->conditions);
273
286
  deserializer.ReadProperty("mark_types", result->mark_types);
287
+ deserializer.ReadProperty("duplicate_eliminated_columns", result->duplicate_eliminated_columns);
274
288
  return std::move(result);
275
289
  }
276
290
 
@@ -285,6 +299,19 @@ unique_ptr<LogicalOperator> LogicalCreate::FormatDeserialize(FormatDeserializer
285
299
  return std::move(result);
286
300
  }
287
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
+
288
315
  void LogicalCreateTable::FormatSerialize(FormatSerializer &serializer) const {
289
316
  LogicalOperator::FormatSerialize(serializer);
290
317
  serializer.WriteProperty("catalog", schema.ParentCatalog().GetName());
@@ -2,7 +2,7 @@
2
2
 
3
3
  namespace duckdb {
4
4
 
5
- const uint64_t VERSION_NUMBER = 53;
5
+ const uint64_t VERSION_NUMBER = 54;
6
6
 
7
7
  struct StorageVersionInfo {
8
8
  const char *version_name;
@@ -89,16 +89,19 @@ idx_t ListColumnData::ScanCount(ColumnScanState &state, Vector &result, idx_t co
89
89
  D_ASSERT(scan_count > 0);
90
90
  validity.ScanCount(state.child_states[0], result, count);
91
91
 
92
- auto data = FlatVector::GetData<uint64_t>(offset_vector);
93
- auto last_entry = data[scan_count - 1];
92
+ UnifiedVectorFormat offsets;
93
+ offset_vector.ToUnifiedFormat(scan_count, offsets);
94
+ auto data = UnifiedVectorFormat::GetData<uint64_t>(offsets);
95
+ auto last_entry = data[offsets.sel->get_index(scan_count - 1)];
94
96
 
95
97
  // shift all offsets so they are 0 at the first entry
96
98
  auto result_data = FlatVector::GetData<list_entry_t>(result);
97
99
  auto base_offset = state.last_offset;
98
100
  idx_t current_offset = 0;
99
101
  for (idx_t i = 0; i < scan_count; i++) {
102
+ auto offset_index = offsets.sel->get_index(i);
100
103
  result_data[i].offset = current_offset;
101
- result_data[i].length = data[i] - current_offset - base_offset;
104
+ result_data[i].length = data[offset_index] - current_offset - base_offset;
102
105
  current_offset += result_data[i].length;
103
106
  }
104
107
 
@@ -36,7 +36,6 @@ bool WriteAheadLog::Replay(AttachedDatabase &database, string &path) {
36
36
  // first deserialize the WAL to look for a checkpoint flag
37
37
  // if there is a checkpoint flag, we might have already flushed the contents of the WAL to disk
38
38
  ReplayState checkpoint_state(database, *con.context, *initial_reader);
39
- initial_reader->SetCatalog(checkpoint_state.catalog);
40
39
  checkpoint_state.deserialize_only = true;
41
40
  try {
42
41
  while (true) {
@@ -73,7 +72,6 @@ bool WriteAheadLog::Replay(AttachedDatabase &database, string &path) {
73
72
 
74
73
  // we need to recover from the WAL: actually set up the replay state
75
74
  BufferedFileReader reader(FileSystem::Get(database), path.c_str(), con.context.get());
76
- reader.SetCatalog(checkpoint_state.catalog);
77
75
  ReplayState state(database, *con.context, reader);
78
76
 
79
77
  // replay the WAL
@@ -284,7 +282,7 @@ void ReplayState::ReplayDropSchema() {
284
282
  void ReplayState::ReplayCreateType() {
285
283
  auto info = TypeCatalogEntry::Deserialize(source);
286
284
  info->on_conflict = OnCreateConflict::IGNORE_ON_CONFLICT;
287
- catalog.CreateType(context, *info);
285
+ catalog.CreateType(context, info->Cast<CreateTypeInfo>());
288
286
  }
289
287
 
290
288
  void ReplayState::ReplayDropType() {
@@ -2,8 +2,6 @@
2
2
 
3
3
  #include "src/planner/operator/logical_any_join.cpp"
4
4
 
5
- #include "src/planner/operator/logical_asof_join.cpp"
6
-
7
5
  #include "src/planner/operator/logical_column_data_get.cpp"
8
6
 
9
7
  #include "src/planner/operator/logical_comparison_join.cpp"
@@ -24,8 +22,6 @@
24
22
 
25
23
  #include "src/planner/operator/logical_delim_get.cpp"
26
24
 
27
- #include "src/planner/operator/logical_delim_join.cpp"
28
-
29
25
  #include "src/planner/operator/logical_dependent_join.cpp"
30
26
 
31
27
  #include "src/planner/operator/logical_distinct.cpp"
package/src/statement.cpp CHANGED
@@ -548,7 +548,6 @@ static Napi::Value TypeToObject(Napi::Env &env, const duckdb::LogicalType &type)
548
548
  obj.Set("value", TypeToObject(env, value_type));
549
549
  } break;
550
550
  case duckdb::LogicalTypeId::ENUM: {
551
- auto name = duckdb::EnumType::GetTypeName(type);
552
551
  auto &values_vec = duckdb::EnumType::GetValuesInsertOrder(type);
553
552
  auto enum_size = duckdb::EnumType::GetSize(type);
554
553
  auto arr = Napi::Array::New(env, enum_size);
@@ -556,7 +555,6 @@ static Napi::Value TypeToObject(Napi::Env &env, const duckdb::LogicalType &type)
556
555
  auto child_name = values_vec.GetValue(i).GetValue<duckdb::string>();
557
556
  arr.Set(i, child_name);
558
557
  }
559
- obj.Set("name", name);
560
558
  obj.Set("values", arr);
561
559
  } break;
562
560
  case duckdb::LogicalTypeId::UNION: {
@@ -48,8 +48,7 @@ describe('Column Types', function() {
48
48
  name: 'small_enum',
49
49
  type: {
50
50
  id: 'ENUM',
51
- sql_type: 'small_enum',
52
- name: 'small_enum',
51
+ sql_type: "ENUM('DUCK_DUCK_ENUM', 'GOOSE')",
53
52
  values: [
54
53
  "DUCK_DUCK_ENUM",
55
54
  "GOOSE"
@@ -1,27 +0,0 @@
1
- //===----------------------------------------------------------------------===//
2
- // DuckDB
3
- //
4
- // duckdb/planner/operator/logical_asof_join.hpp
5
- //
6
- //
7
- //===----------------------------------------------------------------------===//
8
-
9
- #pragma once
10
-
11
- #include "duckdb/planner/operator/logical_comparison_join.hpp"
12
-
13
- namespace duckdb {
14
-
15
- //! LogicalAsOfJoin represents a temporal-style join with one less-than inequality.
16
- //! This inequality matches the greatest value on the right that satisfies the condition.
17
- class LogicalAsOfJoin : public LogicalComparisonJoin {
18
- public:
19
- static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_ASOF_JOIN;
20
-
21
- public:
22
- explicit LogicalAsOfJoin(JoinType type);
23
-
24
- static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
25
- };
26
-
27
- } // namespace duckdb
@@ -1,32 +0,0 @@
1
- //===----------------------------------------------------------------------===//
2
- // DuckDB
3
- //
4
- // duckdb/planner/operator/logical_delim_join.hpp
5
- //
6
- //
7
- //===----------------------------------------------------------------------===//
8
-
9
- #pragma once
10
-
11
- #include "duckdb/planner/operator/logical_comparison_join.hpp"
12
-
13
- namespace duckdb {
14
-
15
- //! LogicalDelimJoin represents a special "duplicate eliminated" join. This join type is only used for subquery
16
- //! flattening, and involves performing duplicate elimination on the LEFT side which is then pushed into the RIGHT side.
17
- class LogicalDelimJoin : public LogicalComparisonJoin {
18
- public:
19
- static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_DELIM_JOIN;
20
-
21
- public:
22
- explicit LogicalDelimJoin(JoinType type);
23
-
24
- //! The set of columns that will be duplicate eliminated from the LHS and pushed into the RHS
25
- vector<unique_ptr<Expression>> duplicate_eliminated_columns;
26
-
27
- public:
28
- void Serialize(FieldWriter &writer) const override;
29
- static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
30
- };
31
-
32
- } // namespace duckdb
@@ -1,14 +0,0 @@
1
- #include "duckdb/planner/operator/logical_asof_join.hpp"
2
-
3
- namespace duckdb {
4
-
5
- LogicalAsOfJoin::LogicalAsOfJoin(JoinType type) : LogicalComparisonJoin(type, LogicalOperatorType::LOGICAL_ASOF_JOIN) {
6
- }
7
-
8
- unique_ptr<LogicalOperator> LogicalAsOfJoin::Deserialize(LogicalDeserializationState &state, FieldReader &reader) {
9
- auto result = make_uniq<LogicalAsOfJoin>(JoinType::INVALID);
10
- LogicalComparisonJoin::Deserialize(*result, state, reader);
11
- return std::move(result);
12
- }
13
-
14
- } // namespace duckdb