duckdb 0.7.2-dev717.0 → 0.7.2-dev865.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 (179) hide show
  1. package/binding.gyp +2 -0
  2. package/lib/duckdb.d.ts +12 -1
  3. package/lib/duckdb.js +19 -0
  4. package/package.json +1 -1
  5. package/src/duckdb/extension/json/include/json_common.hpp +1 -0
  6. package/src/duckdb/extension/json/include/json_functions.hpp +1 -0
  7. package/src/duckdb/extension/json/include/json_serializer.hpp +77 -0
  8. package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +147 -0
  9. package/src/duckdb/extension/json/json_functions.cpp +1 -0
  10. package/src/duckdb/extension/json/json_scan.cpp +2 -2
  11. package/src/duckdb/extension/json/json_serializer.cpp +217 -0
  12. package/src/duckdb/src/catalog/catalog.cpp +21 -5
  13. package/src/duckdb/src/common/enums/expression_type.cpp +8 -222
  14. package/src/duckdb/src/common/enums/join_type.cpp +3 -22
  15. package/src/duckdb/src/common/exception.cpp +2 -2
  16. package/src/duckdb/src/common/serializer/enum_serializer.cpp +1172 -0
  17. package/src/duckdb/src/common/types/value.cpp +117 -93
  18. package/src/duckdb/src/common/types/vector.cpp +140 -1
  19. package/src/duckdb/src/common/types.cpp +166 -89
  20. package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +3 -0
  21. package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +5 -8
  22. package/src/duckdb/src/function/scalar/date/date_part.cpp +2 -2
  23. package/src/duckdb/src/function/scalar/date/date_trunc.cpp +2 -2
  24. package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +1 -1
  25. package/src/duckdb/src/function/scalar/list/list_lambdas.cpp +4 -0
  26. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +8 -8
  27. package/src/duckdb/src/function/scalar/string/regexp/regexp_extract_all.cpp +243 -0
  28. package/src/duckdb/src/function/scalar/string/regexp/regexp_util.cpp +79 -0
  29. package/src/duckdb/src/function/scalar/string/regexp.cpp +21 -80
  30. package/src/duckdb/src/function/table/arrow_conversion.cpp +7 -1
  31. package/src/duckdb/src/function/table/table_scan.cpp +1 -1
  32. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  33. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +3 -0
  34. package/src/duckdb/src/include/duckdb/common/enums/aggregate_handling.hpp +2 -0
  35. package/src/duckdb/src/include/duckdb/common/enums/expression_type.hpp +2 -3
  36. package/src/duckdb/src/include/duckdb/common/enums/joinref_type.hpp +2 -0
  37. package/src/duckdb/src/include/duckdb/common/enums/order_type.hpp +2 -0
  38. package/src/duckdb/src/include/duckdb/common/enums/set_operation_type.hpp +2 -1
  39. package/src/duckdb/src/include/duckdb/common/exception.hpp +40 -9
  40. package/src/duckdb/src/include/duckdb/common/preserved_error.hpp +3 -0
  41. package/src/duckdb/src/include/duckdb/common/serializer/enum_serializer.hpp +113 -0
  42. package/src/duckdb/src/include/duckdb/common/serializer/format_deserializer.hpp +336 -0
  43. package/src/duckdb/src/include/duckdb/common/serializer/format_serializer.hpp +268 -0
  44. package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +126 -0
  45. package/src/duckdb/src/include/duckdb/common/string_util.hpp +12 -0
  46. package/src/duckdb/src/include/duckdb/common/types/value.hpp +2 -31
  47. package/src/duckdb/src/include/duckdb/common/types/vector.hpp +3 -0
  48. package/src/duckdb/src/include/duckdb/common/types.hpp +8 -2
  49. package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +81 -1
  50. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +1 -0
  51. package/src/duckdb/src/include/duckdb/parser/common_table_expression_info.hpp +2 -0
  52. package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +3 -0
  53. package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +2 -0
  54. package/src/duckdb/src/include/duckdb/parser/expression/case_expression.hpp +5 -0
  55. package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +2 -0
  56. package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +2 -0
  57. package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +2 -0
  58. package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +2 -0
  59. package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +2 -0
  60. package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +3 -0
  61. package/src/duckdb/src/include/duckdb/parser/expression/default_expression.hpp +1 -0
  62. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +2 -0
  63. package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +2 -0
  64. package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +2 -0
  65. package/src/duckdb/src/include/duckdb/parser/expression/parameter_expression.hpp +2 -0
  66. package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +2 -0
  67. package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +2 -0
  68. package/src/duckdb/src/include/duckdb/parser/expression/subquery_expression.hpp +2 -0
  69. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +5 -0
  70. package/src/duckdb/src/include/duckdb/parser/parsed_data/sample_options.hpp +2 -0
  71. package/src/duckdb/src/include/duckdb/parser/parsed_expression.hpp +5 -0
  72. package/src/duckdb/src/include/duckdb/parser/query_node/recursive_cte_node.hpp +3 -0
  73. package/src/duckdb/src/include/duckdb/parser/query_node/select_node.hpp +5 -0
  74. package/src/duckdb/src/include/duckdb/parser/query_node/set_operation_node.hpp +3 -0
  75. package/src/duckdb/src/include/duckdb/parser/query_node.hpp +11 -1
  76. package/src/duckdb/src/include/duckdb/parser/result_modifier.hpp +24 -1
  77. package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +2 -1
  78. package/src/duckdb/src/include/duckdb/parser/statement/select_statement.hpp +6 -1
  79. package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +4 -0
  80. package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +2 -0
  81. package/src/duckdb/src/include/duckdb/parser/tableref/expressionlistref.hpp +3 -0
  82. package/src/duckdb/src/include/duckdb/parser/tableref/joinref.hpp +3 -0
  83. package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +9 -0
  84. package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +3 -0
  85. package/src/duckdb/src/include/duckdb/parser/tableref/table_function_ref.hpp +3 -0
  86. package/src/duckdb/src/include/duckdb/parser/tableref.hpp +3 -1
  87. package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats.hpp +9 -52
  88. package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats_union.hpp +62 -0
  89. package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +2 -1
  90. package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +6 -3
  91. package/src/duckdb/src/include/duckdb/storage/table/column_data_checkpointer.hpp +3 -2
  92. package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +5 -3
  93. package/src/duckdb/src/include/duckdb/storage/table/persistent_table_data.hpp +4 -1
  94. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +6 -3
  95. package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +5 -3
  96. package/src/duckdb/src/include/duckdb/storage/table/row_group_segment_tree.hpp +37 -0
  97. package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +8 -1
  98. package/src/duckdb/src/include/duckdb/storage/table/segment_base.hpp +4 -3
  99. package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +271 -26
  100. package/src/duckdb/src/main/extension/extension_install.cpp +7 -2
  101. package/src/duckdb/src/optimizer/deliminator.cpp +1 -1
  102. package/src/duckdb/src/optimizer/filter_combiner.cpp +1 -1
  103. package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +3 -3
  104. package/src/duckdb/src/optimizer/rule/move_constants.cpp +2 -2
  105. package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +1 -1
  106. package/src/duckdb/src/parser/common_table_expression_info.cpp +19 -0
  107. package/src/duckdb/src/parser/expression/between_expression.cpp +17 -0
  108. package/src/duckdb/src/parser/expression/case_expression.cpp +28 -0
  109. package/src/duckdb/src/parser/expression/cast_expression.cpp +17 -0
  110. package/src/duckdb/src/parser/expression/collate_expression.cpp +16 -0
  111. package/src/duckdb/src/parser/expression/columnref_expression.cpp +15 -0
  112. package/src/duckdb/src/parser/expression/comparison_expression.cpp +16 -0
  113. package/src/duckdb/src/parser/expression/conjunction_expression.cpp +15 -0
  114. package/src/duckdb/src/parser/expression/constant_expression.cpp +14 -0
  115. package/src/duckdb/src/parser/expression/default_expression.cpp +7 -0
  116. package/src/duckdb/src/parser/expression/function_expression.cpp +35 -0
  117. package/src/duckdb/src/parser/expression/lambda_expression.cpp +16 -0
  118. package/src/duckdb/src/parser/expression/operator_expression.cpp +15 -0
  119. package/src/duckdb/src/parser/expression/parameter_expression.cpp +15 -0
  120. package/src/duckdb/src/parser/expression/positional_reference_expression.cpp +14 -0
  121. package/src/duckdb/src/parser/expression/star_expression.cpp +20 -0
  122. package/src/duckdb/src/parser/expression/subquery_expression.cpp +20 -0
  123. package/src/duckdb/src/parser/expression/window_expression.cpp +43 -0
  124. package/src/duckdb/src/parser/parsed_data/sample_options.cpp +22 -10
  125. package/src/duckdb/src/parser/parsed_expression.cpp +72 -0
  126. package/src/duckdb/src/parser/query_node/recursive_cte_node.cpp +21 -0
  127. package/src/duckdb/src/parser/query_node/select_node.cpp +31 -0
  128. package/src/duckdb/src/parser/query_node/set_operation_node.cpp +17 -0
  129. package/src/duckdb/src/parser/query_node.cpp +50 -0
  130. package/src/duckdb/src/parser/result_modifier.cpp +78 -0
  131. package/src/duckdb/src/parser/statement/select_statement.cpp +12 -0
  132. package/src/duckdb/src/parser/tableref/basetableref.cpp +21 -0
  133. package/src/duckdb/src/parser/tableref/emptytableref.cpp +4 -0
  134. package/src/duckdb/src/parser/tableref/expressionlistref.cpp +17 -0
  135. package/src/duckdb/src/parser/tableref/joinref.cpp +25 -0
  136. package/src/duckdb/src/parser/tableref/pivotref.cpp +53 -0
  137. package/src/duckdb/src/parser/tableref/subqueryref.cpp +15 -0
  138. package/src/duckdb/src/parser/tableref/table_function.cpp +17 -0
  139. package/src/duckdb/src/parser/tableref.cpp +46 -0
  140. package/src/duckdb/src/parser/transform/expression/transform_array_access.cpp +11 -0
  141. package/src/duckdb/src/parser/transform/expression/transform_bool_expr.cpp +1 -1
  142. package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +1 -1
  143. package/src/duckdb/src/parser/transform/expression/transform_subquery.cpp +1 -1
  144. package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +22 -4
  145. package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +4 -0
  146. package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +1 -1
  147. package/src/duckdb/src/planner/expression/bound_expression.cpp +4 -0
  148. package/src/duckdb/src/storage/checkpoint/table_data_reader.cpp +3 -11
  149. package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +6 -0
  150. package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -0
  151. package/src/duckdb/src/storage/compression/numeric_constant.cpp +2 -2
  152. package/src/duckdb/src/storage/data_table.cpp +1 -1
  153. package/src/duckdb/src/storage/statistics/numeric_stats.cpp +145 -83
  154. package/src/duckdb/src/storage/statistics/numeric_stats_union.cpp +65 -0
  155. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  156. package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +1 -6
  157. package/src/duckdb/src/storage/table/column_data.cpp +29 -35
  158. package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +5 -5
  159. package/src/duckdb/src/storage/table/column_segment.cpp +8 -7
  160. package/src/duckdb/src/storage/table/list_column_data.cpp +2 -1
  161. package/src/duckdb/src/storage/table/persistent_table_data.cpp +2 -1
  162. package/src/duckdb/src/storage/table/row_group.cpp +9 -9
  163. package/src/duckdb/src/storage/table/row_group_collection.cpp +82 -66
  164. package/src/duckdb/src/storage/table/scan_state.cpp +22 -3
  165. package/src/duckdb/src/storage/table/standard_column_data.cpp +1 -0
  166. package/src/duckdb/src/storage/table/struct_column_data.cpp +1 -0
  167. package/src/duckdb/src/verification/deserialized_statement_verifier.cpp +0 -1
  168. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +11780 -11512
  169. package/src/duckdb/third_party/re2/re2/re2.cc +9 -0
  170. package/src/duckdb/third_party/re2/re2/re2.h +2 -0
  171. package/src/duckdb/ub_extension_json_json_functions.cpp +2 -0
  172. package/src/duckdb/ub_src_common_serializer.cpp +2 -0
  173. package/src/duckdb/ub_src_function_scalar_string_regexp.cpp +4 -0
  174. package/src/duckdb/ub_src_parser.cpp +2 -0
  175. package/src/duckdb/ub_src_storage_statistics.cpp +2 -0
  176. package/src/duckdb/ub_src_storage_table.cpp +0 -2
  177. package/src/utils.cpp +12 -0
  178. package/test/extension.test.ts +44 -26
  179. package/src/duckdb/src/storage/table/segment_tree.cpp +0 -179
