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
@@ -27,6 +27,10 @@ public:
27
27
  public:
28
28
  void Serialize(FieldWriter &writer) const override;
29
29
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
30
+
31
+ void FormatSerialize(FormatSerializer &serializer) const override;
32
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
33
+
30
34
  idx_t EstimateCardinality(ClientContext &context) override;
31
35
  vector<idx_t> GetTableIndex() const override;
32
36
  string GetName() const override;
@@ -34,5 +38,8 @@ public:
34
38
  protected:
35
39
  vector<ColumnBinding> GetColumnBindings() override;
36
40
  void ResolveTypes() override;
41
+
42
+ private:
43
+ LogicalDelete(ClientContext &context, const string &catalog, const string &schema, const string &table);
37
44
  };
38
45
  } // namespace duckdb
@@ -35,6 +35,9 @@ public:
35
35
  }
36
36
  void Serialize(FieldWriter &writer) const override;
37
37
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
38
+
39
+ void FormatSerialize(FormatSerializer &serializer) const override;
40
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
38
41
  vector<idx_t> GetTableIndex() const override;
39
42
  string GetName() const override;
40
43
 
@@ -19,13 +19,8 @@ public:
19
19
  static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_DISTINCT;
20
20
 
21
21
  public:
22
- explicit LogicalDistinct(DistinctType distinct_type)
23
- : LogicalOperator(LogicalOperatorType::LOGICAL_DISTINCT), distinct_type(distinct_type) {
24
- }
25
- explicit LogicalDistinct(vector<unique_ptr<Expression>> targets, DistinctType distinct_type)
26
- : LogicalOperator(LogicalOperatorType::LOGICAL_DISTINCT), distinct_type(distinct_type),
27
- distinct_targets(std::move(targets)) {
28
- }
22
+ explicit LogicalDistinct(DistinctType distinct_type);
23
+ explicit LogicalDistinct(vector<unique_ptr<Expression>> targets, DistinctType distinct_type);
29
24
 
30
25
  //! Whether or not this is a DISTINCT or DISTINCT ON
31
26
  DistinctType distinct_type;
@@ -43,9 +38,10 @@ public:
43
38
  void Serialize(FieldWriter &writer) const override;
44
39
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
45
40
 
41
+ void FormatSerialize(FormatSerializer &serializer) const override;
42
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
43
+
46
44
  protected:
47
- void ResolveTypes() override {
48
- types = children[0]->types;
49
- }
45
+ void ResolveTypes() override;
50
46
  };
51
47
  } // namespace duckdb
@@ -34,6 +34,8 @@ public:
34
34
  }
35
35
  void Serialize(FieldWriter &writer) const override;
36
36
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
37
+ void FormatSerialize(FormatSerializer &serializer) const override;
38
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
37
39
  vector<idx_t> GetTableIndex() const override;
38
40
  string GetName() const override;
39
41
 
@@ -34,6 +34,8 @@ public:
34
34
  }
35
35
  void Serialize(FieldWriter &writer) const override;
36
36
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
37
+ void FormatSerialize(FormatSerializer &serializer) const override;
38
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
37
39
  idx_t EstimateCardinality(ClientContext &context) override {
38
40
  return 0;
39
41
  }
@@ -34,6 +34,10 @@ public:
34
34
  public:
35
35
  void Serialize(FieldWriter &writer) const override;
36
36
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
37
+
38
+ void FormatSerialize(FormatSerializer &serializer) const override;
39
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
40
+
37
41
  idx_t EstimateCardinality(ClientContext &context) override {
38
42
  return 3;
39
43
  }
@@ -37,6 +37,9 @@ public:
37
37
  }
38
38
  void Serialize(FieldWriter &writer) const override;
39
39
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
40
+
41
+ void FormatSerialize(FormatSerializer &serializer) const override;
42
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
40
43
  idx_t EstimateCardinality(ClientContext &context) override {
41
44
  return expressions.size();
42
45
  }
@@ -28,6 +28,9 @@ public:
28
28
  void Serialize(FieldWriter &writer) const override;
29
29
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
30
30
 
31
+ void FormatSerialize(FormatSerializer &serializer) const override;
32
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
33
+
31
34
  bool SplitPredicates() {
32
35
  return SplitPredicates(expressions);
33
36
  }
