duckdb 0.7.2-dev2867.0 → 0.7.2-dev3117.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 (319) hide show
  1. package/binding.gyp +2 -0
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/icu/icu-datepart.cpp +5 -1
  4. package/src/duckdb/extension/json/include/json_deserializer.hpp +1 -0
  5. package/src/duckdb/extension/json/include/json_serializer.hpp +8 -1
  6. package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +1 -3
  7. package/src/duckdb/extension/json/json_functions/json_structure.cpp +3 -3
  8. package/src/duckdb/extension/json/json_functions/json_transform.cpp +3 -2
  9. package/src/duckdb/extension/parquet/parquet-extension.cpp +9 -7
  10. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +18 -7
  11. package/src/duckdb/src/catalog/default/default_functions.cpp +2 -0
  12. package/src/duckdb/src/common/arrow/arrow_appender.cpp +3 -3
  13. package/src/duckdb/src/common/arrow/arrow_converter.cpp +2 -2
  14. package/src/duckdb/src/common/enum_util.cpp +5908 -0
  15. package/src/duckdb/src/common/enums/expression_type.cpp +216 -4
  16. package/src/duckdb/src/common/enums/join_type.cpp +6 -5
  17. package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
  18. package/src/duckdb/src/common/exception.cpp +1 -1
  19. package/src/duckdb/src/common/exception_format_value.cpp +2 -2
  20. package/src/duckdb/src/common/multi_file_reader.cpp +14 -0
  21. package/src/duckdb/src/common/serializer/binary_deserializer.cpp +143 -0
  22. package/src/duckdb/src/common/serializer/binary_serializer.cpp +160 -0
  23. package/src/duckdb/src/common/sort/partition_state.cpp +1 -1
  24. package/src/duckdb/src/common/string_util.cpp +6 -1
  25. package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +3 -3
  26. package/src/duckdb/src/common/types.cpp +11 -10
  27. package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +4 -4
  28. package/src/duckdb/src/core_functions/function_list.cpp +2 -0
  29. package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +2 -1
  30. package/src/duckdb/src/core_functions/scalar/list/list_sort.cpp +2 -3
  31. package/src/duckdb/src/core_functions/scalar/string/format_bytes.cpp +29 -0
  32. package/src/duckdb/src/execution/aggregate_hashtable.cpp +3 -3
  33. package/src/duckdb/src/execution/index/art/art.cpp +5 -1
  34. package/src/duckdb/src/execution/operator/aggregate/distinct_aggregate_data.cpp +1 -1
  35. package/src/duckdb/src/execution/operator/aggregate/grouped_aggregate_data.cpp +2 -2
  36. package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +65 -45
  37. package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +17 -11
  38. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +32 -39
  39. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +10 -9
  40. package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +4 -4
  41. package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +6 -21
  42. package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +13 -13
  43. package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +15 -14
  44. package/src/duckdb/src/execution/operator/helper/physical_load.cpp +3 -2
  45. package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +4 -4
  46. package/src/duckdb/src/execution/operator/helper/physical_pragma.cpp +4 -2
  47. package/src/duckdb/src/execution/operator/helper/physical_prepare.cpp +4 -2
  48. package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +10 -8
  49. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +4 -3
  50. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +7 -6
  51. package/src/duckdb/src/execution/operator/helper/physical_streaming_sample.cpp +2 -1
  52. package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +4 -2
  53. package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +8 -8
  54. package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +17 -16
  55. package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +12 -9
  56. package/src/duckdb/src/execution/operator/join/physical_comparison_join.cpp +2 -1
  57. package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +3 -4
  58. package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +5 -5
  59. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +16 -15
  60. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +13 -12
  61. package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +12 -10
  62. package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +13 -11
  63. package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +8 -6
  64. package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
  65. package/src/duckdb/src/execution/operator/order/physical_order.cpp +13 -13
  66. package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +8 -8
  67. package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +165 -0
  68. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +160 -145
  69. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +11 -26
  70. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +14 -19
  71. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +7 -6
  72. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +18 -30
  73. package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +14 -18
  74. package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +6 -4
  75. package/src/duckdb/src/execution/operator/scan/physical_dummy_scan.cpp +4 -19
  76. package/src/duckdb/src/execution/operator/scan/physical_empty_result.cpp +3 -2
  77. package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +14 -5
  78. package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +6 -4
  79. package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +3 -19
  80. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +13 -25
  81. package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +4 -19
  82. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +8 -9
  83. package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +4 -19
  84. package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +4 -19
  85. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +4 -19
  86. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +9 -26
  87. package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +4 -19
  88. package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +4 -19
  89. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +3 -19
  90. package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +9 -8
  91. package/src/duckdb/src/execution/operator/set/physical_union.cpp +1 -1
  92. package/src/duckdb/src/execution/partitionable_hashtable.cpp +2 -2
  93. package/src/duckdb/src/execution/physical_operator.cpp +11 -5
  94. package/src/duckdb/src/execution/physical_plan/plan_copy_to_file.cpp +25 -4
  95. package/src/duckdb/src/execution/physical_plan/plan_sample.cpp +2 -1
  96. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +16 -16
  97. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +5 -4
  98. package/src/duckdb/src/function/table/arrow_conversion.cpp +3 -3
  99. package/src/duckdb/src/function/table/copy_csv.cpp +85 -29
  100. package/src/duckdb/src/function/table/read_csv.cpp +17 -11
  101. package/src/duckdb/src/function/table/system/duckdb_settings.cpp +2 -1
  102. package/src/duckdb/src/function/table/system/duckdb_types.cpp +2 -1
  103. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  104. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +7 -1
  105. package/src/duckdb/src/include/duckdb/common/enum_util.hpp +958 -0
  106. package/src/duckdb/src/include/duckdb/common/enums/join_type.hpp +3 -3
  107. package/src/duckdb/src/include/duckdb/common/enums/operator_result_type.hpp +16 -4
  108. package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
  109. package/src/duckdb/src/include/duckdb/common/exception.hpp +4 -4
  110. package/src/duckdb/src/include/duckdb/common/exception_format_value.hpp +3 -2
  111. package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +44 -0
  112. package/src/duckdb/src/include/duckdb/common/optional_idx.hpp +45 -0
  113. package/src/duckdb/src/include/duckdb/common/serializer/binary_deserializer.hpp +93 -0
  114. package/src/duckdb/src/include/duckdb/common/serializer/binary_serializer.hpp +92 -0
  115. package/src/duckdb/src/include/duckdb/common/serializer/format_deserializer.hpp +7 -3
  116. package/src/duckdb/src/include/duckdb/common/serializer/format_serializer.hpp +2 -2
  117. package/src/duckdb/src/include/duckdb/common/set.hpp +2 -1
  118. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +1 -1
  119. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_segment.hpp +1 -1
  120. package/src/duckdb/src/include/duckdb/common/types.hpp +1 -0
  121. package/src/duckdb/src/include/duckdb/common/vector.hpp +61 -14
  122. package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +15 -0
  123. package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +3 -2
  124. package/src/duckdb/src/include/duckdb/execution/executor.hpp +10 -1
  125. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/distinct_aggregate_data.hpp +2 -2
  126. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/grouped_aggregate_data.hpp +2 -2
  127. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +8 -11
  128. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +2 -4
  129. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +3 -7
  130. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +2 -4
  131. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +1 -2
  132. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +2 -5
  133. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +2 -4
  134. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit_percent.hpp +2 -4
  135. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_load.hpp +1 -2
  136. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +1 -2
  137. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_pragma.hpp +1 -2
  138. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_prepare.hpp +1 -2
  139. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +2 -4
  140. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reset.hpp +1 -2
  141. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +1 -2
  142. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_transaction.hpp +1 -2
  143. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +2 -4
  144. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +2 -4
  145. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +2 -4
  146. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -2
  147. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +1 -2
  148. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +2 -4
  149. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +2 -4
  150. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_nested_loop_join.hpp +2 -4
  151. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +2 -4
  152. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +2 -4
  153. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +2 -4
  154. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +2 -4
  155. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_copy_to_file.hpp +68 -0
  156. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +3 -5
  157. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +4 -5
  158. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_delete.hpp +2 -4
  159. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +2 -4
  160. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -4
  161. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +2 -4
  162. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +1 -2
  163. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_dummy_scan.hpp +1 -3
  164. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_empty_result.hpp +1 -2
  165. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_positional_scan.hpp +1 -2
  166. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +1 -2
  167. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_alter.hpp +1 -3
  168. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +1 -3
  169. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_function.hpp +1 -3
  170. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +2 -4
  171. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_schema.hpp +1 -3
  172. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_sequence.hpp +1 -3
  173. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +1 -3
  174. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +2 -5
  175. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_view.hpp +1 -3
  176. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +1 -3
  177. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_drop.hpp +1 -3
  178. package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +2 -4
  179. package/src/duckdb/src/include/duckdb/execution/partitionable_hashtable.hpp +3 -3
  180. package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +7 -4
  181. package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +26 -6
  182. package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +6 -6
  183. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +2 -1
  184. package/src/duckdb/src/include/duckdb/function/copy_function.hpp +32 -4
  185. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +4 -2
  186. package/src/duckdb/src/include/duckdb/function/table_function.hpp +0 -1
  187. package/src/duckdb/src/include/duckdb/main/client_config.hpp +2 -0
  188. package/src/duckdb/src/include/duckdb/main/config.hpp +4 -0
  189. package/src/duckdb/src/include/duckdb/main/database.hpp +1 -3
  190. package/src/duckdb/src/include/duckdb/main/database_path_and_type.hpp +24 -0
  191. package/src/duckdb/src/include/duckdb/main/relation/setop_relation.hpp +1 -0
  192. package/src/duckdb/src/include/duckdb/parallel/event.hpp +1 -1
  193. package/src/duckdb/src/include/duckdb/parallel/interrupt.hpp +63 -0
  194. package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +16 -3
  195. package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +51 -7
  196. package/src/duckdb/src/include/duckdb/parallel/task.hpp +21 -2
  197. package/src/duckdb/src/include/duckdb/parallel/task_counter.hpp +2 -2
  198. package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +2 -2
  199. package/src/duckdb/src/include/duckdb/parser/parsed_data/sample_options.hpp +1 -0
  200. package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +6 -0
  201. package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +1 -0
  202. package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +2 -0
  203. package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +2 -0
  204. package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +2 -1
  205. package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +1 -0
  206. package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +1 -0
  207. package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +1 -0
  208. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +1 -0
  209. package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +1 -0
  210. package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +1 -0
  211. package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +1 -0
  212. package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +1 -0
  213. package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +1 -0
  214. package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +1 -0
  215. package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +1 -0
  216. package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +1 -0
  217. package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +1 -0
  218. package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +1 -0
  219. package/src/duckdb/src/include/duckdb/planner/query_node/bound_select_node.hpp +1 -1
  220. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -0
  221. package/src/duckdb/src/include/duckdb/storage/optimistic_data_writer.hpp +46 -0
  222. package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +24 -3
  223. package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +46 -1
  224. package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +9 -10
  225. package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +1 -1
  226. package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +2 -2
  227. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +3 -3
  228. package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -0
  229. package/src/duckdb/src/include/duckdb/storage/table/segment_base.hpp +1 -1
  230. package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +22 -0
  231. package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +3 -3
  232. package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +2 -2
  233. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +0 -2
  234. package/src/duckdb/src/include/duckdb/storage/table/validity_column_data.hpp +1 -2
  235. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +9 -34
  236. package/src/duckdb/src/include/duckdb/verification/deserialized_statement_verifier_v2.hpp +26 -0
  237. package/src/duckdb/src/include/duckdb/verification/no_operator_caching_verifier.hpp +25 -0
  238. package/src/duckdb/src/include/duckdb/verification/statement_verifier.hpp +6 -0
  239. package/src/duckdb/src/main/client_context.cpp +1 -0
  240. package/src/duckdb/src/main/client_verify.cpp +5 -0
  241. package/src/duckdb/src/main/config.cpp +4 -0
  242. package/src/duckdb/src/main/database.cpp +22 -34
  243. package/src/duckdb/src/main/database_path_and_type.cpp +23 -0
  244. package/src/duckdb/src/main/extension/extension_load.cpp +19 -15
  245. package/src/duckdb/src/main/relation/join_relation.cpp +2 -1
  246. package/src/duckdb/src/main/relation/setop_relation.cpp +2 -3
  247. package/src/duckdb/src/parallel/event.cpp +1 -1
  248. package/src/duckdb/src/parallel/executor.cpp +39 -3
  249. package/src/duckdb/src/parallel/executor_task.cpp +11 -0
  250. package/src/duckdb/src/parallel/interrupt.cpp +57 -0
  251. package/src/duckdb/src/parallel/pipeline.cpp +49 -6
  252. package/src/duckdb/src/parallel/pipeline_executor.cpp +248 -69
  253. package/src/duckdb/src/parallel/pipeline_initialize_event.cpp +1 -1
  254. package/src/duckdb/src/parallel/task_scheduler.cpp +57 -22
  255. package/src/duckdb/src/parser/base_expression.cpp +6 -0
  256. package/src/duckdb/src/parser/expression/window_expression.cpp +1 -1
  257. package/src/duckdb/src/parser/parsed_data/sample_options.cpp +2 -2
  258. package/src/duckdb/src/parser/query_node/select_node.cpp +1 -1
  259. package/src/duckdb/src/parser/result_modifier.cpp +2 -2
  260. package/src/duckdb/src/parser/statement/select_statement.cpp +0 -44
  261. package/src/duckdb/src/parser/tableref/joinref.cpp +3 -3
  262. package/src/duckdb/src/parser/tableref.cpp +1 -1
  263. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +3 -3
  264. package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +6 -0
  265. package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +4 -1
  266. package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +17 -3
  267. package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +8 -2
  268. package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +7 -0
  269. package/src/duckdb/src/planner/operator/logical_aggregate.cpp +14 -2
  270. package/src/duckdb/src/planner/operator/logical_column_data_get.cpp +11 -0
  271. package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +2 -2
  272. package/src/duckdb/src/planner/operator/logical_cteref.cpp +11 -0
  273. package/src/duckdb/src/planner/operator/logical_delete.cpp +10 -0
  274. package/src/duckdb/src/planner/operator/logical_delim_get.cpp +12 -1
  275. package/src/duckdb/src/planner/operator/logical_dummy_scan.cpp +12 -1
  276. package/src/duckdb/src/planner/operator/logical_expression_get.cpp +12 -1
  277. package/src/duckdb/src/planner/operator/logical_get.cpp +10 -4
  278. package/src/duckdb/src/planner/operator/logical_insert.cpp +12 -1
  279. package/src/duckdb/src/planner/operator/logical_pivot.cpp +11 -0
  280. package/src/duckdb/src/planner/operator/logical_projection.cpp +11 -0
  281. package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +11 -0
  282. package/src/duckdb/src/planner/operator/logical_set_operation.cpp +11 -0
  283. package/src/duckdb/src/planner/operator/logical_unnest.cpp +12 -1
  284. package/src/duckdb/src/planner/operator/logical_update.cpp +10 -0
  285. package/src/duckdb/src/planner/operator/logical_window.cpp +11 -0
  286. package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -1
  287. package/src/duckdb/src/storage/data_table.cpp +5 -0
  288. package/src/duckdb/src/storage/local_storage.cpp +40 -110
  289. package/src/duckdb/src/storage/optimistic_data_writer.cpp +96 -0
  290. package/src/duckdb/src/storage/partial_block_manager.cpp +73 -9
  291. package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -1
  292. package/src/duckdb/src/storage/standard_buffer_manager.cpp +17 -12
  293. package/src/duckdb/src/storage/statistics/base_statistics.cpp +3 -0
  294. package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +90 -82
  295. package/src/duckdb/src/storage/table/column_data.cpp +19 -45
  296. package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +7 -7
  297. package/src/duckdb/src/storage/table/column_segment.cpp +1 -1
  298. package/src/duckdb/src/storage/table/list_column_data.cpp +6 -11
  299. package/src/duckdb/src/storage/table/row_group.cpp +13 -14
  300. package/src/duckdb/src/storage/table/row_group_collection.cpp +10 -4
  301. package/src/duckdb/src/storage/table/standard_column_data.cpp +6 -10
  302. package/src/duckdb/src/storage/table/struct_column_data.cpp +7 -13
  303. package/src/duckdb/src/storage/table/update_segment.cpp +0 -25
  304. package/src/duckdb/src/storage/table/validity_column_data.cpp +2 -6
  305. package/src/duckdb/src/transaction/commit_state.cpp +4 -4
  306. package/src/duckdb/src/verification/deserialized_statement_verifier.cpp +2 -1
  307. package/src/duckdb/src/verification/deserialized_statement_verifier_v2.cpp +20 -0
  308. package/src/duckdb/src/verification/no_operator_caching_verifier.cpp +13 -0
  309. package/src/duckdb/src/verification/statement_verifier.cpp +7 -0
  310. package/src/duckdb/ub_src_common.cpp +2 -2
  311. package/src/duckdb/ub_src_common_serializer.cpp +4 -2
  312. package/src/duckdb/ub_src_core_functions_scalar_string.cpp +2 -0
  313. package/src/duckdb/ub_src_execution_operator_persistent.cpp +2 -0
  314. package/src/duckdb/ub_src_main.cpp +2 -0
  315. package/src/duckdb/ub_src_parallel.cpp +2 -0
  316. package/src/duckdb/ub_src_storage.cpp +2 -0
  317. package/src/duckdb/src/common/serializer/enum_serializer.cpp +0 -1180
  318. package/src/duckdb/src/common/vector.cpp +0 -12
  319. package/src/duckdb/src/include/duckdb/common/serializer/enum_serializer.hpp +0 -113
