duckdb 0.7.2-dev16.0 → 0.7.2-dev314.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 (242) hide show
  1. package/binding.gyp +2 -0
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/icu/icu-extension.cpp +2 -0
  4. package/src/duckdb/extension/icu/icu-table-range.cpp +194 -0
  5. package/src/duckdb/extension/icu/include/icu-table-range.hpp +17 -0
  6. package/src/duckdb/extension/parquet/column_reader.cpp +5 -6
  7. package/src/duckdb/extension/parquet/column_writer.cpp +0 -1
  8. package/src/duckdb/extension/parquet/include/column_reader.hpp +1 -2
  9. package/src/duckdb/extension/parquet/include/generated_column_reader.hpp +1 -11
  10. package/src/duckdb/extension/parquet/parquet-extension.cpp +11 -2
  11. package/src/duckdb/extension/parquet/parquet_statistics.cpp +26 -32
  12. package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +4 -0
  13. package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +7 -6
  14. package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +20 -1
  15. package/src/duckdb/src/common/enums/statement_type.cpp +2 -0
  16. package/src/duckdb/src/common/sort/sort_state.cpp +5 -7
  17. package/src/duckdb/src/common/types/bit.cpp +95 -58
  18. package/src/duckdb/src/common/types/value.cpp +149 -53
  19. package/src/duckdb/src/common/types/vector.cpp +13 -10
  20. package/src/duckdb/src/execution/column_binding_resolver.cpp +6 -0
  21. package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +4 -5
  22. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +1 -1
  23. package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +2 -3
  24. package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +32 -6
  25. package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +1 -1
  26. package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +15 -15
  27. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +18 -12
  28. package/src/duckdb/src/function/aggregate/algebraic/avg.cpp +0 -6
  29. package/src/duckdb/src/function/aggregate/distributive/bitagg.cpp +99 -95
  30. package/src/duckdb/src/function/aggregate/distributive/bitstring_agg.cpp +254 -0
  31. package/src/duckdb/src/function/aggregate/distributive/count.cpp +2 -4
  32. package/src/duckdb/src/function/aggregate/distributive/sum.cpp +11 -16
  33. package/src/duckdb/src/function/aggregate/distributive_functions.cpp +1 -0
  34. package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +16 -5
  35. package/src/duckdb/src/function/cast/bit_cast.cpp +0 -2
  36. package/src/duckdb/src/function/cast/blob_cast.cpp +0 -1
  37. package/src/duckdb/src/function/scalar/bit/bitstring.cpp +99 -0
  38. package/src/duckdb/src/function/scalar/date/date_diff.cpp +0 -1
  39. package/src/duckdb/src/function/scalar/date/date_part.cpp +17 -25
  40. package/src/duckdb/src/function/scalar/date/date_sub.cpp +0 -1
  41. package/src/duckdb/src/function/scalar/date/date_trunc.cpp +10 -14
  42. package/src/duckdb/src/function/scalar/generic/stats.cpp +2 -4
  43. package/src/duckdb/src/function/scalar/list/flatten.cpp +5 -12
  44. package/src/duckdb/src/function/scalar/list/list_concat.cpp +3 -8
  45. package/src/duckdb/src/function/scalar/list/list_extract.cpp +5 -12
  46. package/src/duckdb/src/function/scalar/list/list_value.cpp +5 -9
  47. package/src/duckdb/src/function/scalar/map/map_entries.cpp +61 -0
  48. package/src/duckdb/src/function/scalar/map/map_keys_values.cpp +97 -0
  49. package/src/duckdb/src/function/scalar/math/numeric.cpp +14 -17
  50. package/src/duckdb/src/function/scalar/nested_functions.cpp +3 -0
  51. package/src/duckdb/src/function/scalar/operators/add.cpp +0 -9
  52. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +29 -48
  53. package/src/duckdb/src/function/scalar/operators/bitwise.cpp +0 -63
  54. package/src/duckdb/src/function/scalar/operators/multiply.cpp +0 -6
  55. package/src/duckdb/src/function/scalar/operators/subtract.cpp +0 -6
  56. package/src/duckdb/src/function/scalar/string/caseconvert.cpp +2 -6
  57. package/src/duckdb/src/function/scalar/string/instr.cpp +2 -6
  58. package/src/duckdb/src/function/scalar/string/length.cpp +2 -6
  59. package/src/duckdb/src/function/scalar/string/like.cpp +2 -6
  60. package/src/duckdb/src/function/scalar/string/substring.cpp +2 -6
  61. package/src/duckdb/src/function/scalar/string_functions.cpp +1 -0
  62. package/src/duckdb/src/function/scalar/struct/struct_extract.cpp +4 -9
  63. package/src/duckdb/src/function/scalar/struct/struct_insert.cpp +10 -13
  64. package/src/duckdb/src/function/scalar/struct/struct_pack.cpp +5 -6
  65. package/src/duckdb/src/function/table/read_csv.cpp +9 -0
  66. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  67. package/src/duckdb/src/function/table_function.cpp +19 -0
  68. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp +6 -8
  69. package/src/duckdb/src/include/duckdb/common/constants.hpp +0 -19
  70. package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +2 -1
  71. package/src/duckdb/src/include/duckdb/common/enums/tableref_type.hpp +2 -1
  72. package/src/duckdb/src/include/duckdb/common/types/bit.hpp +5 -1
  73. package/src/duckdb/src/include/duckdb/common/types/value.hpp +2 -8
  74. package/src/duckdb/src/include/duckdb/common/types.hpp +1 -2
  75. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +1 -1
  76. package/src/duckdb/src/include/duckdb/function/aggregate/distributive_functions.hpp +5 -0
  77. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +12 -3
  78. package/src/duckdb/src/include/duckdb/function/scalar/bit_functions.hpp +4 -0
  79. package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +12 -0
  80. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -2
  81. package/src/duckdb/src/include/duckdb/function/table_function.hpp +2 -0
  82. package/src/duckdb/src/include/duckdb/main/capi/capi_internal.hpp +2 -0
  83. package/src/duckdb/src/include/duckdb/main/config.hpp +3 -0
  84. package/src/duckdb/src/include/duckdb/main/database.hpp +1 -0
  85. package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +2 -2
  86. package/src/duckdb/src/include/duckdb/parser/common_table_expression_info.hpp +2 -0
  87. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +2 -1
  88. package/src/duckdb/src/include/duckdb/parser/parsed_data/{alter_function_info.hpp → alter_scalar_function_info.hpp} +13 -13
  89. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_function_info.hpp +47 -0
  90. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_function_info.hpp +2 -1
  91. package/src/duckdb/src/include/duckdb/parser/query_node.hpp +2 -1
  92. package/src/duckdb/src/include/duckdb/parser/statement/multi_statement.hpp +28 -0
  93. package/src/duckdb/src/include/duckdb/parser/tableref/list.hpp +1 -0
  94. package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +76 -0
  95. package/src/duckdb/src/include/duckdb/parser/tokens.hpp +2 -0
  96. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +28 -0
  97. package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -0
  98. package/src/duckdb/src/include/duckdb/planner/binder.hpp +8 -0
  99. package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +2 -0
  100. package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +76 -44
  101. package/src/duckdb/src/include/duckdb/storage/checkpoint/table_data_writer.hpp +3 -2
  102. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_compress.hpp +2 -2
  103. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_fetch.hpp +1 -1
  104. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_scan.hpp +1 -1
  105. package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_compress.hpp +2 -2
  106. package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_fetch.hpp +1 -1
  107. package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_scan.hpp +1 -1
  108. package/src/duckdb/src/include/duckdb/storage/data_pointer.hpp +5 -2
  109. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
  110. package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +93 -29
  111. package/src/duckdb/src/include/duckdb/storage/statistics/column_statistics.hpp +22 -3
  112. package/src/duckdb/src/include/duckdb/storage/statistics/distinct_statistics.hpp +6 -6
  113. package/src/duckdb/src/include/duckdb/storage/statistics/list_stats.hpp +41 -0
  114. package/src/duckdb/src/include/duckdb/storage/statistics/node_statistics.hpp +26 -0
  115. package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats.hpp +157 -0
  116. package/src/duckdb/src/include/duckdb/storage/statistics/segment_statistics.hpp +2 -7
  117. package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +74 -0
  118. package/src/duckdb/src/include/duckdb/storage/statistics/struct_stats.hpp +42 -0
  119. package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +2 -3
  120. package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +2 -2
  121. package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +1 -1
  122. package/src/duckdb/src/include/duckdb/storage/table/persistent_table_data.hpp +2 -1
  123. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +4 -3
  124. package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +3 -2
  125. package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +2 -0
  126. package/src/duckdb/src/include/duckdb/storage/table/table_statistics.hpp +5 -0
  127. package/src/duckdb/src/include/duckdb.h +49 -1
  128. package/src/duckdb/src/include/duckdb.hpp +0 -1
  129. package/src/duckdb/src/main/capi/pending-c.cpp +16 -3
  130. package/src/duckdb/src/main/capi/result-c.cpp +27 -1
  131. package/src/duckdb/src/main/capi/stream-c.cpp +25 -0
  132. package/src/duckdb/src/main/client_context.cpp +8 -1
  133. package/src/duckdb/src/main/config.cpp +66 -1
  134. package/src/duckdb/src/main/database.cpp +10 -2
  135. package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +98 -67
  136. package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +16 -3
  137. package/src/duckdb/src/optimizer/statistics/expression/propagate_aggregate.cpp +9 -3
  138. package/src/duckdb/src/optimizer/statistics/expression/propagate_and_compress.cpp +6 -7
  139. package/src/duckdb/src/optimizer/statistics/expression/propagate_cast.cpp +14 -11
  140. package/src/duckdb/src/optimizer/statistics/expression/propagate_columnref.cpp +1 -1
  141. package/src/duckdb/src/optimizer/statistics/expression/propagate_comparison.cpp +13 -15
  142. package/src/duckdb/src/optimizer/statistics/expression/propagate_conjunction.cpp +0 -1
  143. package/src/duckdb/src/optimizer/statistics/expression/propagate_constant.cpp +3 -75
  144. package/src/duckdb/src/optimizer/statistics/expression/propagate_function.cpp +7 -2
  145. package/src/duckdb/src/optimizer/statistics/expression/propagate_operator.cpp +10 -0
  146. package/src/duckdb/src/optimizer/statistics/operator/propagate_aggregate.cpp +2 -3
  147. package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +28 -31
  148. package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +4 -5
  149. package/src/duckdb/src/optimizer/statistics/operator/propagate_set_operation.cpp +3 -3
  150. package/src/duckdb/src/optimizer/statistics_propagator.cpp +1 -1
  151. package/src/duckdb/src/parser/parsed_data/alter_info.cpp +7 -3
  152. package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +56 -0
  153. package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +51 -0
  154. package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +3 -2
  155. package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +6 -0
  156. package/src/duckdb/src/parser/parsed_expression_iterator.cpp +8 -0
  157. package/src/duckdb/src/parser/query_node.cpp +1 -1
  158. package/src/duckdb/src/parser/statement/multi_statement.cpp +18 -0
  159. package/src/duckdb/src/parser/tableref/pivotref.cpp +296 -0
  160. package/src/duckdb/src/parser/tableref.cpp +3 -0
  161. package/src/duckdb/src/parser/transform/helpers/transform_alias.cpp +12 -6
  162. package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +24 -0
  163. package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +4 -0
  164. package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +4 -0
  165. package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +150 -0
  166. package/src/duckdb/src/parser/transform/statement/transform_select.cpp +8 -0
  167. package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +1 -1
  168. package/src/duckdb/src/parser/transform/tableref/transform_join.cpp +4 -0
  169. package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +105 -0
  170. package/src/duckdb/src/parser/transform/tableref/transform_tableref.cpp +2 -0
  171. package/src/duckdb/src/parser/transformer.cpp +15 -3
  172. package/src/duckdb/src/planner/bind_context.cpp +16 -0
  173. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +11 -3
  174. package/src/duckdb/src/planner/binder/query_node/plan_select_node.cpp +0 -1
  175. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +1 -1
  176. package/src/duckdb/src/planner/binder/statement/bind_logical_plan.cpp +17 -0
  177. package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +9 -0
  178. package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +365 -0
  179. package/src/duckdb/src/planner/binder.cpp +7 -1
  180. package/src/duckdb/src/planner/bound_result_modifier.cpp +1 -1
  181. package/src/duckdb/src/planner/expression/bound_window_expression.cpp +1 -1
  182. package/src/duckdb/src/planner/filter/constant_filter.cpp +4 -6
  183. package/src/duckdb/src/planner/pragma_handler.cpp +10 -2
  184. package/src/duckdb/src/storage/buffer_manager.cpp +44 -46
  185. package/src/duckdb/src/storage/checkpoint/row_group_writer.cpp +1 -1
  186. package/src/duckdb/src/storage/checkpoint/table_data_reader.cpp +1 -4
  187. package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +4 -4
  188. package/src/duckdb/src/storage/compression/bitpacking.cpp +28 -24
  189. package/src/duckdb/src/storage/compression/fixed_size_uncompressed.cpp +43 -45
  190. package/src/duckdb/src/storage/compression/numeric_constant.cpp +9 -10
  191. package/src/duckdb/src/storage/compression/patas.cpp +1 -1
  192. package/src/duckdb/src/storage/compression/rle.cpp +19 -15
  193. package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +5 -5
  194. package/src/duckdb/src/storage/data_table.cpp +4 -6
  195. package/src/duckdb/src/storage/statistics/base_statistics.cpp +373 -128
  196. package/src/duckdb/src/storage/statistics/column_statistics.cpp +58 -3
  197. package/src/duckdb/src/storage/statistics/distinct_statistics.cpp +4 -9
  198. package/src/duckdb/src/storage/statistics/list_stats.cpp +117 -0
  199. package/src/duckdb/src/storage/statistics/numeric_stats.cpp +529 -0
  200. package/src/duckdb/src/storage/statistics/segment_statistics.cpp +2 -11
  201. package/src/duckdb/src/storage/statistics/string_stats.cpp +273 -0
  202. package/src/duckdb/src/storage/statistics/struct_stats.cpp +131 -0
  203. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  204. package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +3 -4
  205. package/src/duckdb/src/storage/table/column_data.cpp +16 -11
  206. package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +2 -3
  207. package/src/duckdb/src/storage/table/column_segment.cpp +6 -8
  208. package/src/duckdb/src/storage/table/list_column_data.cpp +39 -58
  209. package/src/duckdb/src/storage/table/row_group.cpp +24 -23
  210. package/src/duckdb/src/storage/table/row_group_collection.cpp +12 -12
  211. package/src/duckdb/src/storage/table/standard_column_data.cpp +6 -6
  212. package/src/duckdb/src/storage/table/struct_column_data.cpp +15 -16
  213. package/src/duckdb/src/storage/table/table_statistics.cpp +27 -7
  214. package/src/duckdb/src/storage/table/update_segment.cpp +10 -12
  215. package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +3 -0
  216. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +34 -1
  217. package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +1020 -530
  218. package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +7 -0
  219. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +23560 -22737
  220. package/src/duckdb/ub_src_function_aggregate_distributive.cpp +2 -0
  221. package/src/duckdb/ub_src_function_scalar_bit.cpp +2 -0
  222. package/src/duckdb/ub_src_function_scalar_map.cpp +4 -0
  223. package/src/duckdb/ub_src_main_capi.cpp +2 -0
  224. package/src/duckdb/ub_src_parser_parsed_data.cpp +4 -2
  225. package/src/duckdb/ub_src_parser_statement.cpp +2 -0
  226. package/src/duckdb/ub_src_parser_tableref.cpp +2 -0
  227. package/src/duckdb/ub_src_parser_transform_statement.cpp +2 -0
  228. package/src/duckdb/ub_src_parser_transform_tableref.cpp +2 -0
  229. package/src/duckdb/ub_src_planner_binder_tableref.cpp +2 -0
  230. package/src/duckdb/ub_src_storage_statistics.cpp +4 -6
  231. package/src/duckdb/src/include/duckdb/main/loadable_extension.hpp +0 -59
  232. package/src/duckdb/src/include/duckdb/storage/statistics/list_statistics.hpp +0 -36
  233. package/src/duckdb/src/include/duckdb/storage/statistics/numeric_statistics.hpp +0 -75
  234. package/src/duckdb/src/include/duckdb/storage/statistics/string_statistics.hpp +0 -49
  235. package/src/duckdb/src/include/duckdb/storage/statistics/struct_statistics.hpp +0 -36
  236. package/src/duckdb/src/include/duckdb/storage/statistics/validity_statistics.hpp +0 -45
  237. package/src/duckdb/src/parser/parsed_data/alter_function_info.cpp +0 -55
  238. package/src/duckdb/src/storage/statistics/list_statistics.cpp +0 -94
  239. package/src/duckdb/src/storage/statistics/numeric_statistics.cpp +0 -307
  240. package/src/duckdb/src/storage/statistics/string_statistics.cpp +0 -220
  241. package/src/duckdb/src/storage/statistics/struct_statistics.cpp +0 -108
  242. package/src/duckdb/src/storage/statistics/validity_statistics.cpp +0 -91
