duckdb 0.8.2-dev1862.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 (283) hide show
  1. package/binding.gyp +9 -9
  2. package/package.json +1 -1
  3. package/src/duckdb/src/catalog/catalog.cpp +1 -1
  4. package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +17 -41
  5. package/src/duckdb/src/catalog/catalog_entry/macro_catalog_entry.cpp +2 -10
  6. package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +4 -14
  7. package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +11 -28
  8. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +11 -38
  9. package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +11 -27
  10. package/src/duckdb/src/catalog/catalog_entry.cpp +25 -1
  11. package/src/duckdb/src/common/enum_util.cpp +187 -0
  12. package/src/duckdb/src/common/extra_type_info.cpp +1 -2
  13. package/src/duckdb/src/common/serializer/binary_deserializer.cpp +3 -0
  14. package/src/duckdb/src/common/serializer/binary_serializer.cpp +4 -4
  15. package/src/duckdb/src/common/types/column/column_data_collection.cpp +43 -0
  16. package/src/duckdb/src/common/types/hugeint.cpp +40 -0
  17. package/src/duckdb/src/common/types/vector.cpp +1 -1
  18. package/src/duckdb/src/common/types.cpp +0 -12
  19. package/src/duckdb/src/core_functions/function_list.cpp +1 -0
  20. package/src/duckdb/src/core_functions/scalar/string/to_base.cpp +66 -0
  21. package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +14 -11
  22. package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +6 -4
  23. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +14 -12
  24. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +6 -4
  25. package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +8 -6
  26. package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +2 -2
  27. package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +5 -3
  28. package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +7 -5
  29. package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +7 -5
  30. package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +5 -4
  31. package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +2 -2
  32. package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +13 -6
  33. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +7 -5
  34. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +7 -5
  35. package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +7 -4
  36. package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +8 -6
  37. package/src/duckdb/src/execution/operator/order/physical_order.cpp +7 -5
  38. package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +7 -5
  39. package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +8 -6
  40. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +8 -7
  41. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +8 -6
  42. package/src/duckdb/src/execution/operator/persistent/physical_fixed_batch_copy.cpp +11 -9
  43. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +10 -10
  44. package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +4 -2
  45. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +7 -6
  46. package/src/duckdb/src/execution/physical_operator.cpp +3 -2
  47. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +1 -1
  48. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  49. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -2
  50. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +1 -4
  51. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +2 -5
  52. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +1 -6
  53. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +2 -11
  54. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +2 -5
  55. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +14 -0
  56. package/src/duckdb/src/include/duckdb/common/bitpacking.hpp +70 -55
  57. package/src/duckdb/src/include/duckdb/common/constants.hpp +2 -0
  58. package/src/duckdb/src/include/duckdb/common/enum_util.hpp +40 -0
  59. package/src/duckdb/src/include/duckdb/common/enums/index_type.hpp +1 -1
  60. package/src/duckdb/src/include/duckdb/common/enums/operator_result_type.hpp +5 -1
  61. package/src/duckdb/src/include/duckdb/common/hugeint.hpp +15 -0
  62. package/src/duckdb/src/include/duckdb/common/index_vector.hpp +12 -0
  63. package/src/duckdb/src/include/duckdb/common/limits.hpp +52 -149
  64. package/src/duckdb/src/include/duckdb/common/numeric_utils.hpp +48 -0
  65. package/src/duckdb/src/include/duckdb/common/serializer/binary_deserializer.hpp +28 -4
  66. package/src/duckdb/src/include/duckdb/common/serializer/binary_serializer.hpp +12 -5
  67. package/src/duckdb/src/include/duckdb/common/serializer/deserialization_data.hpp +110 -0
  68. package/src/duckdb/src/include/duckdb/common/serializer/format_deserializer.hpp +46 -1
  69. package/src/duckdb/src/include/duckdb/common/serializer/format_serializer.hpp +23 -21
  70. package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +12 -4
  71. package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection.hpp +3 -0
  72. package/src/duckdb/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp +1 -1
  73. package/src/duckdb/src/include/duckdb/core_functions/scalar/operators_functions.hpp +1 -1
  74. package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +9 -0
  75. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +3 -3
  76. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +1 -1
  77. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +3 -3
  78. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +2 -2
  79. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +2 -2
  80. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +1 -1
  81. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +1 -1
  82. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +1 -1
  83. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +2 -2
  84. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +2 -2
  85. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +1 -1
  86. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +2 -2
  87. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +2 -2
  88. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +2 -2
  89. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_nested_loop_join.hpp +2 -2
  90. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +2 -2
  91. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +2 -2
  92. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +2 -2
  93. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_copy_to_file.hpp +2 -2
  94. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +2 -2
  95. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +2 -2
  96. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_fixed_batch_copy.hpp +2 -2
  97. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -2
  98. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +1 -1
  99. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +2 -2
  100. package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +3 -3
  101. package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +11 -0
  102. package/src/duckdb/src/include/duckdb/function/macro_function.hpp +3 -0
  103. package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +3 -0
  104. package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +3 -0
  105. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +3 -0
  106. package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +0 -3
  107. package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +3 -2
  108. package/src/duckdb/src/include/duckdb/parser/column_definition.hpp +6 -5
  109. package/src/duckdb/src/include/duckdb/parser/column_list.hpp +4 -0
  110. package/src/duckdb/src/include/duckdb/parser/constraint.hpp +5 -0
  111. package/src/duckdb/src/include/duckdb/parser/constraints/check_constraint.hpp +3 -0
  112. package/src/duckdb/src/include/duckdb/parser/constraints/foreign_key_constraint.hpp +6 -0
  113. package/src/duckdb/src/include/duckdb/parser/constraints/not_null_constraint.hpp +3 -0
  114. package/src/duckdb/src/include/duckdb/parser/constraints/unique_constraint.hpp +6 -0
  115. package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +1 -1
  116. package/src/duckdb/src/include/duckdb/parser/expression/case_expression.hpp +1 -1
  117. package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +1 -1
  118. package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +1 -1
  119. package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +1 -1
  120. package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +1 -1
  121. package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +1 -1
  122. package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +1 -1
  123. package/src/duckdb/src/include/duckdb/parser/expression/default_expression.hpp +1 -1
  124. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +1 -1
  125. package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +1 -1
  126. package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +1 -1
  127. package/src/duckdb/src/include/duckdb/parser/expression/parameter_expression.hpp +1 -1
  128. package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +1 -1
  129. package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +1 -1
  130. package/src/duckdb/src/include/duckdb/parser/expression/subquery_expression.hpp +1 -1
  131. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +1 -1
  132. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +12 -1
  133. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +66 -2
  134. package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +8 -1
  135. package/src/duckdb/src/include/duckdb/parser/parsed_data/copy_info.hpp +8 -1
  136. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +4 -1
  137. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_info.hpp +9 -2
  138. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +3 -0
  139. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_schema_info.hpp +3 -0
  140. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_sequence_info.hpp +3 -0
  141. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_table_info.hpp +3 -0
  142. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_type_info.hpp +3 -0
  143. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +3 -0
  144. package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +7 -0
  145. package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +7 -0
  146. package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +7 -0
  147. package/src/duckdb/src/include/duckdb/parser/parsed_data/load_info.hpp +13 -3
  148. package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +22 -0
  149. package/src/duckdb/src/include/duckdb/parser/parsed_data/pragma_info.hpp +10 -0
  150. package/src/duckdb/src/include/duckdb/parser/parsed_data/show_select_info.hpp +7 -0
  151. package/src/duckdb/src/include/duckdb/parser/parsed_data/transaction_info.hpp +10 -0
  152. package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +10 -0
  153. package/src/duckdb/src/include/duckdb/planner/bound_constraint.hpp +0 -8
  154. package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +6 -0
  155. package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +5 -0
  156. package/src/duckdb/src/include/duckdb/planner/expression/bound_between_expression.hpp +6 -0
  157. package/src/duckdb/src/include/duckdb/planner/expression/bound_case_expression.hpp +6 -0
  158. package/src/duckdb/src/include/duckdb/planner/expression/bound_cast_expression.hpp +6 -0
  159. package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +3 -0
  160. package/src/duckdb/src/include/duckdb/planner/expression/bound_comparison_expression.hpp +3 -0
  161. package/src/duckdb/src/include/duckdb/planner/expression/bound_conjunction_expression.hpp +3 -0
  162. package/src/duckdb/src/include/duckdb/planner/expression/bound_constant_expression.hpp +3 -0
  163. package/src/duckdb/src/include/duckdb/planner/expression/bound_default_expression.hpp +3 -0
  164. package/src/duckdb/src/include/duckdb/planner/expression/bound_lambda_expression.hpp +3 -1
  165. package/src/duckdb/src/include/duckdb/planner/expression/bound_lambdaref_expression.hpp +3 -0
  166. package/src/duckdb/src/include/duckdb/planner/expression/bound_operator_expression.hpp +3 -0
  167. package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_data.hpp +5 -2
  168. package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_expression.hpp +7 -0
  169. package/src/duckdb/src/include/duckdb/planner/expression/bound_reference_expression.hpp +3 -0
  170. package/src/duckdb/src/include/duckdb/planner/expression/bound_unnest_expression.hpp +3 -0
  171. package/src/duckdb/src/include/duckdb/planner/expression/list.hpp +1 -0
  172. package/src/duckdb/src/include/duckdb/planner/expression.hpp +3 -0
  173. package/src/duckdb/src/include/duckdb/planner/joinside.hpp +3 -0
  174. package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +3 -0
  175. package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +3 -0
  176. package/src/duckdb/src/include/duckdb/planner/operator/logical_any_join.hpp +3 -0
  177. package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +4 -0
  178. package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +9 -2
  179. package/src/duckdb/src/include/duckdb/planner/operator/logical_create.hpp +9 -6
  180. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_index.hpp +2 -16
  181. package/src/duckdb/src/include/duckdb/planner/operator/logical_create_table.hpp +10 -6
  182. package/src/duckdb/src/include/duckdb/planner/operator/logical_cross_product.hpp +3 -0
  183. package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +2 -0
  184. package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +7 -0
  185. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +3 -0
  186. package/src/duckdb/src/include/duckdb/planner/operator/logical_distinct.hpp +6 -10
  187. package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +2 -0
  188. package/src/duckdb/src/include/duckdb/planner/operator/logical_empty_result.hpp +2 -0
  189. package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +4 -0
  190. package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +3 -0
  191. package/src/duckdb/src/include/duckdb/planner/operator/logical_filter.hpp +3 -0
  192. package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +6 -0
  193. package/src/duckdb/src/include/duckdb/planner/operator/logical_limit.hpp +3 -0
  194. package/src/duckdb/src/include/duckdb/planner/operator/logical_limit_percent.hpp +3 -0
  195. package/src/duckdb/src/include/duckdb/planner/operator/logical_materialized_cte.hpp +5 -2
  196. package/src/duckdb/src/include/duckdb/planner/operator/logical_order.hpp +7 -35
  197. package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +6 -0
  198. package/src/duckdb/src/include/duckdb/planner/operator/logical_positional_join.hpp +3 -0
  199. package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +3 -0
  200. package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +5 -3
  201. package/src/duckdb/src/include/duckdb/planner/operator/logical_reset.hpp +4 -0
  202. package/src/duckdb/src/include/duckdb/planner/operator/logical_sample.hpp +6 -0
  203. package/src/duckdb/src/include/duckdb/planner/operator/logical_set.hpp +4 -0
  204. package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +4 -0
  205. package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +3 -0
  206. package/src/duckdb/src/include/duckdb/planner/operator/logical_simple.hpp +3 -0
  207. package/src/duckdb/src/include/duckdb/planner/operator/logical_top_n.hpp +4 -0
  208. package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +2 -0
  209. package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +6 -0
  210. package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +3 -0
  211. package/src/duckdb/src/include/duckdb/planner/tableref/bound_pivotref.hpp +3 -0
  212. package/src/duckdb/src/main/relation/join_relation.cpp +1 -1
  213. package/src/duckdb/src/optimizer/deliminator.cpp +5 -3
  214. package/src/duckdb/src/parallel/pipeline.cpp +0 -17
  215. package/src/duckdb/src/parallel/pipeline_executor.cpp +26 -7
  216. package/src/duckdb/src/parallel/pipeline_finish_event.cpp +55 -1
  217. package/src/duckdb/src/parser/column_definition.cpp +20 -32
  218. package/src/duckdb/src/parser/column_list.cpp +8 -0
  219. package/src/duckdb/src/parser/constraints/foreign_key_constraint.cpp +3 -0
  220. package/src/duckdb/src/parser/constraints/unique_constraint.cpp +3 -0
  221. package/src/duckdb/src/parser/expression/case_expression.cpp +0 -12
  222. package/src/duckdb/src/parser/parsed_data/alter_info.cpp +5 -2
  223. package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +38 -0
  224. package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +3 -1
  225. package/src/duckdb/src/parser/parsed_data/create_sequence_info.cpp +2 -0
  226. package/src/duckdb/src/parser/parsed_data/detach_info.cpp +1 -1
  227. package/src/duckdb/src/parser/parsed_data/drop_info.cpp +1 -1
  228. package/src/duckdb/src/parser/parsed_data/sample_options.cpp +0 -18
  229. package/src/duckdb/src/parser/parsed_data/transaction_info.cpp +4 -1
  230. package/src/duckdb/src/parser/parsed_data/vacuum_info.cpp +1 -1
  231. package/src/duckdb/src/parser/query_node.cpp +0 -10
  232. package/src/duckdb/src/parser/result_modifier.cpp +0 -13
  233. package/src/duckdb/src/parser/statement/select_statement.cpp +0 -10
  234. package/src/duckdb/src/parser/tableref/pivotref.cpp +0 -16
  235. package/src/duckdb/src/parser/transform/statement/transform_create_index.cpp +5 -4
  236. package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +1 -1
  237. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +6 -1
  238. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +13 -3
  239. package/src/duckdb/src/planner/expression/bound_between_expression.cpp +4 -0
  240. package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +13 -6
  241. package/src/duckdb/src/planner/expression/bound_parameter_expression.cpp +20 -12
  242. package/src/duckdb/src/planner/logical_operator.cpp +13 -1
  243. package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +16 -2
  244. package/src/duckdb/src/planner/operator/logical_create.cpp +14 -0
  245. package/src/duckdb/src/planner/operator/logical_create_index.cpp +20 -0
  246. package/src/duckdb/src/planner/operator/logical_create_table.cpp +16 -0
  247. package/src/duckdb/src/planner/operator/logical_delete.cpp +9 -2
  248. package/src/duckdb/src/planner/operator/logical_delim_join.cpp +2 -4
  249. package/src/duckdb/src/planner/operator/logical_distinct.cpp +13 -0
  250. package/src/duckdb/src/planner/operator/logical_explain.cpp +1 -1
  251. package/src/duckdb/src/planner/operator/logical_insert.cpp +8 -2
  252. package/src/duckdb/src/planner/operator/logical_materialized_cte.cpp +3 -2
  253. package/src/duckdb/src/planner/operator/logical_order.cpp +39 -0
  254. package/src/duckdb/src/planner/operator/logical_pivot.cpp +3 -0
  255. package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +5 -5
  256. package/src/duckdb/src/planner/operator/logical_sample.cpp +3 -0
  257. package/src/duckdb/src/planner/operator/logical_update.cpp +8 -2
  258. package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +4 -2
  259. package/src/duckdb/src/planner/planner.cpp +11 -0
  260. package/src/duckdb/src/storage/checkpoint_manager.cpp +23 -23
  261. package/src/duckdb/src/storage/compression/bitpacking.cpp +87 -63
  262. package/src/duckdb/src/storage/compression/bitpacking_hugeint.cpp +295 -0
  263. package/src/duckdb/src/storage/serialization/serialize_constraint.cpp +98 -0
  264. package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +188 -0
  265. package/src/duckdb/src/storage/serialization/serialize_expression.cpp +274 -0
  266. package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +729 -0
  267. package/src/duckdb/src/storage/serialization/serialize_macro_function.cpp +62 -0
  268. package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +242 -0
  269. package/src/duckdb/src/storage/serialization/serialize_parse_info.cpp +419 -0
  270. package/src/duckdb/src/storage/serialization/serialize_parsed_expression.cpp +40 -38
  271. package/src/duckdb/src/storage/serialization/serialize_query_node.cpp +36 -36
  272. package/src/duckdb/src/storage/serialization/serialize_result_modifier.cpp +25 -14
  273. package/src/duckdb/src/storage/serialization/serialize_statement.cpp +22 -0
  274. package/src/duckdb/src/storage/serialization/serialize_tableref.cpp +47 -47
  275. package/src/duckdb/src/storage/serialization/serialize_types.cpp +25 -25
  276. package/src/duckdb/src/storage/storage_info.cpp +3 -2
  277. package/src/duckdb/src/storage/wal_replay.cpp +20 -19
  278. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +6 -6
  279. package/src/duckdb/ub_src_core_functions_scalar_string.cpp +2 -0
  280. package/src/duckdb/ub_src_parser.cpp +0 -2
  281. package/src/duckdb/ub_src_storage_compression.cpp +2 -0
  282. package/src/duckdb/ub_src_storage_serialization.cpp +16 -0
  283. package/src/duckdb/src/parser/common_table_expression_info.cpp +0 -21