@@ -27,6 +27,10 @@
27
27
  #include "duckdb/parser/keyword_helper.hpp"
28
28
  #include "duckdb/parser/parser.hpp"
29
29
 
30
+ #include "duckdb/common/serializer/format_deserializer.hpp"
31
+ #include "duckdb/common/serializer/enum_serializer.hpp"
32
+ #include "duckdb/common/serializer/format_serializer.hpp"
33
+
30
34
  #include <cmath>
31
35
 
32
36
  namespace duckdb {
@@ -327,95 +331,8 @@ bool TypeIsInteger(PhysicalType type) {
327
331
  return (type >= PhysicalType::UINT8 && type <= PhysicalType::INT64) || type == PhysicalType::INT128;
328
332
  }
329
333
 
330
- // LCOV_EXCL_START
331
334
  string LogicalTypeIdToString(LogicalTypeId id) {
332
- switch (id) {
333
- case LogicalTypeId::BOOLEAN:
334
- return "BOOLEAN";
335
- case LogicalTypeId::TINYINT:
336
- return "TINYINT";
337
- case LogicalTypeId::SMALLINT:
338
- return "SMALLINT";
339
- case LogicalTypeId::INTEGER:
340
- return "INTEGER";
341
- case LogicalTypeId::BIGINT:
342
- return "BIGINT";
343
- case LogicalTypeId::HUGEINT:
344
- return "HUGEINT";
345
- case LogicalTypeId::UUID:
346
- return "UUID";
347
- case LogicalTypeId::UTINYINT:
348
- return "UTINYINT";
349
- case LogicalTypeId::USMALLINT:
350
- return "USMALLINT";
351
- case LogicalTypeId::UINTEGER:
352
- return "UINTEGER";
353
- case LogicalTypeId::UBIGINT:
354
- return "UBIGINT";
355
- case LogicalTypeId::DATE:
356
- return "DATE";
357
- case LogicalTypeId::TIME:
358
- return "TIME";
359
- case LogicalTypeId::TIMESTAMP:
360
- return "TIMESTAMP";
361
- case LogicalTypeId::TIMESTAMP_MS:
362
- return "TIMESTAMP_MS";
363
- case LogicalTypeId::TIMESTAMP_NS:
364
- return "TIMESTAMP_NS";
365
- case LogicalTypeId::TIMESTAMP_SEC:
366
- return "TIMESTAMP_S";
367
- case LogicalTypeId::TIMESTAMP_TZ:
368
- return "TIMESTAMP WITH TIME ZONE";
369
- case LogicalTypeId::TIME_TZ:
370
- return "TIME WITH TIME ZONE";
371
- case LogicalTypeId::FLOAT:
372
- return "FLOAT";
373
- case LogicalTypeId::DOUBLE:
374
- return "DOUBLE";
375
- case LogicalTypeId::DECIMAL:
376
- return "DECIMAL";
377
- case LogicalTypeId::VARCHAR:
378
- return "VARCHAR";
379
- case LogicalTypeId::BLOB:
380
- return "BLOB";
381
- case LogicalTypeId::CHAR:
382
- return "CHAR";
383
- case LogicalTypeId::INTERVAL:
384
- return "INTERVAL";
385
- case LogicalTypeId::SQLNULL:
386
- return "NULL";
387
- case LogicalTypeId::ANY:
388
- return "ANY";
389
- case LogicalTypeId::VALIDITY:
390
- return "VALIDITY";
391
- case LogicalTypeId::STRUCT:
392
- return "STRUCT";
393
- case LogicalTypeId::LIST:
394
- return "LIST";
395
- case LogicalTypeId::MAP:
396
- return "MAP";
397
- case LogicalTypeId::POINTER:
398
- return "POINTER";
399
- case LogicalTypeId::TABLE:
400
- return "TABLE";
401
- case LogicalTypeId::LAMBDA:
402
- return "LAMBDA";
403
- case LogicalTypeId::INVALID:
404
- return "INVALID";
405
- case LogicalTypeId::UNION:
406
- return "UNION";
407
- case LogicalTypeId::UNKNOWN:
408
- return "UNKNOWN";
409
- case LogicalTypeId::ENUM:
410
- return "ENUM";
411
- case LogicalTypeId::AGGREGATE_STATE:
412
- return "AGGREGATE_STATE";
413
- case LogicalTypeId::USER:
414
- return "USER";
415
- case LogicalTypeId::BIT:
416
- return "BIT";
417
- }
418
- return "UNDEFINED";
335
+ return EnumSerializer::EnumToString(id);
419
336
  }
420
337
 
421
338
  string LogicalType::ToString() const {
@@ -883,12 +800,16 @@ public:
883
800
  return alias == other_p->alias && EqualsInternal(other_p);
884
801
  }
885
802
  //! Serializes a ExtraTypeInfo to a stand-alone binary blob
886
- virtual void Serialize(FieldWriter &writer) const {};
803
+ virtual void Serialize(FieldWriter &writer) const {
804
+ }
887
805
  //! Serializes a ExtraTypeInfo to a stand-alone binary blob
888
806
  static void Serialize(ExtraTypeInfo *info, FieldWriter &writer);
889
807
  //! Deserializes a blob back into an ExtraTypeInfo
890
808
  static shared_ptr<ExtraTypeInfo> Deserialize(FieldReader &reader);
891
809
 
810
+ virtual void FormatSerialize(FormatSerializer &serializer) const;
811
+ static shared_ptr<ExtraTypeInfo> FormatDeserialize(FormatDeserializer &source);
812
+
892
813
  protected:
893
814
  virtual bool EqualsInternal(ExtraTypeInfo *other_p) const {
894
815
  // Do nothing
@@ -959,6 +880,18 @@ public:
959
880
  writer.WriteField<uint8_t>(scale);
960
881
  }
961
882
 
883
+ void FormatSerialize(FormatSerializer &serializer) const override {
884
+ ExtraTypeInfo::FormatSerialize(serializer);
885
+ serializer.WriteProperty("width", width);
886
+ serializer.WriteProperty("scale", scale);
887
+ }
888
+
889
+ static shared_ptr<ExtraTypeInfo> FormatDeserialize(FormatDeserializer &source) {
890
+ auto width = source.ReadProperty<uint8_t>("width");
891
+ auto scale = source.ReadProperty<uint8_t>("scale");
892
+ return make_shared<DecimalTypeInfo>(width, scale);
893
+ }
894
+
962
895
  static shared_ptr<ExtraTypeInfo> Deserialize(FieldReader &reader) {
963
896
  auto width = reader.ReadRequired<uint8_t>();
964
897
  auto scale = reader.ReadRequired<uint8_t>();
@@ -1016,6 +949,16 @@ public:
1016
949
  return make_shared<StringTypeInfo>(std::move(collation));
1017
950
  }
1018
951
 
952
+ void FormatSerialize(FormatSerializer &serializer) const override {
953
+ ExtraTypeInfo::FormatSerialize(serializer);
954
+ serializer.WriteProperty("collation", collation);
955
+ }
956
+
957
+ static shared_ptr<ExtraTypeInfo> FormatDeserialize(FormatDeserializer &source) {
958
+ auto collation = source.ReadProperty<string>("collation");
959
+ return make_shared<StringTypeInfo>(std::move(collation));
960
+ }
961
+
1019
962
  protected:
1020
963
  bool EqualsInternal(ExtraTypeInfo *other_p) const override {
1021
964
  // collation info has no impact on equality
@@ -1057,11 +1000,21 @@ public:
1057
1000
  writer.WriteSerializable(child_type);
1058
1001
  }
1059
1002
 
1003
+ void FormatSerialize(FormatSerializer &serializer) const override {
1004
+ ExtraTypeInfo::FormatSerialize(serializer);
1005
+ serializer.WriteProperty("child_type", child_type);
1006
+ }
1007
+
1060
1008
  static shared_ptr<ExtraTypeInfo> Deserialize(FieldReader &reader) {
1061
1009
  auto child_type = reader.ReadRequiredSerializable<LogicalType, LogicalType>();
1062
1010
  return make_shared<ListTypeInfo>(std::move(child_type));
1063
1011
  }
1064
1012
 
1013
+ static shared_ptr<ExtraTypeInfo> FormatDeserialize(FormatDeserializer &source) {
1014
+ auto child_type = source.ReadProperty<LogicalType>("child_type");
1015
+ return make_shared<ListTypeInfo>(std::move(child_type));
1016
+ }
1017
+
1065
1018
  protected:
1066
1019
  bool EqualsInternal(ExtraTypeInfo *other_p) const override {
1067
1020
  auto &other = (ListTypeInfo &)*other_p;
@@ -1101,6 +1054,11 @@ public:
1101
1054
  }
1102
1055
  }