package/binding.gyp CHANGED
@@ -57,6 +57,7 @@
57
57
  "src/duckdb/ub_src_function.cpp",
58
58
  "src/duckdb/ub_src_function_cast.cpp",
59
59
  "src/duckdb/ub_src_function_pragma.cpp",
60
+ "src/duckdb/ub_src_function_scalar_bit.cpp",
60
61
  "src/duckdb/ub_src_function_scalar_blob.cpp",
61
62
  "src/duckdb/ub_src_function_scalar_date.cpp",
62
63
  "src/duckdb/ub_src_function_scalar.cpp",
@@ -223,6 +224,7 @@
223
224
  "src/duckdb/third_party/zstd/compress/zstd_ldm.cpp",
224
225
  "src/duckdb/third_party/zstd/compress/zstd_opt.cpp",
225
226
  "src/duckdb/extension/icu/./icu-dateadd.cpp",
227
+ "src/duckdb/extension/icu/./icu-table-range.cpp",
226
228
  "src/duckdb/extension/icu/./icu-datetrunc.cpp",
227
229
  "src/duckdb/extension/icu/./icu-strptime.cpp",
228
230
  "src/duckdb/extension/icu/./icu-datefunc.cpp",
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.7.2-dev16.0",
5
+ "version": "0.7.2-dev314.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -13,6 +13,7 @@
13
13
  #include "include/icu-datesub.hpp"