@@ -28,7 +28,7 @@
28
28
  #include "duckdb/parser/parser.hpp"
29
29
 
30
30
  #include "duckdb/common/serializer/format_deserializer.hpp"
31
- #include "duckdb/common/serializer/enum_serializer.hpp"
31
+ #include "duckdb/common/enum_util.hpp"
32
32
  #include "duckdb/common/serializer/format_serializer.hpp"
33
33
 
34
34
  #include <cmath>
@@ -158,6 +158,11 @@ PhysicalType LogicalType::GetInternalType() {
158
158
  }
159
159
  }
160
160
 
161
+ // **DEPRECATED**: Use EnumUtil directly instead.
162
+ string LogicalTypeIdToString(LogicalTypeId type) {
163
+ return EnumUtil::ToString(type);
164
+ }
165
+
161
166
  constexpr const LogicalTypeId LogicalType::INVALID;
162
167
  constexpr const LogicalTypeId LogicalType::SQLNULL;
163
168
  constexpr const LogicalTypeId LogicalType::BOOLEAN;
@@ -331,10 +336,6 @@ bool TypeIsInteger(PhysicalType type) {
331
336
  return (type >= PhysicalType::UINT8 && type <= PhysicalType::INT64) || type == PhysicalType::INT128;
332
337
  }
