duckdb 0.8.2-dev1968.0 → 0.8.2-dev2044.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 (205) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb/src/catalog/catalog.cpp +1 -1
  3. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +17 -41
  4. package/src/duckdb/src/catalog/catalog_entry/macro_catalog_entry.cpp +2 -10
  5. package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +4 -14
  6. package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +11 -28
  7. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +11 -38
  8. package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +11 -27
  9. package/src/duckdb/src/catalog/catalog_entry.cpp +25 -1
  10. package/src/duckdb/src/common/enum_util.cpp +159 -0
  11. package/src/duckdb/src/common/extra_type_info.cpp +1 -2
  12. package/src/duckdb/src/common/serializer/binary_deserializer.cpp +3 -0
  13. package/src/duckdb/src/common/serializer/binary_serializer.cpp +4 -4
  14. package/src/duckdb/src/common/types/column/column_data_collection.cpp +43 -0
  15. package/src/duckdb/src/common/types/vector.cpp +1 -1
  16. package/src/duckdb/src/common/types.cpp +0 -12
  17. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +1 -1
  18. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  19. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -2
  20. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +1 -4
  21. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +2 -5
  22. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -6
  23. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +2 -11
  24. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +2 -5
  25. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +14 -0
  26. package/src/duckdb/src/include/duckdb/common/constants.hpp +2 -0
  27. package/src/duckdb/src/include/duckdb/common/enum_util.hpp +32 -0
  28. package/src/duckdb/src/include/duckdb/common/enums/index_type.hpp +1 -1
  29. package/src/duckdb/src/include/duckdb/common/index_vector.hpp +12 -0
  30. package/src/duckdb/src/include/duckdb/common/serializer/binary_deserializer.hpp +28 -4
  31. package/src/duckdb/src/include/duckdb/common/serializer/binary_serializer.hpp +12 -5
  32. package/src/duckdb/src/include/duckdb/common/serializer/deserialization_data.hpp +110 -0
  33. package/src/duckdb/src/include/duckdb/common/serializer/format_deserializer.hpp +46 -1
  34. package/src/duckdb/src/include/duckdb/common/serializer/format_serializer.hpp +23 -21
  35. package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +12 -4
  36. package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection.hpp +3 -0
  37. package/src/duckdb/src/include/duckdb/function/macro_function.hpp +3 -0
  38. package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +3 -0
  39. package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +3 -0
  40. package/src/duckdb/src/include/duckdb/parser/column_definition.hpp +6 -5
  41. package/src/duckdb/src/include/duckdb/parser/column_list.hpp +4 -0
  42. package/src/duckdb/src/include/duckdb/parser/constraint.hpp +5 -0
  43. package/src/duckdb/src/include/duckdb/parser/constraints/check_constraint.hpp +3 -0
  44. package/src/duckdb/src/include/duckdb/parser/constraints/foreign_key_constraint.hpp +6 -0
  45. package/src/duckdb/src/include/duckdb/parser/constraints/not_null_constraint.hpp +3 -0
  46. package/src/duckdb/src/include/duckdb/parser/constraints/unique_constraint.hpp +6 -0
  47. package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +1 -1
  48. package/src/duckdb/src/include/duckdb/parser/expression/case_expression.hpp +1 -1
  49. package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +1 -1
  50. package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +1 -1
  51. package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +1 -1
  52. package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +1 -1
  53. package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +1 -1
  54. package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +1 -1
  55. package/src/duckdb/src/include/duckdb/parser/expression/default_expression.hpp +1 -1
  56. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +1 -1
  57. package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +1 -1
  58. package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +1 -1
  59. package/src/duckdb/src/include/duckdb/parser/expression/parameter_expression.hpp +1 -1
  60. package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +1 -1
  61. package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +1 -1
  62. package/src/duckdb/src/include/duckdb/parser/expression/subquery_expression.hpp +1 -1
  63. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +1 -1
  64. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +12 -1
  65. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +66 -2
  66. package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +8 -1
  67. package/src/duckdb/src/include/duckdb/parser/parsed_data/copy_info.hpp +8 -1
  68. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +4 -1
  69. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_info.hpp +9 -2
  70. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +3 -0
  71. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_schema_info.hpp +3 -0
  72. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_sequence_info.hpp +3 -0
  73. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +3 -0
  74. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_type_info.hpp +3 -0
  75. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +3 -0
  76. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +7 -0
  77. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +7 -0
  78. package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +7 -0
  79. package/src/duckdb/src/include/duckdb/parser/parsed_data/load_info.hpp +13 -3
  80. package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +22 -0
  81. package/src/duckdb/src/include/duckdb/parser/parsed_data/pragma_info.hpp +10 -0
  82. package/src/duckdb/src/include/duckdb/parser/parsed_data/show_select_info.hpp +7 -0
  83. package/src/duckdb/src/include/duckdb/parser/parsed_data/transaction_info.hpp +10 -0
  84. package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +10 -0
  85. package/src/duckdb/src/include/duckdb/planner/bound_constraint.hpp +0 -8
  86. package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +6 -0
  87. package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +5 -0
  88. package/src/duckdb/src/include/duckdb/planner/expression/bound_between_expression.hpp +6 -0
  89. package/src/duckdb/src/include/duckdb/planner/expression/bound_case_expression.hpp +6 -0
  90. package/src/duckdb/src/include/duckdb/planner/expression/bound_cast_expression.hpp +6 -0
  91. package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +3 -0
  92. package/src/duckdb/src/include/duckdb/planner/expression/bound_comparison_expression.hpp +3 -0
  93. package/src/duckdb/src/include/duckdb/planner/expression/bound_conjunction_expression.hpp +3 -0
  94. package/src/duckdb/src/include/duckdb/planner/expression/bound_constant_expression.hpp +3 -0
  95. package/src/duckdb/src/include/duckdb/planner/expression/bound_default_expression.hpp +3 -0
  96. package/src/duckdb/src/include/duckdb/planner/expression/bound_lambda_expression.hpp +3 -1
  97. package/src/duckdb/src/include/duckdb/planner/expression/bound_lambdaref_expression.hpp +3 -0
  98. package/src/duckdb/src/include/duckdb/planner/expression/bound_operator_expression.hpp +3 -0
  99. package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_data.hpp +5 -2
  100. package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_expression.hpp +7 -0
  101. package/src/duckdb/src/include/duckdb/planner/expression/bound_reference_expression.hpp +3 -0
  102. package/src/duckdb/src/include/duckdb/planner/expression/bound_unnest_expression.hpp +3 -0
  103. package/src/duckdb/src/include/duckdb/planner/expression/list.hpp +1 -0
  104. package/src/duckdb/src/include/duckdb/planner/expression.hpp +3 -0
  105. package/src/duckdb/src/include/duckdb/planner/joinside.hpp +3 -0
  106. package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +3 -0
  107. package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +3 -0
  108. package/src/duckdb/src/include/duckdb/planner/operator/logical_any_join.hpp +3 -0
  109. package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +4 -0
  110. package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +9 -2
  111. package/src/duckdb/src/include/duckdb/planner/operator/logical_create.hpp +9 -6
  112. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_index.hpp +2 -16
  113. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_table.hpp +10 -6
  114. package/src/duckdb/src/include/duckdb/planner/operator/logical_cross_product.hpp +3 -0
  115. package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +2 -0
  116. package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +7 -0
  117. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +3 -0
  118. package/src/duckdb/src/include/duckdb/planner/operator/logical_distinct.hpp +6 -10
  119. package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +2 -0
  120. package/src/duckdb/src/include/duckdb/planner/operator/logical_empty_result.hpp +2 -0
  121. package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +4 -0
  122. package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +3 -0
  123. package/src/duckdb/src/include/duckdb/planner/operator/logical_filter.hpp +3 -0
  124. package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +6 -0
  125. package/src/duckdb/src/include/duckdb/planner/operator/logical_limit.hpp +3 -0
  126. package/src/duckdb/src/include/duckdb/planner/operator/logical_limit_percent.hpp +3 -0
  127. package/src/duckdb/src/include/duckdb/planner/operator/logical_materialized_cte.hpp +5 -2
  128. package/src/duckdb/src/include/duckdb/planner/operator/logical_order.hpp +7 -35
  129. package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +6 -0
  130. package/src/duckdb/src/include/duckdb/planner/operator/logical_positional_join.hpp +3 -0
  131. package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +3 -0
  132. package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +5 -3
  133. package/src/duckdb/src/include/duckdb/planner/operator/logical_reset.hpp +4 -0
  134. package/src/duckdb/src/include/duckdb/planner/operator/logical_sample.hpp +6 -0
  135. package/src/duckdb/src/include/duckdb/planner/operator/logical_set.hpp +4 -0
  136. package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +4 -0
  137. package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +3 -0
  138. package/src/duckdb/src/include/duckdb/planner/operator/logical_simple.hpp +3 -0
  139. package/src/duckdb/src/include/duckdb/planner/operator/logical_top_n.hpp +4 -0
  140. package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +2 -0
  141. package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +6 -0
  142. package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +3 -0
  143. package/src/duckdb/src/include/duckdb/planner/tableref/bound_pivotref.hpp +3 -0
  144. package/src/duckdb/src/optimizer/deliminator.cpp +5 -3
  145. package/src/duckdb/src/parser/column_definition.cpp +20 -32
  146. package/src/duckdb/src/parser/column_list.cpp +8 -0
  147. package/src/duckdb/src/parser/constraints/foreign_key_constraint.cpp +3 -0
  148. package/src/duckdb/src/parser/constraints/unique_constraint.cpp +3 -0
  149. package/src/duckdb/src/parser/expression/case_expression.cpp +0 -12
  150. package/src/duckdb/src/parser/parsed_data/alter_info.cpp +5 -2
  151. package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +38 -0
  152. package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +3 -1
  153. package/src/duckdb/src/parser/parsed_data/create_sequence_info.cpp +2 -0
  154. package/src/duckdb/src/parser/parsed_data/detach_info.cpp +1 -1
  155. package/src/duckdb/src/parser/parsed_data/drop_info.cpp +1 -1
  156. package/src/duckdb/src/parser/parsed_data/sample_options.cpp +0 -18
  157. package/src/duckdb/src/parser/parsed_data/transaction_info.cpp +4 -1
  158. package/src/duckdb/src/parser/parsed_data/vacuum_info.cpp +1 -1
  159. package/src/duckdb/src/parser/query_node.cpp +0 -10
  160. package/src/duckdb/src/parser/result_modifier.cpp +0 -13
  161. package/src/duckdb/src/parser/statement/select_statement.cpp +0 -10
  162. package/src/duckdb/src/parser/tableref/pivotref.cpp +0 -16
  163. package/src/duckdb/src/parser/transform/statement/transform_create_index.cpp +5 -4
  164. package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +1 -1
  165. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +6 -1
  166. package/src/duckdb/src/planner/expression/bound_between_expression.cpp +4 -0
  167. package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +13 -6
  168. package/src/duckdb/src/planner/expression/bound_parameter_expression.cpp +20 -12
  169. package/src/duckdb/src/planner/logical_operator.cpp +13 -1
  170. package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +16 -2
  171. package/src/duckdb/src/planner/operator/logical_create.cpp +14 -0
  172. package/src/duckdb/src/planner/operator/logical_create_index.cpp +20 -0
  173. package/src/duckdb/src/planner/operator/logical_create_table.cpp +16 -0
  174. package/src/duckdb/src/planner/operator/logical_delete.cpp +9 -2
  175. package/src/duckdb/src/planner/operator/logical_delim_join.cpp +2 -4
  176. package/src/duckdb/src/planner/operator/logical_distinct.cpp +13 -0
  177. package/src/duckdb/src/planner/operator/logical_explain.cpp +1 -1
  178. package/src/duckdb/src/planner/operator/logical_insert.cpp +8 -2
  179. package/src/duckdb/src/planner/operator/logical_materialized_cte.cpp +3 -2
  180. package/src/duckdb/src/planner/operator/logical_order.cpp +39 -0
  181. package/src/duckdb/src/planner/operator/logical_pivot.cpp +3 -0
  182. package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +5 -5
  183. package/src/duckdb/src/planner/operator/logical_sample.cpp +3 -0
  184. package/src/duckdb/src/planner/operator/logical_update.cpp +8 -2
  185. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +4 -2
  186. package/src/duckdb/src/planner/planner.cpp +11 -0
  187. package/src/duckdb/src/storage/checkpoint_manager.cpp +23 -23
  188. package/src/duckdb/src/storage/serialization/serialize_constraint.cpp +98 -0
  189. package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +188 -0
  190. package/src/duckdb/src/storage/serialization/serialize_expression.cpp +274 -0
  191. package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +729 -0
  192. package/src/duckdb/src/storage/serialization/serialize_macro_function.cpp +62 -0
  193. package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +242 -0
  194. package/src/duckdb/src/storage/serialization/serialize_parse_info.cpp +419 -0
  195. package/src/duckdb/src/storage/serialization/serialize_parsed_expression.cpp +40 -38
  196. package/src/duckdb/src/storage/serialization/serialize_query_node.cpp +36 -36
  197. package/src/duckdb/src/storage/serialization/serialize_result_modifier.cpp +25 -14
  198. package/src/duckdb/src/storage/serialization/serialize_statement.cpp +22 -0
  199. package/src/duckdb/src/storage/serialization/serialize_tableref.cpp +47 -47
  200. package/src/duckdb/src/storage/serialization/serialize_types.cpp +25 -25
  201. package/src/duckdb/src/storage/storage_info.cpp +3 -2
  202. package/src/duckdb/src/storage/wal_replay.cpp +20 -19
  203. package/src/duckdb/ub_src_parser.cpp +0 -2
  204. package/src/duckdb/ub_src_storage_serialization.cpp +16 -0
  205. package/src/duckdb/src/parser/common_table_expression_info.cpp +0 -21
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.8.2-dev1968.0",
5
+ "version": "0.8.2-dev2044.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -278,7 +278,7 @@ optional_ptr<CatalogEntry> Catalog::CreateIndex(CatalogTransaction transaction,
278
278
 