1103
1056
 
1057
+ void FormatSerialize(FormatSerializer &serializer) const override {
1058
+ ExtraTypeInfo::FormatSerialize(serializer);
1059
+ serializer.WriteProperty("child_types", child_types);
1060
+ }
1061
+
1104
1062
  static shared_ptr<ExtraTypeInfo> Deserialize(FieldReader &reader) {
1105
1063
  child_list_t<LogicalType> child_list;
1106
1064
  auto child_types_size = reader.ReadRequired<uint32_t>();
@@ -1113,6 +1071,11 @@ public:
1113
1071
  return make_shared<StructTypeInfo>(std::move(child_list));
1114
1072
  }
1115
1073
 
1074
+ static shared_ptr<ExtraTypeInfo> FormatDeserialize(FormatDeserializer &deserializer) {
1075
+ auto child_types = deserializer.ReadProperty<child_list_t<LogicalType>>("child_types");
1076
+ return make_shared<StructTypeInfo>(std::move(child_types));
1077
+ }
1078
+
1116
1079
  protected:
1117
1080
  bool EqualsInternal(ExtraTypeInfo *other_p) const override {
1118
1081
  auto &other = (StructTypeInfo &)*other_p;
@@ -1138,6 +1101,21 @@ public:
1138
1101
  }