@@ -63,6 +63,9 @@ public:
63
63
  void Serialize(FieldWriter &writer) const override;
64
64
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
65
65
 
66
+ void FormatSerialize(FormatSerializer &serializer) const override;
67
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
68
+
66
69
  protected:
67
70
  vector<ColumnBinding> GetColumnBindings() override;
68
71
  void ResolveTypes() override;
@@ -70,5 +73,8 @@ protected:
70
73
  idx_t EstimateCardinality(ClientContext &context) override;
71
74
  vector<idx_t> GetTableIndex() const override;
72
75
  string GetName() const override;
76
+
77
+ private:
78
+ LogicalInsert(ClientContext &context, const string &catalog, const string &schema, const string &table);
73
79
  };
74
80
  } // namespace duckdb
@@ -35,6 +35,9 @@ public:
35
35
  void Serialize(FieldWriter &writer) const override;
36
36
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
37
37
 
38
+ void FormatSerialize(FormatSerializer &serializer) const override;
39
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
40
+
38
41
  protected:
39
42
  void ResolveTypes() override;
40
43
  };
@@ -39,6 +39,9 @@ public:
39
39
 
40
40
  void Serialize(FieldWriter &writer) const override;
41
41
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
42
+
43
+ void FormatSerialize(FormatSerializer &serializer) const override;
44
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
42
45
  idx_t EstimateCardinality(ClientContext &context) override;
43
46
 
44
47
  protected:
@@ -13,8 +13,7 @@
13
13
  namespace duckdb {
14
14
 
15
15
  class LogicalMaterializedCTE : public LogicalOperator {
16
- LogicalMaterializedCTE(idx_t table_index)
17
- : LogicalOperator(LogicalOperatorType::LOGICAL_MATERIALIZED_CTE), table_index(table_index) {
16
+ explicit LogicalMaterializedCTE() : LogicalOperator(LogicalOperatorType::LOGICAL_MATERIALIZED_CTE) {
18
17
  }
19
18
 
20
19
  public:
@@ -39,6 +38,10 @@ public:
39
38
  }
40
39
  void Serialize(FieldWriter &writer) const override;
41
40
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
41
+
42
+ void FormatSerialize(FormatSerializer &serializer) const override;
43
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
44
+
42
45
  vector<idx_t> GetTableIndex() const override;
43
46
 
44
47
  protected:
@@ -21,51 +21,23 @@ public:
21
21
  static constexpr const LogicalOperatorType TYPE = LogicalOperatorType::LOGICAL_ORDER_BY;
22
22
 
23
23
  public:
24
- explicit LogicalOrder(vector<BoundOrderByNode> orders)
25
- : LogicalOperator(LogicalOperatorType::LOGICAL_ORDER_BY), orders(std::move(orders)) {
26
- }
24
+ explicit LogicalOrder(vector<BoundOrderByNode> orders);
27
25
 
28
26
  vector<BoundOrderByNode> orders;
29
27
  vector<idx_t> projections;
30
28
 
31
29
  public:
32
- vector<ColumnBinding> GetColumnBindings() override {
33
- auto child_bindings = children[0]->GetColumnBindings();
34
- if (projections.empty()) {
35
- return child_bindings;
36
- }
37
-
38
- vector<ColumnBinding> result;
39
- for (auto &col_idx : projections) {
40
- result.push_back(child_bindings[col_idx]);
41
- }
42
- return result;
43
- }
30
+ vector<ColumnBinding> GetColumnBindings() override;
44
31
 
45
32
  void Serialize(FieldWriter &writer) const override;
46
33
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
47
34
 
48
- string ParamsToString() const override {
49
- string result = "ORDERS:\n";
50
- for (idx_t i = 0; i < orders.size(); i++) {
51
- if (i > 0) {
52
- result += "\n";
53
- }
54
- result += orders[i].expression->GetName();
55
- }
56
- return result;
57
- }
35
+ void FormatSerialize(FormatSerializer &serializer) const override;
36
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
37
+
38
+ string ParamsToString() const override;
58
39
 
59
40
  protected:
60
- void ResolveTypes() override {
61
- const auto child_types = children[0]->types;
62
- if (projections.empty()) {
63
- types = child_types;
64
- } else {
65
- for (auto &col_idx : projections) {
66
- types.push_back(child_types[col_idx]);
67
- }
68
- }
69
- }
41
+ void ResolveTypes() override;
70
42
  };
71
43
  } // namespace duckdb