279
279
  optional_ptr<CatalogEntry> Catalog::CreateIndex(ClientContext &context, CreateIndexInfo &info) {
280
280
  auto &schema = GetSchema(context, info.schema);
281
- auto &table = GetEntry<TableCatalogEntry>(context, schema.name, info.table->table_name);
281
+ auto &table = GetEntry<TableCatalogEntry>(context, schema.name, info.table);
282
282
  return schema.CreateIndex(context, info, table);
283
283
  }
284
284
 
@@ -19,47 +19,23 @@ string IndexCatalogEntry::ToSQL() const {
19
19
  return sql;
20
20
  }
21
21
 
22
- void IndexCatalogEntry::Serialize(Serializer &serializer) const {
23
- // here we serialize the index metadata in the following order:
24
- // schema name, table name, index name, sql, index type, index constraint type, expression list, parsed expressions,
25
- // column IDs
26
-
27
- FieldWriter writer(serializer);
28
- writer.WriteString(GetSchemaName());
29
- writer.WriteString(GetTableName());
30
- writer.WriteString(name);
31
- writer.WriteString(sql);
32
- writer.WriteField(index->type);
33
- writer.WriteField(index->constraint_type);
34
- writer.WriteSerializableList(expressions);
35
- writer.WriteSerializableList(parsed_expressions);
36
- writer.WriteList<idx_t>(index->column_ids);
37
- writer.Finalize();
38
- }
39
-
40
- unique_ptr<CreateIndexInfo> IndexCatalogEntry::Deserialize(Deserializer &source, ClientContext &context) {
41
- // here we deserialize the index metadata in the following order:
42
- // schema name, table schema name, table name, index name, sql, index type, index constraint type, expression list,
43
- // parsed expression list, column IDs
44
-
45
- auto create_index_info = make_uniq<CreateIndexInfo>();
46
-
47
- FieldReader reader(source);
48
-
49
- create_index_info->schema = reader.ReadRequired<string>();
50
- create_index_info->table = make_uniq<BaseTableRef>();
51
- create_index_info->table->schema_name = create_index_info->schema;
52
- create_index_info->table->table_name = reader.ReadRequired<string>();
53
- create_index_info->index_name = reader.ReadRequired<string>();
54
- create_index_info->sql = reader.ReadRequired<string>();
55
- create_index_info->index_type = IndexType(reader.ReadRequired<uint8_t>());
56
- create_index_info->constraint_type = IndexConstraintType(reader.ReadRequired<uint8_t>());
57
- create_index_info->expressions = reader.ReadRequiredSerializableList<ParsedExpression>();
58
- create_index_info->parsed_expressions = reader.ReadRequiredSerializableList<ParsedExpression>();
59
-
60
- create_index_info->column_ids = reader.ReadRequiredList<idx_t>();
61
- reader.Finalize();
62
- return create_index_info;
22
+ unique_ptr<CreateInfo> IndexCatalogEntry::GetInfo() const {
23
+ auto result = make_uniq<CreateIndexInfo>();
24
+ result->schema = GetSchemaName();
25
+ result->table = GetTableName();
26
+ result->index_name = name;
27
+ result->sql = sql;
28
+ result->index_type = index->type;
29
+ result->constraint_type = index->constraint_type;
30
+ for (auto &expr : expressions) {
31
+ result->expressions.push_back(expr->Copy());
32
+ }
33
+ for (auto &expr : parsed_expressions) {
34
+ result->parsed_expressions.push_back(expr->Copy());
35
+ }
36
+ result->column_ids = index->column_ids;
37
+ result->temporary = temporary;
38
+ return std::move(result);
63
39
  }
64
40
 
65
41
  } // namespace duckdb