1139
1102
  }
1140
1103
 
1104
+ void FormatSerialize(FormatSerializer &serializer) const override {
1105
+ ExtraTypeInfo::FormatSerialize(serializer);
1106
+ serializer.WriteProperty("function_name", state_type.function_name);
1107
+ serializer.WriteProperty("return_type", state_type.return_type);
1108
+ serializer.WriteProperty("bound_argument_types", state_type.bound_argument_types);
1109
+ }
1110
+
1111
+ static shared_ptr<ExtraTypeInfo> FormatDeserialize(FormatDeserializer &source) {
1112
+ auto function_name = source.ReadProperty<string>("function_name");
1113
+ auto return_type = source.ReadProperty<LogicalType>("return_type");
1114
+ auto bound_argument_types = source.ReadProperty<vector<LogicalType>>("bound_argument_types");
1115
+ return make_shared<AggregateStateTypeInfo>(
1116
+ aggregate_state_t(std::move(function_name), std::move(return_type), std::move(bound_argument_types)));
1117
+ }
1118
+
1141
1119
  static shared_ptr<ExtraTypeInfo> Deserialize(FieldReader &reader) {
1142
1120
  auto &source = reader.GetSource();
1143
1121
 
@@ -1294,11 +1272,21 @@ public:
1294
1272
  writer.WriteString(user_type_name);
1295
1273
  }