@@ -31,10 +31,16 @@ public:
31
31
  vector<ColumnBinding> GetColumnBindings() override;
32
32
  void Serialize(FieldWriter &writer) const override;
33
33
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
34
+
35
+ void FormatSerialize(FormatSerializer &serializer) const override;
36
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
34
37
  vector<idx_t> GetTableIndex() const override;
35
38
  string GetName() const override;
36
39
 
37
40
  protected:
38
41
  void ResolveTypes() override;
42
+
43
+ private:
44
+ LogicalPivot();
39
45
  };
40
46
  } // namespace duckdb
@@ -27,5 +27,8 @@ public:
27
27
 
28
28
  void Serialize(FieldWriter &writer) const override;
29
29
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
30
+
31
+ void FormatSerialize(FormatSerializer &serializer) const override;
32
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
30
33
  };
31
34
  } // namespace duckdb
@@ -26,6 +26,9 @@ public:
26
26
  vector<ColumnBinding> GetColumnBindings() override;
27
27
  void Serialize(FieldWriter &writer) const override;
28
28
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
29
+ void FormatSerialize(FormatSerializer &serializer) const override;
30
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
31
+
29
32
  vector<idx_t> GetTableIndex() const override;
30
33
  string GetName() const override;
31
34
 
@@ -13,9 +13,7 @@
13
13
  namespace duckdb {
14
14
 
15
15
  class LogicalRecursiveCTE : public LogicalOperator {
16
- LogicalRecursiveCTE(idx_t table_index, idx_t column_count, bool union_all)
17
- : LogicalOperator(LogicalOperatorType::LOGICAL_RECURSIVE_CTE), union_all(union_all), table_index(table_index),
18
- column_count(column_count) {
16
+ LogicalRecursiveCTE() : LogicalOperator(LogicalOperatorType::LOGICAL_RECURSIVE_CTE) {
19
17
  }
20
18
 
21
19
  public:
@@ -41,6 +39,10 @@ public:
41
39
  }
42
40
  void Serialize(FieldWriter &writer) const override;
43
41
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
42
+
43
+ void FormatSerialize(FormatSerializer &serializer) const override;
44
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
45
+
44
46
  vector<idx_t> GetTableIndex() const override;
45
47
  string GetName() const override;
46
48
 
@@ -30,6 +30,10 @@ public:
30
30
  public:
31
31
  void Serialize(FieldWriter &writer) const override;
32
32
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
33
+
34
+ void FormatSerialize(FormatSerializer &serializer) const override;
35
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
36
+
33
37
  idx_t EstimateCardinality(ClientContext &context) override;
34
38
 
35
39
  protected:
@@ -31,8 +31,14 @@ public:
31
31
  void Serialize(FieldWriter &writer) const override;
32
32
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
33
33
 
34
+ void FormatSerialize(FormatSerializer &serializer) const override;
35
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
36
+
34
37
  protected:
35
38
  void ResolveTypes() override;
39
+
40
+ private:
41
+ LogicalSample();
36
42
  };
37
43
 
38
44
  } // namespace duckdb
@@ -31,6 +31,10 @@ public:
31
31
  public:
32
32
  void Serialize(FieldWriter &writer) const override;
33
33
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
34
+
35
+ void FormatSerialize(FormatSerializer &serializer) const override;
36
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
37
+
34
38
  idx_t EstimateCardinality(ClientContext &context) override;
35
39
 
36
40
  protected:
@@ -40,6 +40,10 @@ public:
40
40
 
41
41
  void Serialize(FieldWriter &writer) const override;
42
42
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
43
+
44
+ void FormatSerialize(FormatSerializer &serializer) const override;
45
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
46
+
43
47
  vector<idx_t> GetTableIndex() const override;
44
48
  string GetName() const override;
45
49
 
@@ -30,6 +30,9 @@ public:
30
30
  void Serialize(FieldWriter &writer) const override;