@@ -22,21 +22,13 @@ TableMacroCatalogEntry::TableMacroCatalogEntry(Catalog &catalog, SchemaCatalogEn
22
22
  : MacroCatalogEntry(catalog, schema, info) {
23
23
  }
24
24
 
25
- unique_ptr<CreateMacroInfo> MacroCatalogEntry::GetInfoForSerialization() const {
25
+ unique_ptr<CreateInfo> MacroCatalogEntry::GetInfo() const {
26
26
  auto info = make_uniq<CreateMacroInfo>(type);
27
27
  info->catalog = catalog.GetName();
28
28
  info->schema = schema.name;
29
29
  info->name = name;
30
30
  info->function = function->Copy();
31
- return info;
32
- }
33
- void MacroCatalogEntry::Serialize(Serializer &serializer) const {
34
- auto info = GetInfoForSerialization();
35
- info->Serialize(serializer);
36
- }
37
-
38
- unique_ptr<CreateMacroInfo> MacroCatalogEntry::Deserialize(Deserializer &main_source, ClientContext &context) {
39
- return unique_ptr_cast<CreateInfo, CreateMacroInfo>(CreateInfo::Deserialize(main_source));
31
+ return std::move(info);
40
32
  }
41
33
 
42
34
  } // namespace duckdb
@@ -33,20 +33,10 @@ SimilarCatalogEntry SchemaCatalogEntry::GetSimilarEntry(CatalogTransaction trans
33
33
  return result;
34
34
  }
35
35
 
36
- void SchemaCatalogEntry::Serialize(Serializer &serializer) const {
37
- FieldWriter writer(serializer);
38
- writer.WriteString(name);
39
- writer.Finalize();
40
- }
41
-
42
- unique_ptr<CreateSchemaInfo> SchemaCatalogEntry::Deserialize(Deserializer &source) {
43
- auto info = make_uniq<CreateSchemaInfo>();
44
-
45
- FieldReader reader(source);
46
- info->schema = reader.ReadRequired<string>();
47
- reader.Finalize();
48
-
49
- return info;
36
+ unique_ptr<CreateInfo> SchemaCatalogEntry::GetInfo() const {
37
+ auto result = make_uniq<CreateSchemaInfo>();
38
+ result->schema = name;
39
+ return std::move(result);
50
40
  }
51
41
 
52
42
  string SchemaCatalogEntry::ToSQL() const {
@@ -18,34 +18,17 @@ SequenceCatalogEntry::SequenceCatalogEntry(Catalog &catalog, SchemaCatalogEntry
18
18
  this->temporary = info.temporary;
19
19
  }
20
20
 
21
- void SequenceCatalogEntry::Serialize(Serializer &serializer) const {
22
- FieldWriter writer(serializer);
23
- writer.WriteString(schema.name);
24
- writer.WriteString(name);
25
- writer.WriteField<uint64_t>(usage_count);
26
- writer.WriteField<int64_t>(increment);
27
- writer.WriteField<int64_t>(min_value);
28
- writer.WriteField<int64_t>(max_value);
29
- writer.WriteField<int64_t>(counter);
30
- writer.WriteField<bool>(cycle);
31
- writer.Finalize();
32
- }
33
-
34
- unique_ptr<CreateSequenceInfo> SequenceCatalogEntry::Deserialize(Deserializer &source) {
35
- auto info = make_uniq<CreateSequenceInfo>();
36
-
37
- FieldReader reader(source);
38
- info->schema = reader.ReadRequired<string>();
39
- info->name = reader.ReadRequired<string>();
40
- info->usage_count = reader.ReadRequired<uint64_t>();
41
- info->increment = reader.ReadRequired<int64_t>();
42
- info->min_value = reader.ReadRequired<int64_t>();
43
- info->max_value = reader.ReadRequired<int64_t>();
44
- info->start_value = reader.ReadRequired<int64_t>();
45
- info->cycle = reader.ReadRequired<bool>();
46
- reader.Finalize();
47
-
48
- return info;
21
+ unique_ptr<CreateInfo> SequenceCatalogEntry::GetInfo() const {
22
+ auto result = make_uniq<CreateSequenceInfo>();
23
+ result->schema = schema.name;
24
+ result->name = name;
25
+ result->usage_count = usage_count;
26
+ result->increment = increment;
27
+ result->min_value = min_value;
28
+ result->max_value = max_value;
29
+ result->start_value = counter;
30
+ result->cycle = cycle;
31
+ return std::move(result);
49
32
  }
50
33
 
51
34
  string SequenceCatalogEntry::ToSQL() const {
@@ -56,42 +56,16 @@ vector<LogicalType> TableCatalogEntry::GetTypes() {
56
56
  return types;
57
57
  }
58
58
 
59
- CreateTableInfo TableCatalogEntry::GetTableInfoForSerialization() const {
60
- CreateTableInfo result;
61
- result.catalog = catalog.GetName();
62
- result.schema = schema.name;
63
- result.table = name;
64
- result.columns = columns.Copy();
65
- result.constraints.reserve(constraints.size());
59
+ unique_ptr<CreateInfo> TableCatalogEntry::GetInfo() const {
60
+ auto result = make_uniq<CreateTableInfo>();
61
+ result->catalog = catalog.GetName();
62
+ result->schema = schema.name;
63
+ result->table = name;
64
+ result->columns = columns.Copy();
65
+ result->constraints.reserve(constraints.size());
66
66
  std::for_each(constraints.begin(), constraints.end(),
67
- [&result](const unique_ptr<Constraint> &c) { result.constraints.emplace_back(c->Copy()); });
68
- return result;
69
- }
70
-
71
- void TableCatalogEntry::Serialize(Serializer &serializer) const {
72
- D_ASSERT(!internal);
73
- const auto info = GetTableInfoForSerialization();
74
- FieldWriter writer(serializer);
75
- writer.WriteString(info.catalog);
76
- writer.WriteString(info.schema);
77
- writer.WriteString(info.table);
78
- info.columns.Serialize(writer);
79
- writer.WriteSerializableList(info.constraints);
80
- writer.Finalize();
81
- }
82
-
83
- unique_ptr<CreateTableInfo> TableCatalogEntry::Deserialize(Deserializer &source, ClientContext &context) {
84
- auto info = make_uniq<CreateTableInfo>();
85
-
86
- FieldReader reader(source);
87
- info->catalog = reader.ReadRequired<string>();
88
- info->schema = reader.ReadRequired<string>();
89
- info->table = reader.ReadRequired<string>();
90
- info->columns = ColumnList::Deserialize(reader);
91
- info->constraints = reader.ReadRequiredSerializableList<Constraint>();
92
- reader.Finalize();
93
-
94
- return info;
67
+ [&result](const unique_ptr<Constraint> &c) { result->constraints.emplace_back(c->Copy()); });
68
+ return std::move(result);
95
69
  }
96
70
 
97
71
  string TableCatalogEntry::ColumnsToSQL(const ColumnList &columns, const vector<unique_ptr<Constraint>> &constraints) {
@@ -162,11 +136,10 @@ string TableCatalogEntry::ColumnsToSQL(const ColumnList &columns, const vector<u
162
136
  // single column unique: insert constraint here
163
137
  ss << " UNIQUE";
164
138
  }
165
- if (column.DefaultValue()) {
166
- ss << " DEFAULT(" << column.DefaultValue()->ToString() << ")";
167
- }
168
139
  if (column.Generated()) {
169
140
  ss << " GENERATED ALWAYS AS(" << column.GeneratedExpression().ToString() << ")";
141
+ } else if (column.DefaultValue()) {
142
+ ss << " DEFAULT(" << column.DefaultValue()->ToString() << ")";
170
143
  }
171
144
  }
172
145
  // print any extra constraints that still need to be printed
@@ -25,6 +25,17 @@ ViewCatalogEntry::ViewCatalogEntry(Catalog &catalog, SchemaCatalogEntry &schema,
25
25
  Initialize(info);
26
26
  }
27
27
 
28
+ unique_ptr<CreateInfo> ViewCatalogEntry::GetInfo() const {
29
+ auto result = make_uniq<CreateViewInfo>();
30
+ result->schema = schema.name;
31
+ result->view_name = name;
32
+ result->sql = sql;
33
+ result->query = unique_ptr_cast<SQLStatement, SelectStatement>(query->Copy());
34
+ result->aliases = aliases;
35
+ result->types = types;
36
+ return std::move(result);
37
+ }
38
+
28
39
  unique_ptr<CatalogEntry> ViewCatalogEntry::AlterEntry(ClientContext &context, AlterInfo &info) {
29
40
  D_ASSERT(!internal);
30
41
  if (info.type != AlterType::ALTER_VIEW) {
@@ -43,33 +54,6 @@ unique_ptr<CatalogEntry> ViewCatalogEntry::AlterEntry(ClientContext &context, Al
43
54
  }
44
55
  }
45
56
 
46
- void ViewCatalogEntry::Serialize(Serializer &serializer) const {
47
- D_ASSERT(!internal);
48
- FieldWriter writer(serializer);
49
- writer.WriteString(schema.name);
50
- writer.WriteString(name);
51
- writer.WriteString(sql);
52
- writer.WriteSerializable(*query);
53
- writer.WriteList<string>(aliases);
54
- writer.WriteRegularSerializableList<LogicalType>(types);
55
- writer.Finalize();
56
- }
57
-
58
- unique_ptr<CreateViewInfo> ViewCatalogEntry::Deserialize(Deserializer &source, ClientContext &context) {
59
- auto info = make_uniq<CreateViewInfo>();
60
-
61
- FieldReader reader(source);
62
- info->schema = reader.ReadRequired<string>();
63
- info->view_name = reader.ReadRequired<string>();
64
- info->sql = reader.ReadRequired<string>();
65
- info->query = reader.ReadRequiredSerializable<SelectStatement>();
66
- info->aliases = reader.ReadRequiredList<string>();
67
- info->types = reader.ReadRequiredSerializableList<LogicalType, LogicalType>();
68
- reader.Finalize();
69
-
70
- return info;
71
- }
72
-
73
57
  string ViewCatalogEntry::ToSQL() const {
74
58
  if (sql.empty()) {
75
59
  //! Return empty sql with view name so pragma view_tables don't complain
@@ -1,6 +1,8 @@
1
1
  #include "duckdb/catalog/catalog_entry.hpp"
2
-
2
+ #include "duckdb/parser/parsed_data/create_info.hpp"
3
3
  #include "duckdb/catalog/catalog.hpp"
4
+ #include "duckdb/common/serializer/binary_serializer.hpp"
5
+ #include "duckdb/common/serializer/binary_deserializer.hpp"
4
6
 
5
7
  namespace duckdb {
6
8
 
@@ -31,6 +33,10 @@ unique_ptr<CatalogEntry> CatalogEntry::Copy(ClientContext &context) const {
31
33
  throw InternalException("Unsupported copy type for catalog entry!");
32
34
  }
33
35
 
36
+ unique_ptr<CreateInfo> CatalogEntry::GetInfo() const {
37
+ throw InternalException("Unsupported type for CatalogEntry::GetInfo!");
38
+ }
39
+
34
40
  string CatalogEntry::ToSQL() const {
35
41
  throw InternalException("Unsupported catalog type for ToSQL()");
36
42
  }
@@ -44,6 +50,24 @@ SchemaCatalogEntry &CatalogEntry::ParentSchema() {
44
50
  }
45
51
  // LCOV_EXCL_STOP
46
52
 
53
+ void CatalogEntry::Serialize(Serializer &serializer) const {
54
+ const auto info = GetInfo();
55
+ info->Serialize(serializer);
56
+ }
57
+
58
+ unique_ptr<CreateInfo> CatalogEntry::Deserialize(Deserializer &source) {
59
+ return CreateInfo::Deserialize(source);
60
+ }
61
+
62
+ void CatalogEntry::FormatSerialize(FormatSerializer &serializer) const {
63
+ const auto info = GetInfo();
64
+ info->FormatSerialize(serializer);
65
+ }
66
+
67
+ unique_ptr<CreateInfo> CatalogEntry::FormatDeserialize(FormatDeserializer &deserializer) {
68
+ return CreateInfo::FormatDeserialize(deserializer);
69
+ }
70
+
47
71
  void CatalogEntry::Verify(Catalog &catalog_p) {
48
72
  }
49
73
 
@@ -88,6 +88,8 @@
88
88
  #include "duckdb/parser/parsed_data/alter_table_info.hpp"
89
89
  #include "duckdb/parser/parsed_data/create_info.hpp"
90
90
  #include "duckdb/parser/parsed_data/create_sequence_info.hpp"
91
+ #include "duckdb/parser/parsed_data/load_info.hpp"
92
+ #include "duckdb/parser/parsed_data/parse_info.hpp"
91
93
  #include "duckdb/parser/parsed_data/pragma_info.hpp"
92
94
  #include "duckdb/parser/parsed_data/sample_options.hpp"
93
95
  #include "duckdb/parser/parsed_data/transaction_info.hpp"
@@ -217,6 +219,29 @@ AggregateType EnumUtil::FromString<AggregateType>(const char *value) {
217
219
  throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
218
220
  }
219
221
 
222
+ template<>
223
+ const char* EnumUtil::ToChars<AlterForeignKeyType>(AlterForeignKeyType value) {
224
+ switch(value) {
225
+ case AlterForeignKeyType::AFT_ADD:
226
+ return "AFT_ADD";
227
+ case AlterForeignKeyType::AFT_DELETE:
228
+ return "AFT_DELETE";
229
+ default:
230
+ throw NotImplementedException(StringUtil::Format("Enum value: '%d' not implemented", value));
231
+ }
232
+ }
233
+
234
+ template<>
235
+ AlterForeignKeyType EnumUtil::FromString<AlterForeignKeyType>(const char *value) {
236
+ if (StringUtil::Equals(value, "AFT_ADD")) {
237
+ return AlterForeignKeyType::AFT_ADD;
238
+ }
239
+ if (StringUtil::Equals(value, "AFT_DELETE")) {
240
+ return AlterForeignKeyType::AFT_DELETE;
241
+ }
242
+ throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
243
+ }
244
+
220
245
  template<>
221
246
  const char* EnumUtil::ToChars<AlterScalarFunctionType>(AlterScalarFunctionType value) {
222
247
  switch(value) {
@@ -2274,6 +2299,39 @@ FunctionSideEffects EnumUtil::FromString<FunctionSideEffects>(const char *value)
2274
2299
  throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
2275
2300
  }
2276
2301
 
2302
+ template<>
2303
+ const char* EnumUtil::ToChars<IndexConstraintType>(IndexConstraintType value) {
2304
+ switch(value) {
2305
+ case IndexConstraintType::NONE:
2306
+ return "NONE";
2307
+ case IndexConstraintType::UNIQUE:
2308
+ return "UNIQUE";
2309
+ case IndexConstraintType::PRIMARY:
2310
+ return "PRIMARY";
2311
+ case IndexConstraintType::FOREIGN:
2312
+ return "FOREIGN";
2313
+ default:
2314
+ throw NotImplementedException(StringUtil::Format("Enum value: '%d' not implemented", value));
2315
+ }
2316
+ }
2317
+
2318
+ template<>
2319
+ IndexConstraintType EnumUtil::FromString<IndexConstraintType>(const char *value) {
2320
+ if (StringUtil::Equals(value, "NONE")) {
2321
+ return IndexConstraintType::NONE;
2322
+ }
2323
+ if (StringUtil::Equals(value, "UNIQUE")) {
2324
+ return IndexConstraintType::UNIQUE;
2325
+ }
2326
+ if (StringUtil::Equals(value, "PRIMARY")) {
2327
+ return IndexConstraintType::PRIMARY;
2328
+ }
2329
+ if (StringUtil::Equals(value, "FOREIGN")) {
2330
+ return IndexConstraintType::FOREIGN;
2331
+ }
2332
+ throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
2333
+ }
2334
+
2277
2335
  template<>
2278
2336
  const char* EnumUtil::ToChars<IndexType>(IndexType value) {
2279
2337
  switch(value) {
@@ -2482,6 +2540,34 @@ KeywordCategory EnumUtil::FromString<KeywordCategory>(const char *value) {
2482
2540
  throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
2483
2541
  }
2484
2542
 
2543
+ template<>
2544
+ const char* EnumUtil::ToChars<LoadType>(LoadType value) {
2545
+ switch(value) {
2546
+ case LoadType::LOAD:
2547
+ return "LOAD";
2548
+ case LoadType::INSTALL:
2549
+ return "INSTALL";
2550
+ case LoadType::FORCE_INSTALL:
2551
+ return "FORCE_INSTALL";
2552
+ default:
2553
+ throw NotImplementedException(StringUtil::Format("Enum value: '%d' not implemented", value));
2554
+ }
2555
+ }
2556
+
2557
+ template<>
2558
+ LoadType EnumUtil::FromString<LoadType>(const char *value) {
2559
+ if (StringUtil::Equals(value, "LOAD")) {
2560
+ return LoadType::LOAD;
2561
+ }
2562
+ if (StringUtil::Equals(value, "INSTALL")) {
2563
+ return LoadType::INSTALL;
2564
+ }
2565
+ if (StringUtil::Equals(value, "FORCE_INSTALL")) {
2566
+ return LoadType::FORCE_INSTALL;
2567
+ }
2568
+ throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
2569
+ }
2570
+
2485
2571
  template<>
2486
2572
  const char* EnumUtil::ToChars<LogicalOperatorType>(LogicalOperatorType value) {
2487
2573
  switch(value) {
@@ -3558,6 +3644,79 @@ OutputStream EnumUtil::FromString<OutputStream>(const char *value) {
3558
3644
  throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
3559
3645
  }
3560
3646
 
3647
+ template<>
3648
+ const char* EnumUtil::ToChars<ParseInfoType>(ParseInfoType value) {
3649
+ switch(value) {
3650
+ case ParseInfoType::ALTER_INFO:
3651
+ return "ALTER_INFO";
3652
+ case ParseInfoType::ATTACH_INFO:
3653
+ return "ATTACH_INFO";
3654
+ case ParseInfoType::COPY_INFO:
3655
+ return "COPY_INFO";
3656
+ case ParseInfoType::CREATE_INFO:
3657
+ return "CREATE_INFO";
3658
+ case ParseInfoType::DETACH_INFO:
3659
+ return "DETACH_INFO";
3660
+ case ParseInfoType::DROP_INFO:
3661
+ return "DROP_INFO";
3662
+ case ParseInfoType::BOUND_EXPORT_DATA:
3663
+ return "BOUND_EXPORT_DATA";
3664
+ case ParseInfoType::LOAD_INFO:
3665
+ return "LOAD_INFO";
3666
+ case ParseInfoType::PRAGMA_INFO:
3667
+ return "PRAGMA_INFO";
3668
+ case ParseInfoType::SHOW_SELECT_INFO:
3669
+ return "SHOW_SELECT_INFO";
3670
+ case ParseInfoType::TRANSACTION_INFO:
3671
+ return "TRANSACTION_INFO";
3672
+ case ParseInfoType::VACUUM_INFO:
3673
+ return "VACUUM_INFO";
3674
+ default:
3675
+ throw NotImplementedException(StringUtil::Format("Enum value: '%d' not implemented", value));
3676
+ }
3677
+ }
3678
+
3679
+ template<>
3680
+ ParseInfoType EnumUtil::FromString<ParseInfoType>(const char *value) {
3681
+ if (StringUtil::Equals(value, "ALTER_INFO")) {
3682
+ return ParseInfoType::ALTER_INFO;
3683
+ }
3684
+ if (StringUtil::Equals(value, "ATTACH_INFO")) {
3685
+ return ParseInfoType::ATTACH_INFO;
3686
+ }
3687
+ if (StringUtil::Equals(value, "COPY_INFO")) {
3688
+ return ParseInfoType::COPY_INFO;
3689
+ }
3690
+ if (StringUtil::Equals(value, "CREATE_INFO")) {
3691
+ return ParseInfoType::CREATE_INFO;
3692
+ }
3693
+ if (StringUtil::Equals(value, "DETACH_INFO")) {
3694
+ return ParseInfoType::DETACH_INFO;
3695
+ }
3696
+ if (StringUtil::Equals(value, "DROP_INFO")) {
3697
+ return ParseInfoType::DROP_INFO;
3698
+ }
3699
+ if (StringUtil::Equals(value, "BOUND_EXPORT_DATA")) {
3700
+ return ParseInfoType::BOUND_EXPORT_DATA;
3701
+ }
3702
+ if (StringUtil::Equals(value, "LOAD_INFO")) {
3703
+ return ParseInfoType::LOAD_INFO;
3704
+ }
3705
+ if (StringUtil::Equals(value, "PRAGMA_INFO")) {
3706
+ return ParseInfoType::PRAGMA_INFO;
3707
+ }
3708
+ if (StringUtil::Equals(value, "SHOW_SELECT_INFO")) {
3709
+ return ParseInfoType::SHOW_SELECT_INFO;
3710
+ }
3711
+ if (StringUtil::Equals(value, "TRANSACTION_INFO")) {
3712
+ return ParseInfoType::TRANSACTION_INFO;
3713
+ }
3714
+ if (StringUtil::Equals(value, "VACUUM_INFO")) {
3715
+ return ParseInfoType::VACUUM_INFO;
3716
+ }
3717
+ throw NotImplementedException(StringUtil::Format("Enum value: '%s' not implemented", value));
3718
+ }
3719
+
3561
3720
  template<>
3562
3721
  const char* EnumUtil::ToChars<ParserExtensionResultType>(ParserExtensionResultType value) {
3563
3722
  switch(value) {
@@ -321,7 +321,6 @@ struct EnumTypeInfoTemplated : public EnumTypeInfo {
321
321
  }
322
322
 
323
323
  static shared_ptr<EnumTypeInfoTemplated> Deserialize(FieldReader &reader, uint32_t size, string enum_name) {
324
-
325
324
  Vector values_insert_order(LogicalType::VARCHAR, size);
326
325
  values_insert_order.Deserialize(size, reader.GetSource());
327
326
  return make_shared<EnumTypeInfoTemplated>(std::move(enum_name), values_insert_order, size);
@@ -451,7 +450,7 @@ shared_ptr<ExtraTypeInfo> EnumTypeInfo::Deserialize(FieldReader &reader) {
451
450
  }
452
451
 
453
452
  shared_ptr<ExtraTypeInfo> EnumTypeInfo::FormatDeserialize(FormatDeserializer &deserializer) {
454
- auto enum_size = deserializer.ReadProperty<uint32_t>("enum_size");
453
+ auto enum_size = deserializer.ReadProperty<idx_t>("enum_size");
455
454
  auto enum_internal_type = EnumTypeInfo::DictType(enum_size);
456
455
  switch (enum_internal_type) {
457
456
  case PhysicalType::UINT8:
@@ -5,6 +5,9 @@ namespace duckdb {
5
5
  void BinaryDeserializer::SetTag(const char *tag) {
6
6
  current_tag = tag;
7
7
  stack.back().read_field_count++;
8
+ if (stack.back().read_field_count > stack.back().expected_field_count) {
9
+ throw SerializationException("Attempting to read a required field, but field is missing");
10
+ }
8
11
  }
9
12
 
10
13
  //===--------------------------------------------------------------------===//
@@ -129,7 +129,7 @@ void BinarySerializer::WriteValue(const string &value) {
129
129
  auto len = value.length();
130
130
  Write<uint32_t>((uint32_t)len);
131
131
  if (len > 0) {
132
- WriteData(value.c_str(), len);
132
+ WriteDataInternal(value.c_str(), len);
133
133
  }
134
134
  }
135
135
 
@@ -137,7 +137,7 @@ void BinarySerializer::WriteValue(const string_t value) {
137
137
  auto len = value.GetSize();
138
138
  Write<uint32_t>((uint32_t)len);
139
139
  if (len > 0) {
140
- WriteData(value.GetDataUnsafe(), len);
140
+ WriteDataInternal(value.GetDataUnsafe(), len);
141
141
  }
142
142
  }
143
143
 
@@ -145,7 +145,7 @@ void BinarySerializer::WriteValue(const char *value) {
145
145
  auto len = strlen(value);
146
146
  Write<uint32_t>((uint32_t)len);
147
147
  if (len > 0) {
148
- WriteData(value, len);
148
+ WriteDataInternal(value, len);
149
149
  }
150
150
  }
151
151
 
@@ -154,7 +154,7 @@ void BinarySerializer::WriteValue(bool value) {
154
154
  }
155
155
 
156
156
  void BinarySerializer::WriteDataPtr(const_data_ptr_t ptr, idx_t count) {
157
- WriteData(ptr, count);
157
+ WriteDataInternal(ptr, count);
158
158
  }
159
159
 
160
160
  } // namespace duckdb
@@ -6,6 +6,8 @@
6
6
  #include "duckdb/common/types/value_map.hpp"
7
7
  #include "duckdb/common/vector_operations/vector_operations.hpp"
8
8
  #include "duckdb/storage/buffer_manager.hpp"
9
+ #include "duckdb/common/serializer/format_serializer.hpp"
10
+ #include "duckdb/common/serializer/format_deserializer.hpp"
9
11
 
10
12
  namespace duckdb {
11
13
 
@@ -1057,4 +1059,45 @@ const vector<unique_ptr<ColumnDataCollectionSegment>> &ColumnDataCollection::Get
1057
1059
  return segments;
1058
1060
  }
1059
1061
 
1062
+ void ColumnDataCollection::FormatSerialize(FormatSerializer &serializer) const {
1063
+ vector<vector<Value>> values;
1064
+ values.resize(ColumnCount());
1065
+ for (auto &chunk : Chunks()) {
1066
+ for (idx_t c = 0; c < chunk.ColumnCount(); c++) {
1067
+ for (idx_t r = 0; r < chunk.size(); r++) {
1068
+ values[c].push_back(chunk.GetValue(c, r));
1069
+ }
1070
+ }
1071
+ }
1072
+ serializer.WriteProperty("types", types);
1073
+ serializer.WriteProperty("values", values);
1074
+ }
1075
+
1076
+ unique_ptr<ColumnDataCollection> ColumnDataCollection::FormatDeserialize(FormatDeserializer &deserializer) {
1077
+ auto types = deserializer.ReadProperty<vector<LogicalType>>("types");
1078
+ auto values = deserializer.ReadProperty<vector<vector<Value>>>("values");
1079
+
1080
+ auto collection = make_uniq<ColumnDataCollection>(Allocator::DefaultAllocator(), types);
1081
+ if (values.empty()) {
1082
+ return collection;
1083
+ }
1084
+ DataChunk chunk;
1085
+ chunk.Initialize(Allocator::DefaultAllocator(), types);
1086
+
1087
+ for (idx_t r = 0; r < values[0].size(); r++) {
1088
+ for (idx_t c = 0; c < types.size(); c++) {
1089
+ chunk.SetValue(c, chunk.size(), values[c][r]);
1090
+ }
1091
+ chunk.SetCardinality(chunk.size() + 1);
1092
+ if (chunk.size() == STANDARD_VECTOR_SIZE) {
1093
+ collection->Append(chunk);
1094
+ chunk.Reset();
1095
+ }
1096
+ }
1097
+ if (chunk.size() > 0) {
1098
+ collection->Append(chunk);
1099
+ }
1100
+ return collection;
1101
+ }
1102
+
1060
1103
  } // namespace duckdb
@@ -977,7 +977,7 @@ void Vector::FormatSerialize(FormatSerializer &serializer, idx_t count) {
977
977
  UnifiedVectorFormat vdata;
978
978
  ToUnifiedFormat(count, vdata);
979
979
 
980
- const auto all_valid = (count > 0) && !vdata.validity.AllValid();
980
+ const bool all_valid = (count > 0) && !vdata.validity.AllValid();
981
981
  serializer.WriteProperty("all_valid", all_valid);
982
982
  if (all_valid) {
983
983
  ValidityMask flat_mask(count);