14
14
  #include "include/icu-datetrunc.hpp"
15
15
  #include "include/icu-makedate.hpp"
16
+ #include "include/icu-table-range.hpp"
16
17
  #include "include/icu-strptime.hpp"
17
18
  #include "include/icu-timebucket.hpp"
18
19
  #include "include/icu-timezone.hpp"
@@ -266,6 +267,7 @@ void ICUExtension::Load(DuckDB &db) {
266
267
  RegisterICUDateSubFunctions(*con.context);
267
268
  RegisterICUDateTruncFunctions(*con.context);
268
269
  RegisterICUMakeDateFunctions(*con.context);
270
+ RegisterICUTableRangeFunctions(*con.context);
269
271
  RegisterICUStrptimeFunctions(*con.context);
270
272
  RegisterICUTimeBucketFunctions(*con.context);
271
273
  RegisterICUTimeZoneFunctions(*con.context);
@@ -0,0 +1,194 @@
1
+ #include "duckdb/common/exception.hpp"
2
+ #include "duckdb/common/types/interval.hpp"
3
+ #include "duckdb/common/types/timestamp.hpp"
4
+ #include "duckdb/function/function_set.hpp"
5
+ #include "duckdb/function/table_function.hpp"
6
+ #include "duckdb/parser/parsed_data/create_table_function_info.hpp"
7
+ #include "include/icu-datefunc.hpp"
8
+ #include "unicode/calendar.h"
9
+
10
+ namespace duckdb {
11
+
12
+ struct ICUTableRange {
13
+ using CalendarPtr = unique_ptr<icu::Calendar>;
14
+
15
+ struct BindData : public TableFunctionData {
16
+ explicit BindData(const BindData &other)
17
+ : tz_setting(other.tz_setting), cal_setting(other.cal_setting), calendar(other.calendar->clone()),
18
+ start(other.start), end(other.end), increment(other.increment), inclusive_bound(other.inclusive_bound),
19
+ greater_than_check(other.greater_than_check) {
20
+ }
21
+
22
+ BindData(ClientContext &context) {
23
+ Value tz_value;
24
+ if (context.TryGetCurrentSetting("TimeZone", tz_value)) {
25
+ tz_setting = tz_value.ToString();
26
+ }
27
+ auto tz = icu::TimeZone::createTimeZone(icu::UnicodeString::fromUTF8(icu::StringPiece(tz_setting)));
28
+
29
+ string cal_id("@calendar=");
30
+ Value cal_value;
31
+ if (context.TryGetCurrentSetting("Calendar", cal_value)) {
32
+ cal_setting = cal_value.ToString();
33
+ cal_id += cal_setting;
34
+ } else {
35
+ cal_id += "gregorian";
36
+ }
37
+
38
+ icu::Locale locale(cal_id.c_str());
39
+
40
+ UErrorCode success = U_ZERO_ERROR;
41
+ calendar.reset(icu::Calendar::createInstance(tz, locale, success));
42
+ if (U_FAILURE(success)) {
43
+ throw Exception("Unable to create ICU calendar.");
44
+ }
45
+ }
46
+
47
+ string tz_setting;
48
+ string cal_setting;
49
+ CalendarPtr calendar;
50
+
51
+ timestamp_t start;
52
+ timestamp_t end;
53
+ interval_t increment;
54
+ bool inclusive_bound;
55
+ bool greater_than_check;
56
+
57
+ bool Equals(const FunctionData &other_p) const {
58
+ auto &other = (const BindData &)other_p;
59
+ return other.start == start && other.end == end && other.increment == increment &&
60
+ other.inclusive_bound == inclusive_bound && other.greater_than_check == greater_than_check &&
61
+ *calendar == *other.calendar;
62
+ }
63
+
64
+ unique_ptr<FunctionData> Copy() const {
65
+ return make_unique<BindData>(*this);
66
+ }
67
+
68
+ bool Finished(timestamp_t current_value) {
69
+ if (greater_than_check) {
70
+ if (inclusive_bound) {
71
+ return current_value > end;
72
+ } else {
73
+ return current_value >= end;
74
+ }
75
+ } else {
76
+ if (inclusive_bound) {
77
+ return current_value < end;
78
+ } else {
79
+ return current_value <= end;
80
+ }
81
+ }
82
+ }
83
+ };
84
+
85
+ template <bool GENERATE_SERIES>
86
+ static unique_ptr<FunctionData> Bind(ClientContext &context, TableFunctionBindInput &input,
87
+ vector<LogicalType> &return_types, vector<string> &names) {
88
+ auto result = make_unique<BindData>(context);
89
+
90
+ auto &inputs = input.inputs;
91
+ D_ASSERT(inputs.size() == 3);
92
+ result->start = inputs[0].GetValue<timestamp_t>();
93
+ result->end = inputs[1].GetValue<timestamp_t>();
94
+ result->increment = inputs[2].GetValue<interval_t>();
95
+
96
+ // Infinities either cause errors or infinite loops, so just ban them
97
+ if (!Timestamp::IsFinite(result->start) || !Timestamp::IsFinite(result->end)) {
98
+ throw BinderException("RANGE with infinite bounds is not supported");
99
+ }
100
+
101
+ if (result->increment.months == 0 && result->increment.days == 0 && result->increment.micros == 0) {
102
+ throw BinderException("interval cannot be 0!");
103
+ }
104
+ // all elements should point in the same direction
105
+ if (result->increment.months > 0 || result->increment.days > 0 || result->increment.micros > 0) {
106
+ if (result->increment.months < 0 || result->increment.days < 0 || result->increment.micros < 0) {
107
+ throw BinderException("RANGE with composite interval that has mixed signs is not supported");
108
+ }
109
+ result->greater_than_check = true;
110
+ if (result->start > result->end) {
111
+ throw BinderException(
112
+ "start is bigger than end, but increment is positive: cannot generate infinite series");
113
+ }
114
+ } else {
115
+ result->greater_than_check = false;
116
+ if (result->start < result->end) {
117
+ throw BinderException(
118
+ "start is smaller than end, but increment is negative: cannot generate infinite series");
119
+ }
120
+ }
121
+ return_types.push_back(inputs[0].type());
122
+ if (GENERATE_SERIES) {
123
+ // generate_series has inclusive bounds on the RHS
124
+ result->inclusive_bound = true;
125
+ names.emplace_back("generate_series");
126
+ } else {
127
+ result->inclusive_bound = false;
128
+ names.emplace_back("range");
129
+ }
130
+ return std::move(result);
131
+ }
132
+
133
+ struct State : public GlobalTableFunctionState {
134
+ explicit State(timestamp_t start_p) : current_state(start_p) {
135
+ }
136
+
137
+ timestamp_t current_state;
138
+ bool finished = false;
139
+ };
140
+
141
+ static unique_ptr<GlobalTableFunctionState> Init(ClientContext &context, TableFunctionInitInput &input) {
142
+ auto &bind_data = (BindData &)*input.bind_data;
143
+ return make_unique<State>(bind_data.start);
144
+ }
145
+
146
+ static void ICUTableRangeFunction(ClientContext &context, TableFunctionInput &data_p, DataChunk &output) {
147
+ auto &bind_data = (BindData &)*data_p.bind_data;
148
+ CalendarPtr calendar_ptr(bind_data.calendar->clone());
149
+ auto calendar = calendar_ptr.get();
150
+ auto &state = (State &)*data_p.global_state;
151
+ if (state.finished) {
152
+ return;
153
+ }
154
+
155
+ idx_t size = 0;
156
+ auto data = FlatVector::GetData<timestamp_t>(output.data[0]);
157
+ while (true) {
158
+ data[size++] = state.current_state;
159
+ state.current_state = ICUDateFunc::Add(calendar, state.current_state, bind_data.increment);
160
+ if (bind_data.Finished(state.current_state)) {
161
+ state.finished = true;
162
+ break;
163
+ }
164
+ if (size >= STANDARD_VECTOR_SIZE) {
165
+ break;
166
+ }
167
+ }
168
+ output.SetCardinality(size);
169
+ }
170
+
171
+ static void AddICUTableRangeFunction(ClientContext &context) {
172
+ auto &catalog = Catalog::GetSystemCatalog(context);
173
+
174
+ TableFunctionSet range("range");
175
+ range.AddFunction(TableFunction({LogicalType::TIMESTAMP_TZ, LogicalType::TIMESTAMP_TZ, LogicalType::INTERVAL},
176
+ ICUTableRangeFunction, Bind<false>, Init));
177
+ CreateTableFunctionInfo range_func_info(range);
178
+ catalog.AddFunction(context, &range_func_info);
179
+
180
+ // generate_series: similar to range, but inclusive instead of exclusive bounds on the RHS
181
+ TableFunctionSet generate_series("generate_series");
182
+ generate_series.AddFunction(
183
+ TableFunction({LogicalType::TIMESTAMP_TZ, LogicalType::TIMESTAMP_TZ, LogicalType::INTERVAL},
184
+ ICUTableRangeFunction, Bind<true>, Init));
185
+ CreateTableFunctionInfo generate_series_func_info(generate_series);
186
+ catalog.AddFunction(context, &generate_series_func_info);
187
+ }
188
+ };
189
+
190
+ void RegisterICUTableRangeFunctions(ClientContext &context) {
191
+ ICUTableRange::AddICUTableRangeFunction(context);
192
+ }
193
+
194
+ } // namespace duckdb
@@ -0,0 +1,17 @@
1
+ //===----------------------------------------------------------------------===//
2
+ // DuckDB
3
+ //
4
+ // icu-table-range.hpp
5
+ //
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #pragma once
10
+
11
+ #include "duckdb.hpp"
12
+
13
+ namespace duckdb {
14
+
15
+ void RegisterICUTableRangeFunctions(ClientContext &context);
16
+
17
+ } // namespace duckdb
@@ -865,7 +865,7 @@ RowNumberColumnReader::RowNumberColumnReader(ParquetReader &reader, LogicalType
865
865
 
866
866
  unique_ptr<BaseStatistics> RowNumberColumnReader::Stats(idx_t row_group_idx_p,
867
867
  const std::vector<ColumnChunk> &columns) {
868
- auto stats = make_unique<NumericStatistics>(type, StatisticsType::LOCAL_STATS);
868
+ auto stats = NumericStats::CreateUnknown(type);
869
869
  auto &row_groups = reader.GetFileMetadata()->row_groups;
870
870
  D_ASSERT(row_group_idx_p < row_groups.size());
871
871
  idx_t row_group_offset_min = 0;
@@ -873,11 +873,10 @@ unique_ptr<BaseStatistics> RowNumberColumnReader::Stats(idx_t row_group_idx_p,
873
873
  row_group_offset_min += row_groups[i].num_rows;
874
874
  }
875
875
 
876
- stats->min = Value::BIGINT(row_group_offset_min);
877
- stats->max = Value::BIGINT(row_group_offset_min + row_groups[row_group_idx_p].num_rows);
878
-
879
- D_ASSERT(!stats->CanHaveNull() && stats->CanHaveNoNull());
880
- return std::move(stats);
876
+ NumericStats::SetMin(stats, Value::BIGINT(row_group_offset_min));
877
+ NumericStats::SetMax(stats, Value::BIGINT(row_group_offset_min + row_groups[row_group_idx_p].num_rows));
878
+ stats.Set(StatsInfo::CANNOT_HAVE_NULL_VALUES);
879
+ return stats.ToUnique();
881
880
  }
882
881
 
883
882
  void RowNumberColumnReader::InitializeRead(idx_t row_group_idx_p, const std::vector<ColumnChunk> &columns,
@@ -1994,7 +1994,6 @@ unique_ptr<ColumnWriter> ColumnWriter::CreateWriterRecursive(vector<duckdb_parqu
1994
1994
  max_define, can_have_nulls);
1995
1995
  }
1996
1996
  case LogicalTypeId::BLOB:
1997
- case LogicalTypeId::BIT:
1998
1997
  case LogicalTypeId::VARCHAR:
1999
1998
  return make_unique<StringColumnWriter>(writer, schema_idx, std::move(schema_path), max_repeat, max_define,
2000
1999
  can_have_nulls);
@@ -18,8 +18,7 @@
18
18
 
19
19
  #include "duckdb.hpp"
20
20
  #ifndef DUCKDB_AMALGAMATION
21
- #include "duckdb/storage/statistics/string_statistics.hpp"
22
- #include "duckdb/storage/statistics/numeric_statistics.hpp"
21
+
23
22
  #include "duckdb/common/types/vector.hpp"
24
23
  #include "duckdb/common/types/string_type.hpp"
25
24
  #include "duckdb/common/types/chunk_collection.hpp"
@@ -29,17 +29,7 @@ public:
29
29
  Vector &result) override;
30
30
 
31
31
  unique_ptr<BaseStatistics> Stats(idx_t row_group_idx_p, const std::vector<ColumnChunk> &columns) override {
32
- switch (type.id()) {
33
- case LogicalTypeId::VARCHAR: {
34
- auto string_stats = make_unique<StringStatistics>(type, StatisticsType::LOCAL_STATS);
35
- string string = constant.ToString();
36
- string_stats->Update(string);
37
- string_stats->max_string_length = string.length();
38
- return std::move(string_stats);
39
- }
40
- default:
41
- return nullptr;
42
- }
32
+ return BaseStatistics::FromConstant(constant).ToUnique();
43
33
  };
44
34
 
45
35
  void InitializeRead(idx_t row_group_idx_p, const std::vector<ColumnChunk> &columns,
@@ -368,7 +368,10 @@ public:
368
368
  if (!config.options.enable_external_access) {
369
369
  throw PermissionException("Scanning Parquet files is disabled through configuration");
370
370
  }
371
- auto file_name = input.inputs[0].GetValue<string>();
371
+ if (input.inputs[0].IsNull()) {
372
+ throw ParserException("Parquet reader cannot take NULL list as parameter");
373
+ }
374
+ auto file_name = StringValue::Get(input.inputs[0]);
372
375
  ParquetOptions parquet_options(context);
373
376
  for (auto &kv : input.named_parameters) {
374
377
  auto loption = StringUtil::Lower(kv.first);
@@ -395,10 +398,16 @@ public:
395
398
  if (!config.options.enable_external_access) {
396
399
  throw PermissionException("Scanning Parquet files is disabled through configuration");
397
400
  }
401
+ if (input.inputs[0].IsNull()) {
402
+ throw ParserException("Parquet reader cannot take NULL list as parameter");
403
+ }
398
404
  FileSystem &fs = FileSystem::GetFileSystem(context);
399
405
  vector<string> files;
400
406
  for (auto &val : ListValue::GetChildren(input.inputs[0])) {
401
- auto glob_files = ParquetGlob(fs, val.ToString(), context);
407
+ if (val.IsNull()) {
408
+ throw ParserException("Parquet reader cannot take NULL input as parameter");
409
+ }
410
+ auto glob_files = ParquetGlob(fs, StringValue::Get(val), context);
402
411
  files.insert(files.end(), glob_files.begin(), glob_files.end());
403
412
  }
404
413
  if (files.empty()) {
@@ -6,8 +6,7 @@
6
6
  #ifndef DUCKDB_AMALGAMATION
7
7
  #include "duckdb/common/types/blob.hpp"
8
8
  #include "duckdb/common/types/value.hpp"
9
- #include "duckdb/storage/statistics/numeric_statistics.hpp"
10
- #include "duckdb/storage/statistics/string_statistics.hpp"
9
+
11
10
  #endif
12
11
 
13
12
  namespace duckdb {
@@ -18,27 +17,29 @@ using duckdb_parquet::format::Type;
18
17
  static unique_ptr<BaseStatistics> CreateNumericStats(const LogicalType &type,
19
18
  const duckdb_parquet::format::SchemaElement &schema_ele,
20
19
  const duckdb_parquet::format::Statistics &parquet_stats) {
21
- auto stats = make_unique<NumericStatistics>(type, StatisticsType::LOCAL_STATS);
20
+ auto stats = NumericStats::CreateUnknown(type);
22
21
 
23
22
  // for reasons unknown to science, Parquet defines *both* `min` and `min_value` as well as `max` and
24
23
  // `max_value`. All are optional. such elegance.
24
+ Value min;
25
+ Value max;
25
26
  if (parquet_stats.__isset.min) {
26
- stats->min = ParquetStatisticsUtils::ConvertValue(type, schema_ele, parquet_stats.min).DefaultCastAs(type);
27
+ min = ParquetStatisticsUtils::ConvertValue(type, schema_ele, parquet_stats.min).DefaultCastAs(type);
27
28
  } else if (parquet_stats.__isset.min_value) {
28
- stats->min =
29
- ParquetStatisticsUtils::ConvertValue(type, schema_ele, parquet_stats.min_value).DefaultCastAs(type);
29
+ min = ParquetStatisticsUtils::ConvertValue(type, schema_ele, parquet_stats.min_value).DefaultCastAs(type);
30
30
  } else {
31
- stats->min = Value(type);
31
+ min = Value(type);
32
32
  }
33
33
  if (parquet_stats.__isset.max) {
34
- stats->max = ParquetStatisticsUtils::ConvertValue(type, schema_ele, parquet_stats.max).DefaultCastAs(type);
34
+ max = ParquetStatisticsUtils::ConvertValue(type, schema_ele, parquet_stats.max).DefaultCastAs(type);
35
35
  } else if (parquet_stats.__isset.max_value) {
36
- stats->max =
37
- ParquetStatisticsUtils::ConvertValue(type, schema_ele, parquet_stats.max_value).DefaultCastAs(type);
36
+ max = ParquetStatisticsUtils::ConvertValue(type, schema_ele, parquet_stats.max_value).DefaultCastAs(type);
38
37
  } else {
39
- stats->max = Value(type);
38
+ max = Value(type);
40
39
  }
41
- return std::move(stats);
40
+ NumericStats::SetMin(stats, min);
41
+ NumericStats::SetMax(stats, max);
42
+ return stats.ToUnique();
42
43
  }
43
44
 
44
45
  Value ParquetStatisticsUtils::ConvertValue(const LogicalType &type,
@@ -228,24 +229,24 @@ unique_ptr<BaseStatistics> ParquetStatisticsUtils::TransformColumnStatistics(con
228
229
  row_group_stats = CreateNumericStats(type, s_ele, parquet_stats);
229
230
  break;
230
231
  case LogicalTypeId::VARCHAR: {
231
- auto string_stats = make_unique<StringStatistics>(type, StatisticsType::LOCAL_STATS);
232
+ auto string_stats = StringStats::CreateEmpty(type);
232
233
  if (parquet_stats.__isset.min) {
233
- string_stats->Update(parquet_stats.min);
234
+ StringStats::Update(string_stats, parquet_stats.min);
234
235
  } else if (parquet_stats.__isset.min_value) {
235
- string_stats->Update(parquet_stats.min_value);
236
+ StringStats::Update(string_stats, parquet_stats.min_value);
236
237
  } else {
237
238
  return nullptr;
238
239
  }
239
240
  if (parquet_stats.__isset.max) {
240
- string_stats->Update(parquet_stats.max);
241
+ StringStats::Update(string_stats, parquet_stats.max);
241
242
  } else if (parquet_stats.__isset.max_value) {
242
- string_stats->Update(parquet_stats.max_value);
243
+ StringStats::Update(string_stats, parquet_stats.max_value);
243
244
  } else {
244
245
  return nullptr;
245
246
  }
246
- string_stats->has_unicode = true; // we dont know better
247
- string_stats->max_string_length = NumericLimits<uint32_t>::Maximum();
248
- row_group_stats = std::move(string_stats);
247
+ StringStats::SetContainsUnicode(string_stats);
248
+ StringStats::ResetMaxStringLength(string_stats);
249
+ row_group_stats = string_stats.ToUnique();
249
250
  break;
250
251
  }
251
252
  default:
@@ -254,21 +255,14 @@ unique_ptr<BaseStatistics> ParquetStatisticsUtils::TransformColumnStatistics(con
254
255
  } // end of type switch
255
256
 
256
257
  // null count is generic
257
- if (row_group_stats) {
258
- if (column_chunk.meta_data.type == duckdb_parquet::format::Type::FLOAT ||
259
- column_chunk.meta_data.type == duckdb_parquet::format::Type::DOUBLE) {
260
- // floats/doubles can have infinity, which can become NULL
261
- row_group_stats->validity_stats = make_unique<ValidityStatistics>(true);
262
- } else if (parquet_stats.__isset.null_count) {
263
- row_group_stats->validity_stats = make_unique<ValidityStatistics>(parquet_stats.null_count != 0);
264
- } else {
265
- row_group_stats->validity_stats = make_unique<ValidityStatistics>(true);
266
- }
267
- } else {
258
+ if (!row_group_stats) {
268
259
  // if stats are missing from any row group we know squat
269
260
  return nullptr;
270
261
  }
271
-
262
+ row_group_stats->Set(StatsInfo::CAN_HAVE_NULL_AND_VALID_VALUES);
263
+ if (parquet_stats.__isset.null_count && parquet_stats.null_count == 0) {
264
+ row_group_stats->Set(StatsInfo::CANNOT_HAVE_NULL_VALUES);
265
+ }
272
266
  return row_group_stats;
273
267
  }
274
268
 
@@ -145,6 +145,10 @@ CatalogEntry *DuckSchemaEntry::CreateFunction(CatalogTransaction transaction, Cr
145
145
  function = make_unique_base<StandardEntry, ScalarFunctionCatalogEntry>(catalog, this,
146
146
  (CreateScalarFunctionInfo *)info);
147
147
  break;
148
+ case CatalogType::TABLE_FUNCTION_ENTRY:
149
+ function =
150
+ make_unique_base<StandardEntry, TableFunctionCatalogEntry>(catalog, this, (CreateTableFunctionInfo *)info);
151
+ break;
148
152
  case CatalogType::MACRO_ENTRY:
149
153
  // create a macro function
150
154
  function = make_unique_base<StandardEntry, ScalarMacroCatalogEntry>(catalog, this, (CreateMacroInfo *)info);
@@ -1,5 +1,5 @@
1
1
  #include "duckdb/catalog/catalog_entry/scalar_function_catalog_entry.hpp"
2
- #include "duckdb/parser/parsed_data/alter_function_info.hpp"
2
+ #include "duckdb/parser/parsed_data/alter_scalar_function_info.hpp"
3
3
 
4
4
  namespace duckdb {
5
5
 
@@ -9,14 +9,15 @@ ScalarFunctionCatalogEntry::ScalarFunctionCatalogEntry(Catalog *catalog, SchemaC
9
9
  }
10
10
 
11
11
  unique_ptr<CatalogEntry> ScalarFunctionCatalogEntry::AlterEntry(ClientContext &context, AlterInfo *info) {
12
- if (info->type != AlterType::ALTER_FUNCTION) {
12
+ if (info->type != AlterType::ALTER_SCALAR_FUNCTION) {
13
13
  throw InternalException("Attempting to alter ScalarFunctionCatalogEntry with unsupported alter type");
14
14
  }
15
- auto &function_info = (AlterFunctionInfo &)*info;
16
- if (function_info.alter_function_type != AlterFunctionType::ADD_FUNCTION_OVERLOADS) {
17
- throw InternalException("Attempting to alter ScalarFunctionCatalogEntry with unsupported alter function type");
15
+ auto &function_info = (AlterScalarFunctionInfo &)*info;
16
+ if (function_info.alter_scalar_function_type != AlterScalarFunctionType::ADD_FUNCTION_OVERLOADS) {
17
+ throw InternalException(
18
+ "Attempting to alter ScalarFunctionCatalogEntry with unsupported alter scalar function type");
18
19
  }
19
- auto &add_overloads = (AddFunctionOverloadInfo &)function_info;
20
+ auto &add_overloads = (AddScalarFunctionOverloadInfo &)function_info;
20
21
 
21
22
  ScalarFunctionSet new_set = functions;
22
23
  if (!new_set.MergeFunctionSet(add_overloads.new_overloads)) {
@@ -1,5 +1,5 @@
1
1
  #include "duckdb/catalog/catalog_entry/table_function_catalog_entry.hpp"
2
- #include "duckdb/parser/parsed_data/create_table_function_info.hpp"
2
+ #include "duckdb/parser/parsed_data/alter_table_function_info.hpp"
3
3
 
4
4
  namespace duckdb {
5
5
 
@@ -10,4 +10,23 @@ TableFunctionCatalogEntry::TableFunctionCatalogEntry(Catalog *catalog, SchemaCat
10
10
  D_ASSERT(this->functions.Size() > 0);
11
11
  }
12
12
 
13
+ unique_ptr<CatalogEntry> TableFunctionCatalogEntry::AlterEntry(ClientContext &context, AlterInfo *info) {
14
+ if (info->type != AlterType::ALTER_TABLE_FUNCTION) {
15
+ throw InternalException("Attempting to alter TableFunctionCatalogEntry with unsupported alter type");
16
+ }
17
+ auto &function_info = (AlterTableFunctionInfo &)*info;
18
+ if (function_info.alter_table_function_type != AlterTableFunctionType::ADD_FUNCTION_OVERLOADS) {
19
+ throw InternalException(
20
+ "Attempting to alter TableFunctionCatalogEntry with unsupported alter table function type");
21
+ }
22
+ auto &add_overloads = (AddTableFunctionOverloadInfo &)function_info;
23
+
24
+ TableFunctionSet new_set = functions;
25
+ if (!new_set.MergeFunctionSet(add_overloads.new_overloads)) {
26
+ throw BinderException("Failed to add new function overloads to function \"%s\": function already exists", name);
27
+ }
28
+ CreateTableFunctionInfo new_info(std::move(new_set));
29
+ return make_unique<TableFunctionCatalogEntry>(catalog, schema, &new_info);
30
+ }
31
+
13
32
  } // namespace duckdb
@@ -59,6 +59,8 @@ string StatementTypeToString(StatementType type) {
59
59
  return "ATTACH";
60
60
  case StatementType::DETACH_STATEMENT:
61
61
  return "DETACH";
62
+ case StatementType::MULTI_STATEMENT:
63
+ return "MULTI";
62
64
  case StatementType::INVALID_STATEMENT:
63
65
  break;
64
66
  }
@@ -3,7 +3,6 @@
3
3
  #include "duckdb/common/row_operations/row_operations.hpp"
4
4
  #include "duckdb/common/sort/sort.hpp"
5
5
  #include "duckdb/common/sort/sorted_block.hpp"
6
- #include "duckdb/storage/statistics/string_statistics.hpp"
7
6
 
8
7
  #include <algorithm>
9
8
  #include <numeric>
@@ -66,9 +65,8 @@ SortLayout::SortLayout(const vector<BoundOrderByNode> &orders)
66
65
  prefix_lengths.back() = GetNestedSortingColSize(col_size, expr.return_type);
67
66
  } else if (physical_type == PhysicalType::VARCHAR) {
68
67
  idx_t size_before = col_size;
69
- if (stats.back()) {
70
- auto &str_stats = (StringStatistics &)*stats.back();
71
- col_size += str_stats.max_string_length;
68
+ if (stats.back() && StringStats::HasMaxStringLength(*stats.back())) {
69
+ col_size += StringStats::MaxStringLength(*stats.back());
72
70
  if (col_size > 12) {
73
71
  col_size = 12;
74
72
  } else {
@@ -95,9 +93,9 @@ SortLayout::SortLayout(const vector<BoundOrderByNode> &orders)
95
93
  if (bytes_to_fill == 0) {
96
94
  break;
97
95
  }
98
- if (logical_types[col_idx].InternalType() == PhysicalType::VARCHAR && stats[col_idx]) {
99
- auto &str_stats = (StringStatistics &)*stats[col_idx];
100
- idx_t diff = str_stats.max_string_length - prefix_lengths[col_idx];
96
+ if (logical_types[col_idx].InternalType() == PhysicalType::VARCHAR && stats[col_idx] &&
97
+ StringStats::HasMaxStringLength(*stats[col_idx])) {
98
+ idx_t diff = StringStats::MaxStringLength(*stats[col_idx]) - prefix_lengths[col_idx];
101
99
  if (diff > 0) {
102
100
  // Increase all sizes accordingly
103
101
  idx_t increase = MinValue(bytes_to_fill, diff);