@@ -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
@@ -1,6 +1,7 @@
1
1
  #include "duckdb/common/types/hugeint.hpp"
2
2
  #include "duckdb/common/exception.hpp"
3
3
  #include "duckdb/common/algorithm.hpp"
4
+ #include "duckdb/common/hugeint.hpp"
4
5
  #include "duckdb/common/limits.hpp"
5
6
  #include "duckdb/common/windows_undefs.hpp"
6
7
  #include "duckdb/common/types/value.hpp"
@@ -763,6 +764,45 @@ hugeint_t &hugeint_t::operator^=(const hugeint_t &rhs) {
763
764
  return *this;
764
765
  }
765
766
 
767
+ bool hugeint_t::operator!() const {
768
+ return *this == 0;
769
+ }
770
+
771
+ hugeint_t::operator bool() const {
772
+ return *this != 0;
773
+ }
774
+
775
+ template <class T>
776
+ static T NarrowCast(const hugeint_t &input) {
777
+ // NarrowCast is supposed to truncate (take lower)
778
+ return static_cast<T>(input.lower);
779
+ }
780
+
781
+ hugeint_t::operator uint8_t() const {
782
+ return NarrowCast<uint8_t>(*this);
783
+ }
784
+ hugeint_t::operator uint16_t() const {
785
+ return NarrowCast<uint16_t>(*this);
786
+ }
787
+ hugeint_t::operator uint32_t() const {
788
+ return NarrowCast<uint32_t>(*this);
789
+ }
790
+ hugeint_t::operator uint64_t() const {
791
+ return NarrowCast<uint64_t>(*this);
792
+ }
793
+ hugeint_t::operator int8_t() const {
794
+ return NarrowCast<int8_t>(*this);
795
+ }
796
+ hugeint_t::operator int16_t() const {
797
+ return NarrowCast<int16_t>(*this);
798
+ }
799
+ hugeint_t::operator int32_t() const {
800
+ return NarrowCast<int32_t>(*this);
801
+ }
802
+ hugeint_t::operator int64_t() const {
803
+ return NarrowCast<int64_t>(*this);
804
+ }
805
+
766
806
  string hugeint_t::ToString() const {
767
807
  return Hugeint::ToString(*this);
768
808
  }