333
338
 
334
- string LogicalTypeIdToString(LogicalTypeId id) {
335
- return EnumSerializer::EnumToString(id);
336
- }
337
-
338
339
  string LogicalType::ToString() const {
339
340
  auto alias = GetAlias();
340
341
  if (!alias.empty()) {
@@ -406,7 +407,7 @@ string LogicalType::ToString() const {
406
407
  return AggregateStateType::GetTypeName(*this);
407
408
  }
408
409
  default:
409
- return LogicalTypeIdToString(id_);
410
+ return EnumUtil::ToString(id_);
410
411
  }
411
412
  }
412
413
  // LCOV_EXCL_STOP
@@ -1566,17 +1567,18 @@ void ExtraTypeInfo::Serialize(ExtraTypeInfo *info, FieldWriter &writer) {
1566
1567
  }
1567
1568
  void ExtraTypeInfo::FormatSerialize(FormatSerializer &serializer) const {
1568
1569
  serializer.WriteProperty("type", type);
1570
+ // BREAKING: we used to write the alias last if there was additional type info, but now we write it second.
1569
1571
  serializer.WriteProperty("alias", alias);
1570
1572
  }
1571
1573
 
1572
1574
  shared_ptr<ExtraTypeInfo> ExtraTypeInfo::FormatDeserialize(FormatDeserializer &deserializer) {
1573
1575
  auto type = deserializer.ReadProperty<ExtraTypeInfoType>("type");
1576
+ auto alias = deserializer.ReadProperty<string>("alias");
1577
+ // BREAKING: we used to read the alias last, but now we read it second.
1574
1578
 
1575
1579
  shared_ptr<ExtraTypeInfo> result;
1576
1580
  switch (type) {
1577
1581
  case ExtraTypeInfoType::INVALID_TYPE_INFO: {
1578
- string alias;
1579
- deserializer.ReadOptionalProperty("alias", alias);
1580
1582
  if (!alias.empty()) {
1581
1583
  return make_shared<ExtraTypeInfo>(type, alias);
1582
1584
  }
@@ -1620,11 +1622,10 @@ shared_ptr<ExtraTypeInfo> ExtraTypeInfo::FormatDeserialize(FormatDeserializer &d
1620
1622
  case ExtraTypeInfoType::AGGREGATE_STATE_TYPE_INFO:
1621
1623
  result = AggregateStateTypeInfo::FormatDeserialize(deserializer);
1622
1624
  break;
1623
-
1624
1625
  default:
1625
1626
  throw InternalException("Unimplemented type info in ExtraTypeInfo::Deserialize");
1626
1627
  }
1627
- deserializer.ReadOptionalPropertyOrDefault("alias", result->alias, string());
1628
+ result->alias = alias;
1628
1629
  return result;
1629
1630
  }
1630
1631
 
@@ -900,15 +900,15 @@ idx_t VectorOperations::DistinctLessThan(Vector &left, Vector &right, const Sele
900
900
  // true := A < B with nulls being minimal
901
901
  idx_t VectorOperations::DistinctLessThanNullsFirst(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
902
902
  SelectionVector *true_sel, SelectionVector *false_sel) {
903
- return TemplatedDistinctSelectOperation<duckdb::DistinctLessThanNullsFirst, duckdb::DistinctLessThan>(
904
- left, right, sel, count, true_sel, false_sel);
903
+ return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanNullsFirst, duckdb::DistinctGreaterThan>(
904
+ right, left, sel, count, true_sel, false_sel);
905
905
  }
906
906
 
907
907
  // true := A <= B with nulls being maximal
908
908
  idx_t VectorOperations::DistinctLessThanEquals(Vector &left, Vector &right, const SelectionVector *sel, idx_t count,
909
909
  SelectionVector *true_sel, SelectionVector *false_sel) {
910
- return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanEquals>(right, left, sel, count, true_sel,
911
- false_sel);
910
+ return count -
911
+ TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThan>(left, right, sel, count, false_sel, true_sel);
912
912
  }
913
913
 
914
914
  // true := A != B with nulls being equal, inputs selected
@@ -148,6 +148,8 @@ static StaticFunctionDefinition internal_functions[] = {
148
148
  DUCKDB_SCALAR_FUNCTION(ListFlattenFun),
149
149
  DUCKDB_SCALAR_FUNCTION_SET(FloorFun),
150
150
  DUCKDB_SCALAR_FUNCTION(FormatFun),
151
+ DUCKDB_SCALAR_FUNCTION_ALIAS(FormatreadabledecimalsizeFun),
152
+ DUCKDB_SCALAR_FUNCTION(FormatBytesFun),
151
153
  DUCKDB_SCALAR_FUNCTION(FromBase64Fun),
152
154
  DUCKDB_SCALAR_FUNCTION_ALIAS(FromBinaryFun),
153
155
  DUCKDB_SCALAR_FUNCTION_ALIAS(FromHexFun),
@@ -3,6 +3,7 @@
3
3
  #include "duckdb/common/enums/date_part_specifier.hpp"
4
4
  #include "duckdb/common/exception.hpp"
5
5
  #include "duckdb/common/string_util.hpp"
6
+ #include "duckdb/common/enum_util.hpp"
6
7
  #include "duckdb/common/types/date.hpp"
7
8
  #include "duckdb/common/types/timestamp.hpp"
8
9
  #include "duckdb/common/vector_operations/vector_operations.hpp"
@@ -81,7 +82,7 @@ DatePartSpecifier GetDateTypePartSpecifier(const string &specifier, LogicalType
81
82
  break;
82
83
  }
83
84
 
84
- throw NotImplementedException("\"%s\" units \"%s\" not recognized", LogicalTypeIdToString(type.id()), specifier);
85
+ throw NotImplementedException("\"%s\" units \"%s\" not recognized", EnumUtil::ToString(type.id()), specifier);
85
86
  }
86
87
 
87
88
  template <int64_t MIN, int64_t MAX>
@@ -1,11 +1,10 @@
1
1
  #include "duckdb/core_functions/scalar/list_functions.hpp"
2
- #include "duckdb/common/serializer/enum_serializer.hpp"
2
+ #include "duckdb/common/enum_util.hpp"
3
3
  #include "duckdb/common/types/chunk_collection.hpp"
4
4
  #include "duckdb/planner/expression/bound_function_expression.hpp"
5
5
  #include "duckdb/execution/expression_executor.hpp"
6
6
  #include "duckdb/planner/expression/bound_reference_expression.hpp"
7
7
  #include "duckdb/main/config.hpp"
8
-
9
8
  #include "duckdb/common/sort/sort.hpp"
10
9
 
11
10
  namespace duckdb {
@@ -251,7 +250,7 @@ static T GetOrder(ClientContext &context, Expression &expr) {
251
250
  }
252
251
  Value order_value = ExpressionExecutor::EvaluateScalar(context, expr);
253
252
  auto order_name = StringUtil::Upper(order_value.ToString());
254
- return EnumSerializer::StringToEnum<T>(order_name.c_str());
253
+ return EnumUtil::FromString<T>(order_name.c_str());
255
254
  }
256
255
 
257
256
  static unique_ptr<FunctionData> ListNormalSortBind(ClientContext &context, ScalarFunction &bound_function,
@@ -0,0 +1,29 @@
1
+ #include "duckdb/core_functions/scalar/string_functions.hpp"
2
+ #include "duckdb/common/types/data_chunk.hpp"
3
+ #include "duckdb/common/string_util.hpp"
4
+
5
+ namespace duckdb {
6
+
7
+ static void FormatBytesFunction(DataChunk &args, ExpressionState &state, Vector &result) {
8
+ UnaryExecutor::Execute<int64_t, string_t>(args.data[0], result, args.size(), [&](int64_t bytes) {
9
+ bool is_negative = bytes < 0;
10
+ idx_t unsigned_bytes;
11
+ if (bytes < 0) {
12
+ if (bytes == NumericLimits<int64_t>::Minimum()) {
13
+ unsigned_bytes = idx_t(NumericLimits<int64_t>::Maximum()) + 1;
14
+ } else {
15
+ unsigned_bytes = idx_t(-bytes);
16
+ }
17
+ } else {
18
+ unsigned_bytes = idx_t(bytes);
19
+ }
20
+ return StringVector::AddString(result, (is_negative ? "-" : "") +
21
+ StringUtil::BytesToHumanReadableString(unsigned_bytes));
22
+ });
23
+ }
24
+
25
+ ScalarFunction FormatBytesFun::GetFunction() {
26
+ return ScalarFunction({LogicalType::BIGINT}, LogicalType::VARCHAR, FormatBytesFunction);
27
+ }
28
+
29
+ } // namespace duckdb
@@ -236,7 +236,7 @@ void GroupedAggregateHashTable::Resize(idx_t size) {
236
236
 
237
237
  idx_t GroupedAggregateHashTable::AddChunk(AggregateHTAppendState &state, DataChunk &groups, DataChunk &payload,
238
238
  AggregateType filter) {
239
- vector<idx_t> aggregate_filter;
239
+ unsafe_vector<idx_t> aggregate_filter;
240
240
 
241
241
  auto &aggregates = layout.GetAggregates();
242
242
  for (idx_t i = 0; i < aggregates.size(); i++) {
@@ -249,7 +249,7 @@ idx_t GroupedAggregateHashTable::AddChunk(AggregateHTAppendState &state, DataChu
249
249
  }
250
250
 
251
251
  idx_t GroupedAggregateHashTable::AddChunk(AggregateHTAppendState &state, DataChunk &groups, DataChunk &payload,
252
- const vector<idx_t> &filter) {
252
+ const unsafe_vector<idx_t> &filter) {
253
253
  Vector hashes(LogicalType::HASH);
254
254
  groups.Hash(hashes);
255
255
 
@@ -257,7 +257,7 @@ idx_t GroupedAggregateHashTable::AddChunk(AggregateHTAppendState &state, DataChu
257
257
  }
258
258
 
259
259
  idx_t GroupedAggregateHashTable::AddChunk(AggregateHTAppendState &state, DataChunk &groups, Vector &group_hashes,
260
- DataChunk &payload, const vector<idx_t> &filter) {
260
+ DataChunk &payload, const unsafe_vector<idx_t> &filter) {
261
261
  D_ASSERT(!is_finalized);
262
262
  if (groups.size() == 0) {
263
263
  return 0;
@@ -879,7 +879,11 @@ string ART::GenerateConstraintErrorMessage(VerifyExistenceType verify_type, cons
879
879
  case VerifyExistenceType::APPEND: {
880
880
  // APPEND to PK/UNIQUE table, but node/key already exists in PK/UNIQUE table
881
881
  string type = IsPrimary() ? "primary key" : "unique";
882
- return StringUtil::Format("Duplicate key \"%s\" violates %s constraint", key_name, type);
882
+ return StringUtil::Format(
883
+ "Duplicate key \"%s\" violates %s constraint. "
884
+ "If this is an unexpected constraint violation please double "
885
+ "check with the known index limitations section in our documentation (docs - sql - indexes).",
886
+ key_name, type);
883
887
  }
884
888
  case VerifyExistenceType::APPEND_FK: {
885
889
  // APPEND_FK to FK table, node/key does not exist in PK/UNIQUE table
@@ -171,7 +171,7 @@ bool DistinctAggregateCollectionInfo::AnyDistinct() const {
171
171
  return !indices.empty();
172
172
  }
173
173
 
174
- const vector<idx_t> &DistinctAggregateCollectionInfo::Indices() const {
174
+ const unsafe_vector<idx_t> &DistinctAggregateCollectionInfo::Indices() const {
175
175
  return this->indices;
176
176
  }
177
177
 
@@ -12,7 +12,7 @@ const vector<vector<idx_t>> &GroupedAggregateData::GetGroupingFunctions() const
12
12
 
13
13
  void GroupedAggregateData::InitializeGroupby(vector<unique_ptr<Expression>> groups,
14
14
  vector<unique_ptr<Expression>> expressions,
15
- vector<vector<idx_t>> grouping_functions) {
15
+ vector<unsafe_vector<idx_t>> grouping_functions) {
16
16
  InitializeGroupbyGroups(std::move(groups));
17
17
  vector<LogicalType> payload_types_filters;
18
18
 
@@ -86,7 +86,7 @@ void GroupedAggregateData::InitializeGroupbyGroups(vector<unique_ptr<Expression>
86
86
  this->groups = std::move(groups);
87
87
  }
88
88
 
89
- void GroupedAggregateData::SetGroupingFunctions(vector<vector<idx_t>> &functions) {
89
+ void GroupedAggregateData::SetGroupingFunctions(vector<unsafe_vector<idx_t>> &functions) {
90
90
  grouping_functions.reserve(functions.size());
91
91
  for (idx_t i = 0; i < functions.size(); i++) {
92
92
  grouping_functions.push_back(std::move(functions[i]));
@@ -4,6 +4,7 @@
4
4
  #include "duckdb/common/vector_operations/vector_operations.hpp"
5
5
  #include "duckdb/execution/aggregate_hashtable.hpp"
6
6
  #include "duckdb/main/client_context.hpp"
7
+ #include "duckdb/parallel/interrupt.hpp"
7
8
  #include "duckdb/parallel/pipeline.hpp"
8
9
  #include "duckdb/parallel/task_scheduler.hpp"
9
10
  #include "duckdb/parallel/thread_context.hpp"
@@ -116,7 +117,8 @@ PhysicalHashAggregate::PhysicalHashAggregate(ClientContext &context, vector<Logi
116
117
  vector<unique_ptr<Expression>> expressions,
117
118
  vector<unique_ptr<Expression>> groups_p,
118
119
  vector<GroupingSet> grouping_sets_p,
119
- vector<vector<idx_t>> grouping_functions_p, idx_t estimated_cardinality)
120
+ vector<unsafe_vector<idx_t>> grouping_functions_p,
121
+ idx_t estimated_cardinality)
120
122
  : PhysicalOperator(PhysicalOperatorType::HASH_GROUP_BY, std::move(types), estimated_cardinality),
121
123
  grouping_sets(std::move(grouping_sets_p)) {
122
124
  // get a list of all aggregates to be computed
@@ -250,10 +252,10 @@ unique_ptr<LocalSinkState> PhysicalHashAggregate::GetLocalSinkState(ExecutionCon
250
252
  return make_uniq<HashAggregateLocalState>(*this, context);
251
253
  }
252
254
 
253
- void PhysicalHashAggregate::SinkDistinctGrouping(ExecutionContext &context, GlobalSinkState &state,
254
- LocalSinkState &lstate, DataChunk &input, idx_t grouping_idx) const {
255
- auto &sink = lstate.Cast<HashAggregateLocalState>();
256
- auto &global_sink = state.Cast<HashAggregateGlobalState>();
255
+ void PhysicalHashAggregate::SinkDistinctGrouping(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input,
256
+ idx_t grouping_idx) const {
257
+ auto &sink = input.local_state.Cast<HashAggregateLocalState>();
258
+ auto &global_sink = input.global_state.Cast<HashAggregateGlobalState>();
257
259
 
258
260
  auto &grouping_gstate = global_sink.grouping_states[grouping_idx];
259
261
  auto &grouping_lstate = sink.grouping_states[grouping_idx];
@@ -265,7 +267,7 @@ void PhysicalHashAggregate::SinkDistinctGrouping(ExecutionContext &context, Glob
265
267
  DataChunk empty_chunk;
266
268
 
267
269
  // Create an empty filter for Sink, since we don't need to update any aggregate states here
268
- vector<idx_t> empty_filter;
270
+ unsafe_vector<idx_t> empty_filter;
269
271
 
270
272
  for (idx_t &idx : distinct_info.indices) {
271
273
  auto &aggregate = grouped_aggregate_data.aggregates[idx]->Cast<BoundAggregateExpression>();
@@ -280,6 +282,9 @@ void PhysicalHashAggregate::SinkDistinctGrouping(ExecutionContext &context, Glob
280
282
  auto &radix_global_sink = *distinct_state->radix_states[table_idx];
281
283
  auto &radix_local_sink = *grouping_lstate.distinct_states[table_idx];
282
284
 
285
+ InterruptState interrupt_state;
286
+ OperatorSinkInput sink_input {radix_global_sink, radix_local_sink, interrupt_state};
287
+
283
288
  if (aggregate.filter) {
284
289
  DataChunk filter_chunk;
285
290
  auto &filtered_data = sink.filter_set.GetFilterData(idx);
@@ -288,10 +293,10 @@ void PhysicalHashAggregate::SinkDistinctGrouping(ExecutionContext &context, Glob
288
293
  // Add the filter Vector (BOOL)
289
294
  auto it = filter_indexes.find(aggregate.filter.get());
290
295
  D_ASSERT(it != filter_indexes.end());
291
- D_ASSERT(it->second < input.data.size());
296
+ D_ASSERT(it->second < chunk.data.size());
292
297
  auto &filter_bound_ref = aggregate.filter->Cast<BoundReferenceExpression>();
293
- filter_chunk.data[filter_bound_ref.index].Reference(input.data[it->second]);
294
- filter_chunk.SetCardinality(input.size());
298
+ filter_chunk.data[filter_bound_ref.index].Reference(chunk.data[it->second]);
299
+ filter_chunk.SetCardinality(chunk.size());
295
300
 
296
301
  // We cant use the AggregateFilterData::ApplyFilter method, because the chunk we need to
297
302
  // apply the filter to also has the groups, and the filtered_data.filtered_payload does not have those.
@@ -305,43 +310,42 @@ void PhysicalHashAggregate::SinkDistinctGrouping(ExecutionContext &context, Glob
305
310
  // Because the 'input' chunk needs to be re-used after this, we need to create
306
311
  // a duplicate of it, that we can apply the filter to
307
312
  DataChunk filtered_input;
308
- filtered_input.InitializeEmpty(input.GetTypes());
313
+ filtered_input.InitializeEmpty(chunk.GetTypes());
309
314
 
310
315
  for (idx_t group_idx = 0; group_idx < grouped_aggregate_data.groups.size(); group_idx++) {
311
316
  auto &group = grouped_aggregate_data.groups[group_idx];
312
317
  auto &bound_ref = group->Cast<BoundReferenceExpression>();
313
- filtered_input.data[bound_ref.index].Reference(input.data[bound_ref.index]);
318
+ filtered_input.data[bound_ref.index].Reference(chunk.data[bound_ref.index]);
314
319
  }
315
320
  for (idx_t child_idx = 0; child_idx < aggregate.children.size(); child_idx++) {
316
321
  auto &child = aggregate.children[child_idx];
317
322
  auto &bound_ref = child->Cast<BoundReferenceExpression>();
318
323
 
319
- filtered_input.data[bound_ref.index].Reference(input.data[bound_ref.index]);
324
+ filtered_input.data[bound_ref.index].Reference(chunk.data[bound_ref.index]);
320
325
  }
321
326
  filtered_input.Slice(sel_vec, count);
322
327
  filtered_input.SetCardinality(count);
323
328
 
324
- radix_table.Sink(context, radix_global_sink, radix_local_sink, filtered_input, empty_chunk, empty_filter);
329
+ radix_table.Sink(context, filtered_input, sink_input, empty_chunk, empty_filter);
325
330
  } else {
326
- radix_table.Sink(context, radix_global_sink, radix_local_sink, input, empty_chunk, empty_filter);
331
+ radix_table.Sink(context, chunk, sink_input, empty_chunk, empty_filter);
327
332
  }
328
333
  }
329
334
  }
330
335
 
331
- void PhysicalHashAggregate::SinkDistinct(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
332
- DataChunk &input) const {
336
+ void PhysicalHashAggregate::SinkDistinct(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const {
333
337
  for (idx_t i = 0; i < groupings.size(); i++) {
334
- SinkDistinctGrouping(context, state, lstate, input, i);
338
+ SinkDistinctGrouping(context, chunk, input, i);
335
339
  }
336
340
  }
337
341
 
338
- SinkResultType PhysicalHashAggregate::Sink(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
339
- DataChunk &input) const {
340
- auto &llstate = lstate.Cast<HashAggregateLocalState>();
341
- auto &gstate = state.Cast<HashAggregateGlobalState>();
342
+ SinkResultType PhysicalHashAggregate::Sink(ExecutionContext &context, DataChunk &chunk,
343
+ OperatorSinkInput &input) const {
344
+ auto &llstate = input.local_state.Cast<HashAggregateLocalState>();
345
+ auto &gstate = input.global_state.Cast<HashAggregateGlobalState>();
342
346
 
343
347
  if (distinct_collection_info) {
344
- SinkDistinct(context, state, lstate, input);
348
+ SinkDistinct(context, chunk, input);
345
349
  }
346
350
 
347
351
  if (CanSkipRegularSink()) {
@@ -359,8 +363,8 @@ SinkResultType PhysicalHashAggregate::Sink(ExecutionContext &context, GlobalSink
359
363
  for (auto &child_expr : aggr.children) {
360
364
  D_ASSERT(child_expr->type == ExpressionType::BOUND_REF);
361
365
  auto &bound_ref_expr = child_expr->Cast<BoundReferenceExpression>();
362
- D_ASSERT(bound_ref_expr.index < input.data.size());
363
- aggregate_input_chunk.data[aggregate_input_idx++].Reference(input.data[bound_ref_expr.index]);
366
+ D_ASSERT(bound_ref_expr.index < chunk.data.size());
367
+ aggregate_input_chunk.data[aggregate_input_idx++].Reference(chunk.data[bound_ref_expr.index]);
364
368
  }
365
369
  }
366
370
  // Populate the filter vectors
@@ -369,23 +373,24 @@ SinkResultType PhysicalHashAggregate::Sink(ExecutionContext &context, GlobalSink
369
373
  if (aggr.filter) {
370
374
  auto it = filter_indexes.find(aggr.filter.get());
371
375
  D_ASSERT(it != filter_indexes.end());
372
- D_ASSERT(it->second < input.data.size());
373
- aggregate_input_chunk.data[aggregate_input_idx++].Reference(input.data[it->second]);
376
+ D_ASSERT(it->second < chunk.data.size());
377
+ aggregate_input_chunk.data[aggregate_input_idx++].Reference(chunk.data[it->second]);
374
378
  }
375
379
  }
376
380
 
377
- aggregate_input_chunk.SetCardinality(input.size());
381
+ aggregate_input_chunk.SetCardinality(chunk.size());
378
382
  aggregate_input_chunk.Verify();
379
383
 
380
384
  // For every grouping set there is one radix_table
381
385
  for (idx_t i = 0; i < groupings.size(); i++) {
382
386
  auto &grouping_gstate = gstate.grouping_states[i];
383
387
  auto &grouping_lstate = llstate.grouping_states[i];
388
+ InterruptState interrupt_state;
389
+ OperatorSinkInput sink_input {*grouping_gstate.table_state, *grouping_lstate.table_state, interrupt_state};
384
390
 
385
391
  auto &grouping = groupings[i];
386
392
  auto &table = grouping.table_data;
387
- table.Sink(context, *grouping_gstate.table_state, *grouping_lstate.table_state, input, aggregate_input_chunk,
388
- non_distinct_filter);
393
+ table.Sink(context, chunk, sink_input, aggregate_input_chunk, non_distinct_filter);
389
394
  }
390
395
 
391
396
  return SinkResultType::NEED_MORE_INPUT;
@@ -452,7 +457,7 @@ public:
452
457
 
453
458
  public:
454
459
  void Schedule() override {
455
- vector<unique_ptr<Task>> tasks;
460
+ vector<shared_ptr<Task>> tasks;
456
461
  for (idx_t i = 0; i < op.groupings.size(); i++) {
457
462
  auto &grouping_gstate = gstate.grouping_states[i];
458
463
 
@@ -504,7 +509,7 @@ public:
504
509
 
505
510
  public:
506
511
  void Schedule() override {
507
- vector<unique_ptr<Task>> tasks;
512
+ vector<shared_ptr<Task>> tasks;
508
513
  tasks.push_back(make_uniq<HashAggregateFinalizeTask>(*pipeline, shared_from_this(), gstate, context, op));
509
514
  D_ASSERT(!tasks.empty());
510
515
  SetTasks(std::move(tasks));
@@ -579,11 +584,18 @@ public:
579
584
  output_chunk.Reset();
580
585
  group_chunk.Reset();
581
586
  aggregate_input_chunk.Reset();
582
- radix_table_p->GetData(temp_exec_context, output_chunk, *state.radix_states[table_idx], *global_source,
583
- *local_source);
584
587
 
585
- if (output_chunk.size() == 0) {
588
+ InterruptState interrupt_state;
589
+ OperatorSourceInput source_input {*global_source, *local_source, interrupt_state};
590
+ auto res = radix_table_p->GetData(temp_exec_context, output_chunk, *state.radix_states[table_idx],
591
+ source_input);
592
+
593
+ if (res == SourceResultType::FINISHED) {
594
+ D_ASSERT(output_chunk.size() == 0);
586
595
  break;
596
+ } else if (res == SourceResultType::BLOCKED) {
597
+ throw InternalException(
598
+ "Unexpected interrupt from radix table GetData in HashDistinctAggregateFinalizeTask");
587
599
  }
588
600
 
589
601
  auto &grouped_aggregate_data = *data.grouped_aggregate_data[table_idx];
@@ -603,8 +615,8 @@ public:
603
615
  aggregate_input_chunk.SetCardinality(output_chunk);
604
616
 
605
617
  // Sink it into the main ht
606
- grouping_data.table_data.Sink(temp_exec_context, table_state, *temp_local_state, group_chunk,
607
- aggregate_input_chunk, {i});
618
+ OperatorSinkInput sink_input {table_state, *temp_local_state, interrupt_state};
619
+ grouping_data.table_data.Sink(temp_exec_context, group_chunk, sink_input, aggregate_input_chunk, {i});
608
620
  }
609
621
  }
610
622
  grouping_data.table_data.Combine(temp_exec_context, table_state, *temp_local_state);
@@ -650,7 +662,7 @@ public:
650
662
  void Schedule() override {
651
663
  global_sources = CreateGlobalSources();
652
664
 
653
- vector<unique_ptr<Task>> tasks;
665
+ vector<shared_ptr<Task>> tasks;
654
666
  auto &scheduler = TaskScheduler::GetScheduler(context);
655
667
  auto number_of_threads = scheduler.NumberOfThreads();
656
668
  tasks.reserve(number_of_threads);
@@ -714,7 +726,7 @@ public:
714
726
 
715
727
  public:
716
728
  void Schedule() override {
717
- vector<unique_ptr<Task>> tasks;
729
+ vector<shared_ptr<Task>> tasks;
718
730
  for (idx_t i = 0; i < op.groupings.size(); i++) {
719
731
  auto &grouping = op.groupings[i];
720
732
  auto &distinct_data = *grouping.distinct_data;
@@ -868,11 +880,11 @@ unique_ptr<LocalSourceState> PhysicalHashAggregate::GetLocalSourceState(Executio
868
880
  return make_uniq<PhysicalHashAggregateLocalSourceState>(context, *this);
869
881
  }
870
882
 
871
- void PhysicalHashAggregate::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate_p,
872
- LocalSourceState &lstate_p) const {
883
+ SourceResultType PhysicalHashAggregate::GetData(ExecutionContext &context, DataChunk &chunk,
884
+ OperatorSourceInput &input) const {
873
885
  auto &sink_gstate = sink_state->Cast<HashAggregateGlobalState>();
874
- auto &gstate = gstate_p.Cast<PhysicalHashAggregateGlobalSourceState>();
875
- auto &lstate = lstate_p.Cast<PhysicalHashAggregateLocalSourceState>();
886
+ auto &gstate = input.global_state.Cast<PhysicalHashAggregateGlobalSourceState>();
887
+ auto &lstate = input.local_state.Cast<PhysicalHashAggregateLocalSourceState>();
876
888
  while (true) {
877
889
  idx_t radix_idx = gstate.state_index;
878
890
  if (radix_idx >= groupings.size()) {
@@ -881,11 +893,17 @@ void PhysicalHashAggregate::GetData(ExecutionContext &context, DataChunk &chunk,
881
893
  auto &grouping = groupings[radix_idx];
882
894
  auto &radix_table = grouping.table_data;
883
895
  auto &grouping_gstate = sink_gstate.grouping_states[radix_idx];
884
- radix_table.GetData(context, chunk, *grouping_gstate.table_state, *gstate.radix_states[radix_idx],
885
- *lstate.radix_states[radix_idx]);
896
+
897
+ InterruptState interrupt_state;
898
+ OperatorSourceInput source_input {*gstate.radix_states[radix_idx], *lstate.radix_states[radix_idx],
899
+ interrupt_state};
900
+ auto res = radix_table.GetData(context, chunk, *grouping_gstate.table_state, source_input);
886
901
  if (chunk.size() != 0) {
887
- return;
902
+ return SourceResultType::HAVE_MORE_OUTPUT;
903
+ } else if (res == SourceResultType::BLOCKED) {
904
+ throw InternalException("Unexpectedly Blocked from radix_table");
888
905
  }
906
+
889
907
  // move to the next table
890
908
  lock_guard<mutex> l(gstate.lock);
891
909
  radix_idx++;
@@ -895,6 +913,8 @@ void PhysicalHashAggregate::GetData(ExecutionContext &context, DataChunk &chunk,
895
913
  gstate.state_index = radix_idx;
896
914
  }
897
915
  }
916
+
917
+ return chunk.size() == 0 ? SourceResultType::FINISHED : SourceResultType::HAVE_MORE_OUTPUT;
898
918
  }
899
919
 
900
920
  string PhysicalHashAggregate::ParamsToString() const {
@@ -114,9 +114,9 @@ unique_ptr<LocalSinkState> PhysicalPerfectHashAggregate::GetLocalSinkState(Execu
114
114
  return make_uniq<PerfectHashAggregateLocalState>(*this, context);
115
115
  }
116
116
 
117
- SinkResultType PhysicalPerfectHashAggregate::Sink(ExecutionContext &context, GlobalSinkState &state,
118
- LocalSinkState &lstate_p, DataChunk &input) const {
119
- auto &lstate = lstate_p.Cast<PerfectHashAggregateLocalState>();
117
+ SinkResultType PhysicalPerfectHashAggregate::Sink(ExecutionContext &context, DataChunk &chunk,
118
+ OperatorSinkInput &input) const {
119
+ auto &lstate = input.local_state.Cast<PerfectHashAggregateLocalState>();
120
120
  DataChunk &group_chunk = lstate.group_chunk;
121
121
  DataChunk &aggregate_input_chunk = lstate.aggregate_input_chunk;
122
122
 
@@ -124,7 +124,7 @@ SinkResultType PhysicalPerfectHashAggregate::Sink(ExecutionContext &context, Glo
124
124
  auto &group = groups[group_idx];
125
125
  D_ASSERT(group->type == ExpressionType::BOUND_REF);
126
126
  auto &bound_ref_expr = group->Cast<BoundReferenceExpression>();
127
- group_chunk.data[group_idx].Reference(input.data[bound_ref_expr.index]);
127
+ group_chunk.data[group_idx].Reference(chunk.data[bound_ref_expr.index]);
128
128
  }
129
129
  idx_t aggregate_input_idx = 0;
130
130
  for (auto &aggregate : aggregates) {
@@ -132,7 +132,7 @@ SinkResultType PhysicalPerfectHashAggregate::Sink(ExecutionContext &context, Glo
132
132
  for (auto &child_expr : aggr.children) {
133
133
  D_ASSERT(child_expr->type == ExpressionType::BOUND_REF);
134
134
  auto &bound_ref_expr = child_expr->Cast<BoundReferenceExpression>();
135
- aggregate_input_chunk.data[aggregate_input_idx++].Reference(input.data[bound_ref_expr.index]);
135
+ aggregate_input_chunk.data[aggregate_input_idx++].Reference(chunk.data[bound_ref_expr.index]);
136
136
  }
137
137
  }
138
138
  for (auto &aggregate : aggregates) {
@@ -140,13 +140,13 @@ SinkResultType PhysicalPerfectHashAggregate::Sink(ExecutionContext &context, Glo
140
140
  if (aggr.filter) {
141
141
  auto it = filter_indexes.find(aggr.filter.get());
142
142
  D_ASSERT(it != filter_indexes.end());
143
- aggregate_input_chunk.data[aggregate_input_idx++].Reference(input.data[it->second]);
143
+ aggregate_input_chunk.data[aggregate_input_idx++].Reference(chunk.data[it->second]);
144
144
  }
145
145
  }
146
146
 
147
- group_chunk.SetCardinality(input.size());
147
+ group_chunk.SetCardinality(chunk.size());
148
148
 
149
- aggregate_input_chunk.SetCardinality(input.size());
149
+ aggregate_input_chunk.SetCardinality(chunk.size());
150
150
 
151
151
  group_chunk.Verify();
152
152
  aggregate_input_chunk.Verify();
@@ -184,12 +184,18 @@ unique_ptr<GlobalSourceState> PhysicalPerfectHashAggregate::GetGlobalSourceState
184
184
  return make_uniq<PerfectHashAggregateState>();
185
185
  }
186
186
 
187
- void PhysicalPerfectHashAggregate::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate_p,
188
- LocalSourceState &lstate) const {
189
- auto &state = (PerfectHashAggregateState &)gstate_p;
187
+ SourceResultType PhysicalPerfectHashAggregate::GetData(ExecutionContext &context, DataChunk &chunk,
188
+ OperatorSourceInput &input) const {
189
+ auto &state = (PerfectHashAggregateState &)input.global_state;
190
190
  auto &gstate = sink_state->Cast<PerfectHashAggregateGlobalState>();
191
191
 
192
192
  gstate.ht->Scan(state.ht_scan_position, chunk);
193
+
194
+ if (chunk.size() > 0) {
195
+ return SourceResultType::HAVE_MORE_OUTPUT;
196
+ } else {
197
+ return SourceResultType::FINISHED;
198
+ }
193
199
  }
194
200
 
195
201
  string PhysicalPerfectHashAggregate::ParamsToString() const {