1296
1274
 
1275
+ void FormatSerialize(FormatSerializer &serializer) const override {
1276
+ ExtraTypeInfo::FormatSerialize(serializer);
1277
+ serializer.WriteProperty("user_type_name", user_type_name);
1278
+ }
1279
+
1297
1280
  static shared_ptr<ExtraTypeInfo> Deserialize(FieldReader &reader) {
1298
1281
  auto enum_name = reader.ReadRequired<string>();
1299
1282
  return make_shared<UserTypeInfo>(std::move(enum_name));
1300
1283
  }
1301
1284
 
1285
+ static shared_ptr<ExtraTypeInfo> FormatDeserialize(FormatDeserializer &source) {
1286
+ auto enum_name = source.ReadProperty<string>("user_type_name");
1287
+ return make_shared<UserTypeInfo>(std::move(enum_name));
1288
+ }
1289
+
1302
1290
  protected:
1303
1291
  bool EqualsInternal(ExtraTypeInfo *other_p) const override {
1304
1292
  auto &other = (UserTypeInfo &)*other_p;
@@ -1380,6 +1368,12 @@ protected:
1380
1368
  EnumType::Serialize(writer, *this, serialize_internals);
1381
1369
  }
1382
1370
 
1371
+ void FormatSerialize(FormatSerializer &serializer) const override {
1372
+ ExtraTypeInfo::FormatSerialize(serializer);
1373
+ serializer.WriteProperty("dict_size", dict_size);
1374
+ serializer.WriteProperty("enum_name", enum_name);
1375
+ ((Vector &)values_insert_order).FormatSerialize(serializer, dict_size);
1376
+ }
1383
1377
  Vector values_insert_order;