31
31
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
32
32
 
33
+ void FormatSerialize(FormatSerializer &serializer) const override;
34
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
35
+
33
36
  protected:
34
37
  void ResolveTypes() override {
35
38
  types = {LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR,
@@ -28,6 +28,9 @@ public:
28
28
  public:
29
29
  void Serialize(FieldWriter &writer) const override;
30
30
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
31
+
32
+ void FormatSerialize(FormatSerializer &serializer) const override;
33
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
31
34
  idx_t EstimateCardinality(ClientContext &context) override;
32
35
 
33
36
  protected:
@@ -35,6 +35,10 @@ public:
35
35
  }
36
36
  void Serialize(FieldWriter &writer) const override;
37
37
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
38
+
39
+ void FormatSerialize(FormatSerializer &serializer) const override;
40
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
41
+
38
42
  idx_t EstimateCardinality(ClientContext &context) override;
39
43
 
40
44
  protected:
@@ -28,6 +28,8 @@ public:
28
28
  vector<ColumnBinding> GetColumnBindings() override;
29
29
  void Serialize(FieldWriter &writer) const override;
30
30
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
31
+ void FormatSerialize(FormatSerializer &serializer) const override;
32
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
31
33
  vector<idx_t> GetTableIndex() const override;
32
34
  string GetName() const override;
33
35
 
@@ -33,11 +33,17 @@ public:
33
33
  public:
34
34
  void Serialize(FieldWriter &writer) const override;
35
35
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
36
+ void FormatSerialize(FormatSerializer &serializer) const override;
37
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
38
+
36
39
  idx_t EstimateCardinality(ClientContext &context) override;
37
40
  string GetName() const override;
38
41
 
39
42
  protected:
40
43
  vector<ColumnBinding> GetColumnBindings() override;
41
44
  void ResolveTypes() override;
45
+
46
+ private:
47
+ LogicalUpdate(ClientContext &context, const string &catalog, const string &schema, const string &table);
42
48
  };
43
49
  } // namespace duckdb
@@ -29,6 +29,9 @@ public:
29
29
  vector<ColumnBinding> GetColumnBindings() override;
30
30
  void Serialize(FieldWriter &writer) const override;
31
31
  static unique_ptr<LogicalOperator> Deserialize(LogicalDeserializationState &state, FieldReader &reader);
32
+
33
+ void FormatSerialize(FormatSerializer &serializer) const override;
34
+ static unique_ptr<LogicalOperator> FormatDeserialize(FormatDeserializer &deserializer);
32
35
  vector<idx_t> GetTableIndex() const override;
33
36
  string GetName() const override;
34
37
 
@@ -25,6 +25,9 @@ struct BoundPivotInfo {
25
25
  vector<string> pivot_values;
26
26
  //! The set of aggregate functions that is being executed
27
27
  vector<unique_ptr<Expression>> aggregates;
28
+
29
+ void FormatSerialize(FormatSerializer &serializer) const;
30
+ static BoundPivotInfo FormatDeserialize(FormatDeserializer &deserializer);
28
31
  };
29
32
 