@@ -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);
@@ -1108,18 +1108,6 @@ LogicalType LogicalType::Deserialize(Deserializer &source) {
1108
1108
  return LogicalType(id, std::move(info));
1109
1109
  }
1110
1110
 
1111
- void LogicalType::FormatSerialize(FormatSerializer &serializer) const {
1112
- serializer.WriteProperty("id", id_);
1113
- serializer.WriteOptionalProperty("type_info", type_info_.get());
1114
- }
1115
-
1116
- LogicalType LogicalType::FormatDeserialize(FormatDeserializer &deserializer) {
1117
- auto id = deserializer.ReadProperty<LogicalTypeId>("id");
1118
- auto info = deserializer.ReadOptionalProperty<shared_ptr<ExtraTypeInfo>>("type_info");
1119
-
1120
- return LogicalType(id, std::move(info));
1121
- }
1122
-
1123
1111
  bool LogicalType::EqualTypeInfo(const LogicalType &rhs) const {
1124
1112
  if (type_info_.get() == rhs.type_info_.get()) {
1125
1113
  return true;
@@ -310,6 +310,7 @@ static StaticFunctionDefinition internal_functions[] = {
310
310
  DUCKDB_SCALAR_FUNCTION_SET(TimezoneFun),
311
311
  DUCKDB_SCALAR_FUNCTION_SET(TimezoneHourFun),
312
312
  DUCKDB_SCALAR_FUNCTION_SET(TimezoneMinuteFun),
313
+ DUCKDB_SCALAR_FUNCTION_SET(ToBaseFun),
313
314
  DUCKDB_SCALAR_FUNCTION(ToBase64Fun),
314
315
  DUCKDB_SCALAR_FUNCTION_SET_ALIAS(ToBinaryFun),
315
316
  DUCKDB_SCALAR_FUNCTION(ToDaysFun),
@@ -0,0 +1,66 @@
1
+ #include "duckdb/core_functions/scalar/string_functions.hpp"
2
+ #include "duckdb/common/vector_operations/vector_operations.hpp"
3
+ #include "duckdb/planner/expression/bound_constant_expression.hpp"
4
+
5
+ namespace duckdb {
6
+
7
+ static const char alphabet[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
8
+
9
+ static unique_ptr<FunctionData> ToBaseBind(ClientContext &context, ScalarFunction &bound_function,
10
+ vector<unique_ptr<Expression>> &arguments) {
11
+ // If no min_length is specified, default to 0
12
+ D_ASSERT(arguments.size() == 2 || arguments.size() == 3);
13
+ if (arguments.size() == 2) {
14
+ arguments.push_back(make_uniq_base<Expression, BoundConstantExpression>(Value::INTEGER(0)));
15
+ }
16
+ return nullptr;
17
+ }
18
+
19
+ static void ToBaseFunction(DataChunk &args, ExpressionState &state, Vector &result) {
20
+ auto &input = args.data[0];
21
+ auto &radix = args.data[1];
22
+ auto &min_length = args.data[2];
23
+ auto count = args.size();
24
+
25
+ TernaryExecutor::Execute<int64_t, int32_t, int32_t, string_t>(
26
+ input, radix, min_length, result, count, [&](int64_t input, int32_t radix, int32_t min_length) {
27
+ if (input < 0) {
28
+ throw InvalidInputException("'to_base' number must be greater than or equal to 0");
29
+ }
30
+ if (radix < 2 || radix > 36) {
31
+ throw InvalidInputException("'to_base' radix must be between 2 and 36");
32
+ }
33
+ if (min_length > 64 || min_length < 0) {
34
+ throw InvalidInputException("'to_base' min_length must be between 0 and 64");
35
+ }
36
+
37
+ char buf[64];
38
+ char *end = buf + sizeof(buf);
39
+ char *ptr = end;
40
+ do {
41
+ *--ptr = alphabet[input % radix];
42
+ input /= radix;
43
+ } while (input > 0);
44
+
45
+ auto length = end - ptr;
46
+ while (length < min_length) {
47
+ *--ptr = '0';
48
+ length++;
49
+ }
50
+
51
+ return StringVector::AddString(result, ptr, end - ptr);
52
+ });
53
+ }
54
+
55
+ ScalarFunctionSet ToBaseFun::GetFunctions() {
56
+ ScalarFunctionSet set("to_base");
57
+
58
+ set.AddFunction(
59
+ ScalarFunction({LogicalType::BIGINT, LogicalType::INTEGER}, LogicalType::VARCHAR, ToBaseFunction, ToBaseBind));
60
+ set.AddFunction(ScalarFunction({LogicalType::BIGINT, LogicalType::INTEGER, LogicalType::INTEGER},
61
+ LogicalType::VARCHAR, ToBaseFunction, ToBaseBind));
62
+
63
+ return set;
64
+ }
65
+
66
+ } // namespace duckdb
@@ -396,10 +396,10 @@ SinkResultType PhysicalHashAggregate::Sink(ExecutionContext &context, DataChunk
396
396
  return SinkResultType::NEED_MORE_INPUT;
397
397
  }
398
398
 
399
- void PhysicalHashAggregate::CombineDistinct(ExecutionContext &context, GlobalSinkState &state,
400
- LocalSinkState &lstate) const {
401
- auto &global_sink = state.Cast<HashAggregateGlobalState>();
402
- auto &sink = lstate.Cast<HashAggregateLocalState>();
399
+ void PhysicalHashAggregate::CombineDistinct(ExecutionContext &context, OperatorSinkCombineInput &input) const {
400
+
401
+ auto &global_sink = input.global_state.Cast<HashAggregateGlobalState>();
402
+ auto &sink = input.local_state.Cast<HashAggregateLocalState>();
403
403
 
404
404
  if (!distinct_collection_info) {
405
405
  return;
@@ -425,14 +425,15 @@ void PhysicalHashAggregate::CombineDistinct(ExecutionContext &context, GlobalSin
425
425
  }
426
426
  }
427
427
 
428
- void PhysicalHashAggregate::Combine(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate) const {
429
- auto &gstate = state.Cast<HashAggregateGlobalState>();
430
- auto &llstate = lstate.Cast<HashAggregateLocalState>();
428
+ SinkCombineResultType PhysicalHashAggregate::Combine(ExecutionContext &context, OperatorSinkCombineInput &input) const {
429
+ auto &gstate = input.global_state.Cast<HashAggregateGlobalState>();
430
+ auto &llstate = input.local_state.Cast<HashAggregateLocalState>();
431
431
 
432
- CombineDistinct(context, state, lstate);
432
+ OperatorSinkCombineInput combine_distinct_input {gstate, llstate, input.interrupt_state};
433
+ CombineDistinct(context, combine_distinct_input);
433
434
 
434
435
  if (CanSkipRegularSink()) {
435
- return;
436
+ return SinkCombineResultType::FINISHED;
436
437
  }
437
438
  for (idx_t i = 0; i < groupings.size(); i++) {
438
439
  auto &grouping_gstate = gstate.grouping_states[i];
@@ -442,6 +443,8 @@ void PhysicalHashAggregate::Combine(ExecutionContext &context, GlobalSinkState &
442
443
  auto &table = grouping.table_data;
443
444
  table.Combine(context, *grouping_gstate.table_state, *grouping_lstate.table_state);
444
445
  }
446
+
447
+ return SinkCombineResultType::FINISHED;
445
448
  }
446
449
 
447
450
  //! REGULAR FINALIZE EVENT
@@ -818,8 +821,8 @@ SinkFinalizeType PhysicalHashAggregate::FinalizeInternal(Pipeline &pipeline, Eve
818
821
  }
819
822
 
820
823
  SinkFinalizeType PhysicalHashAggregate::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
821
- GlobalSinkState &gstate_p) const {
822
- return FinalizeInternal(pipeline, event, context, gstate_p, true);
824
+ OperatorSinkFinalizeInput &input) const {
825
+ return FinalizeInternal(pipeline, event, context, input.global_state, true);
823
826
  }
824
827
 
825
828
  //===--------------------------------------------------------------------===//
@@ -159,13 +159,15 @@ SinkResultType PhysicalPerfectHashAggregate::Sink(ExecutionContext &context, Dat
159
159
  //===--------------------------------------------------------------------===//
160
160
  // Combine
161
161
  //===--------------------------------------------------------------------===//
162
- void PhysicalPerfectHashAggregate::Combine(ExecutionContext &context, GlobalSinkState &gstate_p,
163
- LocalSinkState &lstate_p) const {
164
- auto &lstate = lstate_p.Cast<PerfectHashAggregateLocalState>();
165
- auto &gstate = gstate_p.Cast<PerfectHashAggregateGlobalState>();
162
+ SinkCombineResultType PhysicalPerfectHashAggregate::Combine(ExecutionContext &context,
163
+ OperatorSinkCombineInput &input) const {
164
+ auto &lstate = input.local_state.Cast<PerfectHashAggregateLocalState>();
165
+ auto &gstate = input.global_state.Cast<PerfectHashAggregateGlobalState>();
166
166
 
167
167
  lock_guard<mutex> l(gstate.lock);
168
168
  gstate.ht->Combine(*lstate.ht);
169
+
170
+ return SinkCombineResultType::FINISHED;
169
171
  }
170
172
 
171
173
  //===--------------------------------------------------------------------===//
@@ -299,10 +299,9 @@ SinkResultType PhysicalUngroupedAggregate::Sink(ExecutionContext &context, DataC
299
299
  // Finalize
300
300
  //===--------------------------------------------------------------------===//
301
301
 
302
- void PhysicalUngroupedAggregate::CombineDistinct(ExecutionContext &context, GlobalSinkState &state,
303
- LocalSinkState &lstate) const {
304
- auto &global_sink = state.Cast<UngroupedAggregateGlobalState>();
305
- auto &source = lstate.Cast<UngroupedAggregateLocalState>();
302
+ void PhysicalUngroupedAggregate::CombineDistinct(ExecutionContext &context, OperatorSinkCombineInput &input) const {
303
+ auto &global_sink = input.global_state.Cast<UngroupedAggregateGlobalState>();
304
+ auto &source = input.local_state.Cast<UngroupedAggregateLocalState>();
306
305
 
307
306
  if (!distinct_data) {
308
307
  return;
@@ -319,10 +318,10 @@ void PhysicalUngroupedAggregate::CombineDistinct(ExecutionContext &context, Glob
319
318
  }
320
319
  }
321
320
 
322
- void PhysicalUngroupedAggregate::Combine(ExecutionContext &context, GlobalSinkState &state,
323
- LocalSinkState &lstate) const {
324
- auto &gstate = state.Cast<UngroupedAggregateGlobalState>();
325
- auto &source = lstate.Cast<UngroupedAggregateLocalState>();
321
+ SinkCombineResultType PhysicalUngroupedAggregate::Combine(ExecutionContext &context,
322
+ OperatorSinkCombineInput &input) const {
323
+ auto &gstate = input.global_state.Cast<UngroupedAggregateGlobalState>();
324
+ auto &source = input.local_state.Cast<UngroupedAggregateLocalState>();
326
325
  D_ASSERT(!gstate.finished);
327
326
 
328
327
  // finalize: combine the local state into the global state
@@ -330,7 +329,8 @@ void PhysicalUngroupedAggregate::Combine(ExecutionContext &context, GlobalSinkSt
330
329
  // use the combine method to combine the partial aggregates
331
330
  lock_guard<mutex> glock(gstate.lock);
332
331
 
333
- CombineDistinct(context, state, lstate);
332
+ OperatorSinkCombineInput distinct_input {gstate, source, input.interrupt_state};
333
+ CombineDistinct(context, distinct_input);
334
334
 
335
335
  for (idx_t aggr_idx = 0; aggr_idx < aggregates.size(); aggr_idx++) {
336
336
  auto &aggregate = aggregates[aggr_idx]->Cast<BoundAggregateExpression>();
@@ -353,6 +353,8 @@ void PhysicalUngroupedAggregate::Combine(ExecutionContext &context, GlobalSinkSt
353
353
  auto &client_profiler = QueryProfiler::Get(context.client);
354
354
  context.thread.profiler.Flush(*this, source.child_executor, "child_executor", 0);
355
355
  client_profiler.Flush(context.thread.profiler);
356
+
357
+ return SinkCombineResultType::FINISHED;
356
358
  }
357
359
 
358
360
  class UngroupedDistinctAggregateFinalizeTask : public ExecutorTask {
@@ -536,11 +538,11 @@ SinkFinalizeType PhysicalUngroupedAggregate::FinalizeDistinct(Pipeline &pipeline
536
538
  }
537
539
 
538
540
  SinkFinalizeType PhysicalUngroupedAggregate::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
539
- GlobalSinkState &gstate_p) const {
540
- auto &gstate = gstate_p.Cast<UngroupedAggregateGlobalState>();
541
+ OperatorSinkFinalizeInput &input) const {
542
+ auto &gstate = input.global_state.Cast<UngroupedAggregateGlobalState>();
541
543
 
542
544
  if (distinct_data) {
543
- return FinalizeDistinct(pipeline, event, context, gstate_p);
545
+ return FinalizeDistinct(pipeline, event, context, input.global_state);
544
546
  }
545
547
 
546
548
  D_ASSERT(!gstate.finished);
@@ -124,9 +124,11 @@ SinkResultType PhysicalWindow::Sink(ExecutionContext &context, DataChunk &chunk,
124
124
  return SinkResultType::NEED_MORE_INPUT;
125
125
  }
126
126
 
127
- void PhysicalWindow::Combine(ExecutionContext &context, GlobalSinkState &gstate_p, LocalSinkState &lstate_p) const {
128
- auto &lstate = lstate_p.Cast<WindowLocalSinkState>();
127
+ SinkCombineResultType PhysicalWindow::Combine(ExecutionContext &context, OperatorSinkCombineInput &input) const {
128
+ auto &lstate = input.local_state.Cast<WindowLocalSinkState>();
129
129
  lstate.Combine();
130
+
131
+ return SinkCombineResultType::FINISHED;
130
132
  }
131
133
 
132
134
  unique_ptr<LocalSinkState> PhysicalWindow::GetLocalSinkState(ExecutionContext &context) const {
@@ -139,8 +141,8 @@ unique_ptr<GlobalSinkState> PhysicalWindow::GetGlobalSinkState(ClientContext &co
139
141
  }
140
142
 
141
143
  SinkFinalizeType PhysicalWindow::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
142
- GlobalSinkState &gstate_p) const {
143
- auto &state = gstate_p.Cast<WindowGlobalSinkState>();
144
+ OperatorSinkFinalizeInput &input) const {
145
+ auto &state = input.global_state.Cast<WindowGlobalSinkState>();
144
146
 
145
147
  // Did we get any data?
146
148
  if (!state.global_partition->count) {
@@ -37,18 +37,20 @@ SinkResultType PhysicalBatchCollector::Sink(ExecutionContext &context, DataChunk
37
37
  return SinkResultType::NEED_MORE_INPUT;
38
38
  }
39
39
 
40
- void PhysicalBatchCollector::Combine(ExecutionContext &context, GlobalSinkState &gstate_p,
41
- LocalSinkState &lstate_p) const {
42
- auto &gstate = gstate_p.Cast<BatchCollectorGlobalState>();
43
- auto &state = lstate_p.Cast<BatchCollectorLocalState>();
40
+ SinkCombineResultType PhysicalBatchCollector::Combine(ExecutionContext &context,
41
+ OperatorSinkCombineInput &input) const {
42
+ auto &gstate = input.global_state.Cast<BatchCollectorGlobalState>();
43
+ auto &state = input.local_state.Cast<BatchCollectorLocalState>();
44
44
 
45
45
  lock_guard<mutex> lock(gstate.glock);
46
46
  gstate.data.Merge(state.data);
47
+
48
+ return SinkCombineResultType::FINISHED;
47
49
  }
48
50
 
49
51
  SinkFinalizeType PhysicalBatchCollector::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
50
- GlobalSinkState &gstate_p) const {
51
- auto &gstate = gstate_p.Cast<BatchCollectorGlobalState>();
52
+ OperatorSinkFinalizeInput &input) const {
53
+ auto &gstate = input.global_state.Cast<BatchCollectorGlobalState>();
52
54
  auto collection = gstate.data.FetchCollection();
53
55
  D_ASSERT(collection);
54
56
  auto result = make_uniq<MaterializedQueryResult>(statement_type, properties, names, std::move(collection),
@@ -18,8 +18,8 @@ SinkResultType PhysicalExplainAnalyze::Sink(ExecutionContext &context, DataChunk
18
18
  }
19
19
 
20
20
  SinkFinalizeType PhysicalExplainAnalyze::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
21
- GlobalSinkState &gstate_p) const {
22
- auto &gstate = gstate_p.Cast<ExplainAnalyzeStateGlobalState>();
21
+ OperatorSinkFinalizeInput &input) const {
22
+ auto &gstate = input.global_state.Cast<ExplainAnalyzeStateGlobalState>();
23
23
  auto &profiler = QueryProfiler::Get(context);
24
24
  gstate.analyzed_plan = profiler.ToString();
25
25
  return SinkFinalizeType::READY;
@@ -116,14 +116,16 @@ SinkResultType PhysicalLimit::Sink(ExecutionContext &context, DataChunk &chunk,
116
116
  return SinkResultType::NEED_MORE_INPUT;
117
117
  }
118
118
 
119
- void PhysicalLimit::Combine(ExecutionContext &context, GlobalSinkState &gstate_p, LocalSinkState &lstate_p) const {
120
- auto &gstate = gstate_p.Cast<LimitGlobalState>();
121
- auto &state = lstate_p.Cast<LimitLocalState>();
119
+ SinkCombineResultType PhysicalLimit::Combine(ExecutionContext &context, OperatorSinkCombineInput &input) const {
120
+ auto &gstate = input.global_state.Cast<LimitGlobalState>();
121
+ auto &state = input.local_state.Cast<LimitLocalState>();
122
122
 
123
123
  lock_guard<mutex> lock(gstate.glock);
124
124
  gstate.limit = state.limit;
125
125
  gstate.offset = state.offset;
126
126
  gstate.data.Merge(state.data);
127
+
128
+ return SinkCombineResultType::FINISHED;
127
129
  }
128
130
 
129
131
  //===--------------------------------------------------------------------===//
@@ -32,12 +32,12 @@ SinkResultType PhysicalMaterializedCollector::Sink(ExecutionContext &context, Da
32
32
  return SinkResultType::NEED_MORE_INPUT;
33
33
  }
34
34
 
35
- void PhysicalMaterializedCollector::Combine(ExecutionContext &context, GlobalSinkState &gstate_p,
36
- LocalSinkState &lstate_p) const {
37
- auto &gstate = gstate_p.Cast<MaterializedCollectorGlobalState>();
38
- auto &lstate = lstate_p.Cast<MaterializedCollectorLocalState>();
35
+ SinkCombineResultType PhysicalMaterializedCollector::Combine(ExecutionContext &context,
36
+ OperatorSinkCombineInput &input) const {
37
+ auto &gstate = input.global_state.Cast<MaterializedCollectorGlobalState>();
38
+ auto &lstate = input.local_state.Cast<MaterializedCollectorLocalState>();
39
39
  if (lstate.collection->Count() == 0) {
40
- return;
40
+ return SinkCombineResultType::FINISHED;
41
41
  }
42
42
 
43
43
  lock_guard<mutex> l(gstate.glock);
@@ -46,6 +46,8 @@ void PhysicalMaterializedCollector::Combine(ExecutionContext &context, GlobalSin
46
46
  } else {
47
47
  gstate.collection->Combine(*lstate.collection);
48
48
  }
49
+
50
+ return SinkCombineResultType::FINISHED;
49
51
  }
50
52
 
51
53
  unique_ptr<GlobalSinkState> PhysicalMaterializedCollector::GetGlobalSinkState(ClientContext &context) const {
@@ -57,20 +57,22 @@ SinkResultType PhysicalVacuum::Sink(ExecutionContext &context, DataChunk &chunk,
57
57
  return SinkResultType::NEED_MORE_INPUT;
58
58
  }
59
59
 
60
- void PhysicalVacuum::Combine(ExecutionContext &context, GlobalSinkState &gstate_p, LocalSinkState &lstate_p) const {
61
- auto &gstate = gstate_p.Cast<VacuumGlobalSinkState>();
62
- auto &lstate = lstate_p.Cast<VacuumLocalSinkState>();
60
+ SinkCombineResultType PhysicalVacuum::Combine(ExecutionContext &context, OperatorSinkCombineInput &input) const {
61
+ auto &gstate = input.global_state.Cast<VacuumGlobalSinkState>();
62
+ auto &lstate = input.local_state.Cast<VacuumLocalSinkState>();
63
63
 
64
64
  lock_guard<mutex> lock(gstate.stats_lock);
65
65
  D_ASSERT(gstate.column_distinct_stats.size() == lstate.column_distinct_stats.size());
66
66
  for (idx_t col_idx = 0; col_idx < gstate.column_distinct_stats.size(); col_idx++) {
67
67
  gstate.column_distinct_stats[col_idx]->Merge(*lstate.column_distinct_stats[col_idx]);
68
68
  }
69
+
70
+ return SinkCombineResultType::FINISHED;
69
71
  }
70
72
 
71
73
  SinkFinalizeType PhysicalVacuum::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
72
- GlobalSinkState &gstate) const {
73
- auto &sink = gstate.Cast<VacuumGlobalSinkState>();
74
+ OperatorSinkFinalizeInput &input) const {
75
+ auto &sink = input.global_state.Cast<VacuumGlobalSinkState>();
74
76
 
75
77
  auto table = info->table;
76
78
  for (idx_t col_idx = 0; col_idx < sink.column_distinct_stats.size(); col_idx++) {
@@ -143,17 +143,18 @@ SinkResultType PhysicalAsOfJoin::Sink(ExecutionContext &context, DataChunk &chun
143
143
  return SinkResultType::NEED_MORE_INPUT;
144
144
  }
145
145
 
146
- void PhysicalAsOfJoin::Combine(ExecutionContext &context, GlobalSinkState &gstate_p, LocalSinkState &lstate_p) const {
147
- auto &lstate = lstate_p.Cast<AsOfLocalSinkState>();
146
+ SinkCombineResultType PhysicalAsOfJoin::Combine(ExecutionContext &context, OperatorSinkCombineInput &input) const {
147
+ auto &lstate = input.local_state.Cast<AsOfLocalSinkState>();
148
148
  lstate.Combine();
149
+ return SinkCombineResultType::FINISHED;
149
150
  }
150
151
 
151
152
  //===--------------------------------------------------------------------===//
152
153
  // Finalize
153
154
  //===--------------------------------------------------------------------===//
154
155
  SinkFinalizeType PhysicalAsOfJoin::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
155
- GlobalSinkState &gstate_p) const {
156
- auto &gstate = gstate_p.Cast<AsOfGlobalSinkState>();
156
+ OperatorSinkFinalizeInput &input) const {
157
+ auto &gstate = input.global_state.Cast<AsOfGlobalSinkState>();
157
158
 
158
159
  // The data is all in so we can initialise the left partitioning.
159
160
  const vector<unique_ptr<BaseStatistics>> partitions_stats;
@@ -62,8 +62,8 @@ SinkResultType PhysicalBlockwiseNLJoin::Sink(ExecutionContext &context, DataChun
62
62
  // Finalize
63
63
  //===--------------------------------------------------------------------===//
64
64
  SinkFinalizeType PhysicalBlockwiseNLJoin::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
65
- GlobalSinkState &gstate_p) const {
66
- auto &gstate = gstate_p.Cast<BlockwiseNLJoinGlobalState>();
65
+ OperatorSinkFinalizeInput &input) const {
66
+ auto &gstate = input.global_state.Cast<BlockwiseNLJoinGlobalState>();
67
67
  gstate.right_outer.Initialize(gstate.right_chunks.Count());
68
68
 
69
69
  if (gstate.right_chunks.Count() == 0 && EmptyResultIfRHSIsEmpty()) {
@@ -98,18 +98,25 @@ SinkResultType PhysicalDelimJoin::Sink(ExecutionContext &context, DataChunk &chu
98
98
  return SinkResultType::NEED_MORE_INPUT;
99
99
  }
100
100
 
101
- void PhysicalDelimJoin::Combine(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate_p) const {
102
- auto &lstate = lstate_p.Cast<DelimJoinLocalState>();
103
- auto &gstate = state.Cast<DelimJoinGlobalState>();
101
+ SinkCombineResultType PhysicalDelimJoin::Combine(ExecutionContext &context, OperatorSinkCombineInput &input) const {
102
+ auto &lstate = input.local_state.Cast<DelimJoinLocalState>();
103
+ auto &gstate = input.global_state.Cast<DelimJoinGlobalState>();
104
104
  gstate.Merge(lstate.lhs_data);
105
- distinct->Combine(context, *distinct->sink_state, *lstate.distinct_state);
105
+
106
+ OperatorSinkCombineInput distinct_combine_input {*distinct->sink_state, *lstate.distinct_state,
107
+ input.interrupt_state};
108
+ distinct->Combine(context, distinct_combine_input);
109
+
110
+ return SinkCombineResultType::FINISHED;
106
111
  }
107
112
 
108
113
  SinkFinalizeType PhysicalDelimJoin::Finalize(Pipeline &pipeline, Event &event, ClientContext &client,
109
- GlobalSinkState &gstate) const {
114
+ OperatorSinkFinalizeInput &input) const {
110
115
  // finalize the distinct HT
111
116
  D_ASSERT(distinct);
112
- distinct->Finalize(pipeline, event, client, *distinct->sink_state);
117
+
118
+ OperatorSinkFinalizeInput finalize_input {*distinct->sink_state, input.interrupt_state};
119
+ distinct->Finalize(pipeline, event, client, finalize_input);
113
120
  return SinkFinalizeType::READY;
114
121
  }
115
122
 
@@ -210,9 +210,9 @@ SinkResultType PhysicalHashJoin::Sink(ExecutionContext &context, DataChunk &chun
210
210
  return SinkResultType::NEED_MORE_INPUT;
211
211
  }
212
212
 
213
- void PhysicalHashJoin::Combine(ExecutionContext &context, GlobalSinkState &gstate_p, LocalSinkState &lstate_p) const {
214
- auto &gstate = gstate_p.Cast<HashJoinGlobalSinkState>();
215
- auto &lstate = lstate_p.Cast<HashJoinLocalSinkState>();
213
+ SinkCombineResultType PhysicalHashJoin::Combine(ExecutionContext &context, OperatorSinkCombineInput &input) const {
214
+ auto &gstate = input.global_state.Cast<HashJoinGlobalSinkState>();
215
+ auto &lstate = input.local_state.Cast<HashJoinLocalSinkState>();
216
216
  if (lstate.hash_table) {
217
217
  lstate.hash_table->GetSinkCollection().FlushAppendState(lstate.append_state);
218
218
  lock_guard<mutex> local_ht_lock(gstate.lock);
@@ -221,6 +221,8 @@ void PhysicalHashJoin::Combine(ExecutionContext &context, GlobalSinkState &gstat
221
221
  auto &client_profiler = QueryProfiler::Get(context.client);
222
222
  context.thread.profiler.Flush(*this, lstate.build_executor, "build_executor", 1);
223
223
  client_profiler.Flush(context.thread.profiler);
224
+
225
+ return SinkCombineResultType::FINISHED;
224
226
  }
225
227
 
226
228
  //===--------------------------------------------------------------------===//
@@ -362,8 +364,8 @@ public:
362
364
  };
363
365
 
364
366
  SinkFinalizeType PhysicalHashJoin::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
365
- GlobalSinkState &gstate) const {
366
- auto &sink = gstate.Cast<HashJoinGlobalSinkState>();
367
+ OperatorSinkFinalizeInput &input) const {
368
+ auto &sink = input.global_state.Cast<HashJoinGlobalSinkState>();
367
369
  auto &ht = *sink.hash_table;
368
370
 
369
371
  sink.external = ht.RequiresExternalJoin(context.config, sink.local_hash_tables);