1384
1378
 
1385
1379
  private:
@@ -1439,6 +1433,13 @@ struct EnumTypeInfoTemplated : public EnumTypeInfo {
1439
1433
  return make_shared<EnumTypeInfoTemplated>(std::move(enum_name), values_insert_order, size);
1440
1434
  }
1441
1435
 
1436
+ static shared_ptr<EnumTypeInfoTemplated> FormatDeserialize(FormatDeserializer &source, uint32_t size) {
1437
+ auto enum_name = source.ReadProperty<string>("enum_name");
1438
+ Vector values_insert_order(LogicalType::VARCHAR, size);
1439
+ values_insert_order.FormatDeserialize(source, size);
1440
+ return make_shared<EnumTypeInfoTemplated>(std::move(enum_name), values_insert_order, size);
1441
+ }
1442
+
1442
1443
  string_map_t<T> &GetValues() {
1443
1444
  return values;
1444
1445
  }
@@ -1573,6 +1574,70 @@ void ExtraTypeInfo::Serialize(ExtraTypeInfo *info, FieldWriter &writer) {
1573
1574
  writer.WriteString(info->alias);
1574
1575
  }
1575
1576
  }
1577
+ void ExtraTypeInfo::FormatSerialize(FormatSerializer &serializer) const {
1578
+ serializer.WriteProperty("type", type);
1579
+ serializer.WriteProperty("alias", alias);
1580
+ }
1581
+
1582
+ shared_ptr<ExtraTypeInfo> ExtraTypeInfo::FormatDeserialize(FormatDeserializer &deserializer) {
1583
+ auto type = deserializer.ReadProperty<ExtraTypeInfoType>("type");
1584
+
1585
+ shared_ptr<ExtraTypeInfo> result;
1586
+ switch (type) {
1587
+ case ExtraTypeInfoType::INVALID_TYPE_INFO: {
1588
+ string alias;
1589
+ deserializer.ReadOptionalProperty("alias", alias);
1590
+ if (!alias.empty()) {
1591
+ return make_shared<ExtraTypeInfo>(type, alias);
1592
+ }
1593
+ return nullptr;
1594
+ }
1595
+ case ExtraTypeInfoType::GENERIC_TYPE_INFO: {
1596
+ result = make_shared<ExtraTypeInfo>(type);
1597
+ } break;
1598
+ case ExtraTypeInfoType::DECIMAL_TYPE_INFO:
1599
+ result = DecimalTypeInfo::FormatDeserialize(deserializer);
1600
+ break;
1601
+ case ExtraTypeInfoType::STRING_TYPE_INFO:
1602
+ result = StringTypeInfo::FormatDeserialize(deserializer);
1603
+ break;
1604
+ case ExtraTypeInfoType::LIST_TYPE_INFO:
1605
+ result = ListTypeInfo::FormatDeserialize(deserializer);
1606
+ break;
1607
+ case ExtraTypeInfoType::STRUCT_TYPE_INFO:
1608
+ result = StructTypeInfo::FormatDeserialize(deserializer);
1609
+ break;
1610
+ case ExtraTypeInfoType::USER_TYPE_INFO:
1611
+ result = UserTypeInfo::FormatDeserialize(deserializer);
1612
+ break;
1613
+ case ExtraTypeInfoType::ENUM_TYPE_INFO: {
1614
+ auto enum_size = deserializer.ReadProperty<uint32_t>("enum_size");
1615
+ auto enum_internal_type = EnumVectorDictType(enum_size);
1616
+ switch (enum_internal_type) {
1617
+ case PhysicalType::UINT8:
1618
+ result = EnumTypeInfoTemplated<uint8_t>::FormatDeserialize(deserializer, enum_size);
1619
+ break;
1620
+ case PhysicalType::UINT16:
1621
+ result = EnumTypeInfoTemplated<uint16_t>::FormatDeserialize(deserializer, enum_size);
1622
+ break;
1623
+ case PhysicalType::UINT32:
1624
+ result = EnumTypeInfoTemplated<uint32_t>::FormatDeserialize(deserializer, enum_size);
1625
+ break;
1626
+ default:
1627
+ throw InternalException("Invalid Physical Type for ENUMs");
1628
+ }
1629
+ } break;
1630
+ case ExtraTypeInfoType::AGGREGATE_STATE_TYPE_INFO:
1631
+ result = AggregateStateTypeInfo::FormatDeserialize(deserializer);
1632
+ break;
1633
+
1634
+ default:
1635
+ throw InternalException("Unimplemented type info in ExtraTypeInfo::Deserialize");
1636
+ }
1637
+ deserializer.ReadOptionalPropertyOrDefault("alias", result->alias, string());
1638
+ return result;
1639
+ }
1640
+
1576
1641
  shared_ptr<ExtraTypeInfo> ExtraTypeInfo::Deserialize(FieldReader &reader) {
1577
1642
  auto type = reader.ReadRequired<ExtraTypeInfoType>();
1578
1643
  shared_ptr<ExtraTypeInfo> extra_info;
@@ -1684,6 +1749,18 @@ LogicalType LogicalType::Deserialize(Deserializer &source) {
1684
1749
  return LogicalType(id, std::move(info));
1685
1750
  }
1686
1751
 
1752
+ void LogicalType::FormatSerialize(FormatSerializer &serializer) const {
1753
+ serializer.WriteProperty("id", id_);
1754
+ serializer.WriteOptionalProperty("type_info", type_info_.get());
1755
+ }
1756
+
1757
+ LogicalType LogicalType::FormatDeserialize(FormatDeserializer &deserializer) {
1758
+ auto id = deserializer.ReadProperty<LogicalTypeId>("id");
1759
+ auto info = deserializer.ReadOptionalProperty<shared_ptr<ExtraTypeInfo>>("type_info");
1760
+
1761
+ return LogicalType(id, std::move(info));
1762
+ }
1763
+
1687
1764
  bool LogicalType::EqualTypeInfo(const LogicalType &rhs) const {
1688
1765
  if (type_info_.get() == rhs.type_info_.get()) {
1689
1766
  return true;
@@ -111,6 +111,9 @@ SinkResultType PhysicalLimit::Sink(ExecutionContext &context, GlobalSinkState &g
111
111
  }
112
112
  state.data.Append(input, lstate.batch_index);
113
113
  state.current_offset += input.size();
114
+ if (state.current_offset == max_element) {
115
+ return SinkResultType::FINISHED;
116
+ }
114
117
  return SinkResultType::NEED_MORE_INPUT;
115
118
  }
116
119
 
@@ -73,20 +73,17 @@ static bool CanUsePerfectHashAggregate(ClientContext &context, LogicalAggregate
73
73
  int64_t range;
74
74
  switch (group_type.InternalType()) {
75
75
  case PhysicalType::INT8:
76
- range = int64_t(NumericStats::GetMaxUnsafe<int8_t>(nstats)) -
77
- int64_t(NumericStats::GetMinUnsafe<int8_t>(nstats));
76
+ range = int64_t(NumericStats::GetMax<int8_t>(nstats)) - int64_t(NumericStats::GetMin<int8_t>(nstats));
78
77
  break;
79
78
  case PhysicalType::INT16:
80
- range = int64_t(NumericStats::GetMaxUnsafe<int16_t>(nstats)) -
81
- int64_t(NumericStats::GetMinUnsafe<int16_t>(nstats));
79
+ range = int64_t(NumericStats::GetMax<int16_t>(nstats)) - int64_t(NumericStats::GetMin<int16_t>(nstats));
82
80
  break;
83
81
  case PhysicalType::INT32:
84
- range = int64_t(NumericStats::GetMaxUnsafe<int32_t>(nstats)) -
85
- int64_t(NumericStats::GetMinUnsafe<int32_t>(nstats));
82
+ range = int64_t(NumericStats::GetMax<int32_t>(nstats)) - int64_t(NumericStats::GetMin<int32_t>(nstats));
86
83
  break;
87
84
  case PhysicalType::INT64:
88
- if (!TrySubtractOperator::Operation(NumericStats::GetMaxUnsafe<int64_t>(nstats),
89
- NumericStats::GetMinUnsafe<int64_t>(nstats), range)) {
85
+ if (!TrySubtractOperator::Operation(NumericStats::GetMax<int64_t>(nstats),
86
+ NumericStats::GetMin<int64_t>(nstats), range)) {
90
87
  return false;
91
88
  }
92
89
  break;
@@ -180,8 +180,8 @@ struct DatePart {
180
180
  return nullptr;
181
181
  }
182
182
  // run the operator on both the min and the max, this gives us the [min, max] bound
183
- auto min = NumericStats::GetMinUnsafe<T>(nstats);
184
- auto max = NumericStats::GetMaxUnsafe<T>(nstats);
183
+ auto min = NumericStats::GetMin<T>(nstats);
184
+ auto max = NumericStats::GetMax<T>(nstats);
185
185
  if (min > max) {
186
186
  return nullptr;
187
187
  }
@@ -594,8 +594,8 @@ static unique_ptr<BaseStatistics> DateTruncStatistics(vector<BaseStatistics> &ch
594
594
  return nullptr;
595
595
  }
596
596
  // run the operator on both the min and the max, this gives us the [min, max] bound
597
- auto min = NumericStats::GetMinUnsafe<TA>(nstats);
598
- auto max = NumericStats::GetMaxUnsafe<TA>(nstats);
597
+ auto min = NumericStats::GetMin<TA>(nstats);
598
+ auto max = NumericStats::GetMax<TA>(nstats);
599
599
  if (min > max) {
600
600
  return nullptr;
601
601
  }
@@ -507,7 +507,7 @@ ScalarFunction ListUniqueFun::GetFunction() {
507
507
  }
508
508
 
509
509
  void ListAggregateFun::RegisterFunction(BuiltinFunctions &set) {
510
- set.AddFunction({"list_aggregate", "array_aggregate", "list_aggr", "array_aggr"}, GetFunction());
510
+ set.AddFunction({"list_aggregate", "array_aggregate", "list_aggr", "array_aggr", "aggregate"}, GetFunction());
511
511
  }
512
512
 
513
513
  void ListDistinctFun::RegisterFunction(BuiltinFunctions &set) {
@@ -392,6 +392,8 @@ void ListTransformFun::RegisterFunction(BuiltinFunctions &set) {
392
392
  set.AddFunction(fun);
393
393
  fun.name = "array_apply";
394
394
  set.AddFunction(fun);
395
+ fun.name = "apply";
396
+ set.AddFunction(fun);
395
397
  }
396
398
 
397
399
  void ListFilterFun::RegisterFunction(BuiltinFunctions &set) {
@@ -405,6 +407,8 @@ void ListFilterFun::RegisterFunction(BuiltinFunctions &set) {
405
407
 
406
408
  fun.name = "array_filter";
407
409
  set.AddFunction(fun);
410
+ fun.name = "filter";
411
+ set.AddFunction(fun);
408
412
  }
409
413
 
410
414
  } // namespace duckdb
@@ -81,11 +81,11 @@ struct AddPropagateStatistics {
81
81
  Value &new_max) {
82
82
  T min, max;
83
83
  // new min is min+min
84
- if (!OP::Operation(NumericStats::GetMinUnsafe<T>(lstats), NumericStats::GetMinUnsafe<T>(rstats), min)) {
84
+ if (!OP::Operation(NumericStats::GetMin<T>(lstats), NumericStats::GetMin<T>(rstats), min)) {
85
85
  return true;
86
86
  }
87
87
  // new max is max+max
88
- if (!OP::Operation(NumericStats::GetMaxUnsafe<T>(lstats), NumericStats::GetMaxUnsafe<T>(rstats), max)) {
88
+ if (!OP::Operation(NumericStats::GetMax<T>(lstats), NumericStats::GetMax<T>(rstats), max)) {
89
89
  return true;
90
90
  }
91
91
  new_min = Value::Numeric(type, min);
@@ -99,10 +99,10 @@ struct SubtractPropagateStatistics {
99
99
  static bool Operation(LogicalType type, BaseStatistics &lstats, BaseStatistics &rstats, Value &new_min,
100
100
  Value &new_max) {
101
101
  T min, max;
102
- if (!OP::Operation(NumericStats::GetMinUnsafe<T>(lstats), NumericStats::GetMaxUnsafe<T>(rstats), min)) {
102
+ if (!OP::Operation(NumericStats::GetMin<T>(lstats), NumericStats::GetMax<T>(rstats), min)) {
103
103
  return true;
104
104
  }
105
- if (!OP::Operation(NumericStats::GetMaxUnsafe<T>(lstats), NumericStats::GetMinUnsafe<T>(rstats), max)) {
105
+ if (!OP::Operation(NumericStats::GetMax<T>(lstats), NumericStats::GetMin<T>(rstats), max)) {
106
106
  return true;
107
107
  }
108
108
  new_min = Value::Numeric(type, min);
@@ -489,8 +489,8 @@ unique_ptr<FunctionData> DecimalNegateBind(ClientContext &context, ScalarFunctio
489
489
  struct NegatePropagateStatistics {
490
490
  template <class T>
491
491
  static bool Operation(LogicalType type, BaseStatistics &istats, Value &new_min, Value &new_max) {
492
- auto max_value = NumericStats::GetMaxUnsafe<T>(istats);
493
- auto min_value = NumericStats::GetMinUnsafe<T>(istats);
492
+ auto max_value = NumericStats::GetMax<T>(istats);
493
+ auto min_value = NumericStats::GetMin<T>(istats);
494
494
  if (!NegateOperator::CanNegate<T>(min_value) || !NegateOperator::CanNegate<T>(max_value)) {
495
495
  return true;
496
496
  }
@@ -664,8 +664,8 @@ struct MultiplyPropagateStatistics {
664
664
  // etc
665
665
  // rather than doing all this switcheroo we just multiply all combinations of lmin/lmax with rmin/rmax
666
666
  // and check what the minimum/maximum value is
667
- T lvals[] {NumericStats::GetMinUnsafe<T>(lstats), NumericStats::GetMaxUnsafe<T>(lstats)};
668
- T rvals[] {NumericStats::GetMinUnsafe<T>(rstats), NumericStats::GetMaxUnsafe<T>(rstats)};
667
+ T lvals[] {NumericStats::GetMin<T>(lstats), NumericStats::GetMax<T>(lstats)};
668
+ T rvals[] {NumericStats::GetMin<T>(rstats), NumericStats::GetMax<T>(rstats)};
669
669
  T min = NumericLimits<T>::Maximum();
670
670
  T max = NumericLimits<T>::Minimum();
671
671
  // multiplications