30
33
  class BoundPivotRef : public BoundTableRef {
@@ -52,7 +52,7 @@ const vector<ColumnDefinition> &JoinRelation::Columns() {
52
52
 
53
53
  string JoinRelation::ToString(idx_t depth) {
54
54
  string str = RenderWhitespace(depth);
55
- str += "Join " + EnumUtil::ToString(join_type);
55
+ str += "Join " + EnumUtil::ToString(join_ref_type) + " " + EnumUtil::ToString(join_type);
56
56
  if (condition) {
57
57
  str += " " + condition->GetName();
58
58
  }
@@ -15,10 +15,12 @@ namespace duckdb {
15
15
 
16
16
  struct DelimCandidate {
17
17
  public:
18
- explicit DelimCandidate(LogicalDelimJoin &delim_join) : delim_join(delim_join), delim_get_count(0) {
18
+ explicit DelimCandidate(unique_ptr<LogicalOperator> &op, LogicalDelimJoin &delim_join)
19
+ : op(op), delim_join(delim_join), delim_get_count(0) {
19
20
  }
20
21
 
21
22
  public:
23
+ unique_ptr<LogicalOperator> &op;
22
24
  LogicalDelimJoin &delim_join;
23
25
  vector<reference<unique_ptr<LogicalOperator>>> joins;
24
26
  idx_t delim_get_count;
@@ -61,7 +63,7 @@ unique_ptr<LogicalOperator> Deliminator::Optimize(unique_ptr<LogicalOperator> op
61
63
  }
62
64
  }
63
65
  }
64
- delim_join.type = LogicalOperatorType::LOGICAL_COMPARISON_JOIN;
66
+ candidate.op = LogicalComparisonJoin::FromDelimJoin(delim_join);
65
67
  }
66
68
  }
67
69
 
@@ -78,7 +80,7 @@ void Deliminator::FindCandidates(unique_ptr<LogicalOperator> &op, vector<DelimCa
78
80
  return;
79
81
  }
80
82
 
81
- candidates.emplace_back(op->Cast<LogicalDelimJoin>());
83
+ candidates.emplace_back(op, op->Cast<LogicalDelimJoin>());
82
84
  auto &candidate = candidates.back();
83
85
 
84
86
  // DelimGets are in the RHS
@@ -218,23 +218,6 @@ void Pipeline::Ready() {
218
218
  std::reverse(operators.begin(), operators.end());
219
219
  }
220
220
 
221
- void Pipeline::Finalize(Event &event) {
222
- if (executor.HasError()) {
223
- return;
224
- }
225
- D_ASSERT(ready);
226
- try {
227
- auto sink_state = sink->Finalize(*this, event, executor.context, *sink->sink_state);
228
- sink->sink_state->state = sink_state;
229
- } catch (Exception &ex) { // LCOV_EXCL_START
230
- executor.PushError(PreservedError(ex));
231
- } catch (std::exception &ex) {
232
- executor.PushError(PreservedError(ex));
233
- } catch (...) {
234
- executor.PushError(PreservedError("Unknown exception in Finalize!"));
235
- } // LCOV_EXCL_STOP
236
- }
237
-
238
221
  void Pipeline::AddDependency(shared_ptr<Pipeline> &pipeline) {
239
222
  D_ASSERT(pipeline);
240
223
  dependencies.push_back(weak_ptr<Pipeline>(pipeline));
@@ -171,9 +171,7 @@ PipelineExecuteResult PipelineExecutor::Execute(idx_t max_chunks) {
171
171
  return PipelineExecuteResult::NOT_FINISHED;
172
172
  }
173
173
 
174
- PushFinalize();
175
-
176
- return PipelineExecuteResult::FINISHED;
174
+ return PushFinalize();
177
175
  }
178
176
 
179
177
  PipelineExecuteResult PipelineExecutor::Execute() {
@@ -238,24 +236,45 @@ OperatorResultType PipelineExecutor::ExecutePushInternal(DataChunk &input, idx_t
238
236
  }
239
237
  }
240
238
 
241
- void PipelineExecutor::PushFinalize() {
239
+ PipelineExecuteResult PipelineExecutor::PushFinalize() {
242
240
  if (finalized) {
243
241
  throw InternalException("Calling PushFinalize on a pipeline that has been finalized already");
244
242
  }
245
243
 
246
244
  D_ASSERT(local_sink_state);
247
245
 
248
- finalized = true;
246
+ // Run the combine for the sink
247
+ OperatorSinkCombineInput combine_input {*pipeline.sink->sink_state, *local_sink_state, interrupt_state};
248
+
249
+ #ifdef DUCKDB_DEBUG_ASYNC_SINK_SOURCE
250
+ if (debug_blocked_combine_count < debug_blocked_target_count) {
251
+ debug_blocked_combine_count++;
252
+
253
+ auto &callback_state = combine_input.interrupt_state;
254
+ std::thread rewake_thread([callback_state] {
255
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
256
+ callback_state.Callback();
257
+ });
258
+ rewake_thread.detach();
249
259
 
250
- // run the combine for the sink
251
- pipeline.sink->Combine(context, *pipeline.sink->sink_state, *local_sink_state);
260
+ return PipelineExecuteResult::INTERRUPTED;
261
+ }
262
+ #endif
263
+ auto result = pipeline.sink->Combine(context, combine_input);
252
264
 
265
+ if (result == SinkCombineResultType::BLOCKED) {
266
+ return PipelineExecuteResult::INTERRUPTED;
267
+ }
268
+
269
+ finalized = true;
253
270
  // flush all query profiler info
254
271
  for (idx_t i = 0; i < intermediate_states.size(); i++) {
255
272
  intermediate_states[i]->Finalize(pipeline.operators[i].get(), context);
256
273
  }
257
274
  pipeline.executor.Flush(thread);
258
275
  local_sink_state.reset();
276
+
277
+ return PipelineExecuteResult::FINISHED;
259
278
  }
260
279
 
261
280
  // TODO: Refactoring the StreamingQueryResult to use Push-based execution should eliminate the need for this code
@@ -1,16 +1,70 @@
1
1
  #include "duckdb/parallel/pipeline_finish_event.hpp"
2
2
  #include "duckdb/execution/executor.hpp"
3
+ #include "duckdb/parallel/interrupt.hpp"
3
4
 
4
5
  namespace duckdb {
5
6
 
7
+ //! The PipelineFinishTask calls Finalize on the sink. Note that this is a single-threaded operation, but is executed
8
+ //! in a task to allow the Finalize call to block (e.g. for async I/O)
9
+ class PipelineFinishTask : public ExecutorTask {
10
+ public:
11
+ explicit PipelineFinishTask(Pipeline &pipeline_p, shared_ptr<Event> event_p)
12
+ : ExecutorTask(pipeline_p.executor), pipeline(pipeline_p), event(std::move(event_p)) {
13
+ }
14
+
15
+ Pipeline &pipeline;
16
+ shared_ptr<Event> event;
17
+
18
+ public:
19
+ TaskExecutionResult ExecuteTask(TaskExecutionMode mode) override {
20
+ auto sink = pipeline.GetSink();
21
+ InterruptState interrupt_state(shared_from_this());
22
+ OperatorSinkFinalizeInput finalize_input {*sink->sink_state, interrupt_state};
23
+
24
+ #ifdef DUCKDB_DEBUG_ASYNC_SINK_SOURCE
25
+ if (debug_blocked_count < debug_blocked_target_count) {
26
+ debug_blocked_count++;
27
+
28
+ auto &callback_state = interrupt_state;
29
+ std::thread rewake_thread([callback_state] {
30
+ std::this_thread::sleep_for(std::chrono::milliseconds(1));
31
+ callback_state.Callback();
32
+ });
33
+ rewake_thread.detach();
34
+
35
+ return TaskExecutionResult::TASK_BLOCKED;
36
+ }
37
+ #endif
38
+ auto sink_state = sink->Finalize(pipeline, *event, executor.context, finalize_input);
39
+
40
+ if (sink_state == SinkFinalizeType::BLOCKED) {
41
+ return TaskExecutionResult::TASK_BLOCKED;
42
+ }
43
+
44
+ sink->sink_state->state = sink_state;
45
+ event->FinishTask();
46
+ return TaskExecutionResult::TASK_FINISHED;
47
+ }
48
+
49
+ private:
50
+ #ifdef DUCKDB_DEBUG_ASYNC_SINK_SOURCE
51
+ //! Debugging state: number of times blocked
52
+ int debug_blocked_count = 0;
53
+ //! Number of times the Finalize will block before actually returning data
54
+ int debug_blocked_target_count = 1;
55
+ #endif
56
+ };
57
+
6
58
  PipelineFinishEvent::PipelineFinishEvent(shared_ptr<Pipeline> pipeline_p) : BasePipelineEvent(std::move(pipeline_p)) {
7
59
  }
8
60
 
9
61
  void PipelineFinishEvent::Schedule() {
62
+ vector<shared_ptr<Task>> tasks;
63
+ tasks.push_back(make_uniq<PipelineFinishTask>(*pipeline, shared_from_this()));
64
+ SetTasks(std::move(tasks));
10
65
  }
11
66
 
12
67
  void PipelineFinishEvent::FinishEvent() {
13
- pipeline->Finalize(*this);
14
68
  }
15
69
 
16
70
  } // namespace duckdb