duckdb 0.7.2-dev2820.0 → 0.7.2-dev2995.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 (254) hide show
  1. package/binding.gyp +1 -0
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/icu/icu-datepart.cpp +55 -1
  4. package/src/duckdb/extension/parquet/parquet-extension.cpp +5 -4
  5. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +18 -7
  6. package/src/duckdb/src/catalog/default/default_functions.cpp +2 -0
  7. package/src/duckdb/src/common/arrow/arrow_appender.cpp +3 -3
  8. package/src/duckdb/src/common/arrow/arrow_converter.cpp +2 -2
  9. package/src/duckdb/src/common/local_file_system.cpp +1 -3
  10. package/src/duckdb/src/common/multi_file_reader.cpp +11 -8
  11. package/src/duckdb/src/common/sort/partition_state.cpp +1 -1
  12. package/src/duckdb/src/common/string_util.cpp +6 -1
  13. package/src/duckdb/src/core_functions/function_list.cpp +2 -0
  14. package/src/duckdb/src/core_functions/scalar/string/format_bytes.cpp +29 -0
  15. package/src/duckdb/src/execution/index/art/art.cpp +5 -1
  16. package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +62 -43
  17. package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +17 -11
  18. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +32 -39
  19. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +10 -9
  20. package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +4 -4
  21. package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +6 -21
  22. package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +13 -13
  23. package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +15 -14
  24. package/src/duckdb/src/execution/operator/helper/physical_load.cpp +3 -2
  25. package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +4 -4
  26. package/src/duckdb/src/execution/operator/helper/physical_pragma.cpp +4 -2
  27. package/src/duckdb/src/execution/operator/helper/physical_prepare.cpp +4 -2
  28. package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +10 -8
  29. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +4 -3
  30. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +7 -6
  31. package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +4 -2
  32. package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +8 -8
  33. package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +17 -16
  34. package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +10 -8
  35. package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +3 -4
  36. package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +5 -5
  37. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +16 -15
  38. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +13 -12
  39. package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +12 -10
  40. package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +13 -11
  41. package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +8 -6
  42. package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
  43. package/src/duckdb/src/execution/operator/order/physical_order.cpp +13 -13
  44. package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +8 -8
  45. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +160 -145
  46. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +10 -25
  47. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +14 -19
  48. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +7 -6
  49. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +18 -30
  50. package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +14 -18
  51. package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +6 -4
  52. package/src/duckdb/src/execution/operator/scan/physical_dummy_scan.cpp +4 -19
  53. package/src/duckdb/src/execution/operator/scan/physical_empty_result.cpp +3 -2
  54. package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +14 -5
  55. package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +6 -4
  56. package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +3 -19
  57. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +4 -18
  58. package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +4 -19
  59. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +8 -9
  60. package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +4 -19
  61. package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +4 -19
  62. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +4 -19
  63. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +20 -28
  64. package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +4 -19
  65. package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +4 -19
  66. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +3 -19
  67. package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +9 -8
  68. package/src/duckdb/src/execution/operator/set/physical_union.cpp +1 -1
  69. package/src/duckdb/src/execution/physical_operator.cpp +11 -5
  70. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +16 -16
  71. package/src/duckdb/src/function/table/arrow_conversion.cpp +3 -3
  72. package/src/duckdb/src/function/table/read_csv.cpp +7 -4
  73. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  74. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +7 -1
  75. package/src/duckdb/src/include/duckdb/common/enums/operator_result_type.hpp +16 -4
  76. package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +5 -4
  77. package/src/duckdb/src/include/duckdb/common/optional_idx.hpp +45 -0
  78. package/src/duckdb/src/include/duckdb/common/set.hpp +2 -1
  79. package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +15 -0
  80. package/src/duckdb/src/include/duckdb/execution/executor.hpp +10 -1
  81. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +5 -8
  82. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +2 -4
  83. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +3 -7
  84. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +2 -4
  85. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +1 -2
  86. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +2 -5
  87. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +2 -4
  88. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit_percent.hpp +2 -4
  89. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_load.hpp +1 -2
  90. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +1 -2
  91. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_pragma.hpp +1 -2
  92. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_prepare.hpp +1 -2
  93. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +2 -4
  94. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reset.hpp +1 -2
  95. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +1 -2
  96. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_transaction.hpp +1 -2
  97. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +2 -4
  98. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +2 -4
  99. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +2 -4
  100. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -2
  101. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +1 -2
  102. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +2 -4
  103. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +2 -4
  104. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_nested_loop_join.hpp +2 -4
  105. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +2 -4
  106. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +2 -4
  107. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +2 -4
  108. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +2 -4
  109. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +3 -5
  110. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +2 -5
  111. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_delete.hpp +2 -4
  112. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +2 -4
  113. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -4
  114. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +2 -4
  115. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +1 -2
  116. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_dummy_scan.hpp +1 -3
  117. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_empty_result.hpp +1 -2
  118. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_positional_scan.hpp +1 -2
  119. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +1 -2
  120. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_alter.hpp +1 -3
  121. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +1 -3
  122. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_function.hpp +1 -3
  123. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +2 -4
  124. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_schema.hpp +1 -3
  125. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_sequence.hpp +1 -3
  126. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +1 -3
  127. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +6 -5
  128. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_view.hpp +1 -3
  129. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +1 -3
  130. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_drop.hpp +1 -3
  131. package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +2 -4
  132. package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +7 -4
  133. package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +26 -6
  134. package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +5 -5
  135. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +2 -1
  136. package/src/duckdb/src/include/duckdb/function/table_function.hpp +0 -1
  137. package/src/duckdb/src/include/duckdb/main/client_config.hpp +2 -0
  138. package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
  139. package/src/duckdb/src/include/duckdb/main/database.hpp +1 -0
  140. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +3 -0
  141. package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +0 -2
  142. package/src/duckdb/src/include/duckdb/parallel/event.hpp +1 -1
  143. package/src/duckdb/src/include/duckdb/parallel/interrupt.hpp +63 -0
  144. package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +16 -3
  145. package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +51 -7
  146. package/src/duckdb/src/include/duckdb/parallel/task.hpp +21 -2
  147. package/src/duckdb/src/include/duckdb/parallel/task_counter.hpp +2 -2
  148. package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +2 -2
  149. package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +3 -0
  150. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +5 -1
  151. package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +6 -0
  152. package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +1 -0
  153. package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +1 -0
  154. package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +1 -0
  155. package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +1 -0
  156. package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +1 -0
  157. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +1 -0
  158. package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +1 -0
  159. package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +1 -0
  160. package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +1 -0
  161. package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +1 -0
  162. package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +1 -0
  163. package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +1 -0
  164. package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +1 -0
  165. package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +1 -0
  166. package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +1 -0
  167. package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +1 -0
  168. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -0
  169. package/src/duckdb/src/include/duckdb/storage/optimistic_data_writer.hpp +46 -0
  170. package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +24 -3
  171. package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +46 -1
  172. package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +9 -10
  173. package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +1 -1
  174. package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +2 -2
  175. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +3 -3
  176. package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -0
  177. package/src/duckdb/src/include/duckdb/storage/table/segment_base.hpp +1 -1
  178. package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +22 -0
  179. package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +3 -3
  180. package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +2 -2
  181. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +0 -2
  182. package/src/duckdb/src/include/duckdb/storage/table/validity_column_data.hpp +1 -2
  183. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +9 -34
  184. package/src/duckdb/src/include/duckdb/verification/no_operator_caching_verifier.hpp +25 -0
  185. package/src/duckdb/src/include/duckdb/verification/statement_verifier.hpp +5 -0
  186. package/src/duckdb/src/main/attached_database.cpp +5 -3
  187. package/src/duckdb/src/main/client_verify.cpp +4 -0
  188. package/src/duckdb/src/main/config.cpp +4 -0
  189. package/src/duckdb/src/main/database.cpp +45 -48
  190. package/src/duckdb/src/main/extension/extension_load.cpp +32 -49
  191. package/src/duckdb/src/parallel/event.cpp +1 -1
  192. package/src/duckdb/src/parallel/executor.cpp +39 -3
  193. package/src/duckdb/src/parallel/executor_task.cpp +11 -0
  194. package/src/duckdb/src/parallel/interrupt.cpp +57 -0
  195. package/src/duckdb/src/parallel/pipeline.cpp +49 -6
  196. package/src/duckdb/src/parallel/pipeline_executor.cpp +248 -69
  197. package/src/duckdb/src/parallel/pipeline_initialize_event.cpp +1 -1
  198. package/src/duckdb/src/parallel/task_scheduler.cpp +57 -22
  199. package/src/duckdb/src/parser/base_expression.cpp +6 -0
  200. package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +1 -4
  201. package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +2 -4
  202. package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +43 -24
  203. package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +3 -0
  204. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +17 -28
  205. package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +17 -3
  206. package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +8 -2
  207. package/src/duckdb/src/planner/operator/logical_aggregate.cpp +13 -1
  208. package/src/duckdb/src/planner/operator/logical_column_data_get.cpp +11 -0
  209. package/src/duckdb/src/planner/operator/logical_cteref.cpp +11 -0
  210. package/src/duckdb/src/planner/operator/logical_delete.cpp +10 -0
  211. package/src/duckdb/src/planner/operator/logical_delim_get.cpp +12 -1
  212. package/src/duckdb/src/planner/operator/logical_dummy_scan.cpp +12 -1
  213. package/src/duckdb/src/planner/operator/logical_expression_get.cpp +12 -1
  214. package/src/duckdb/src/planner/operator/logical_get.cpp +10 -4
  215. package/src/duckdb/src/planner/operator/logical_insert.cpp +12 -1
  216. package/src/duckdb/src/planner/operator/logical_pivot.cpp +11 -0
  217. package/src/duckdb/src/planner/operator/logical_projection.cpp +11 -0
  218. package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +11 -0
  219. package/src/duckdb/src/planner/operator/logical_set_operation.cpp +11 -0
  220. package/src/duckdb/src/planner/operator/logical_unnest.cpp +12 -1
  221. package/src/duckdb/src/planner/operator/logical_update.cpp +10 -0
  222. package/src/duckdb/src/planner/operator/logical_window.cpp +11 -0
  223. package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -1
  224. package/src/duckdb/src/storage/data_table.cpp +5 -0
  225. package/src/duckdb/src/storage/local_storage.cpp +40 -110
  226. package/src/duckdb/src/storage/optimistic_data_writer.cpp +96 -0
  227. package/src/duckdb/src/storage/partial_block_manager.cpp +73 -9
  228. package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -1
  229. package/src/duckdb/src/storage/standard_buffer_manager.cpp +17 -12
  230. package/src/duckdb/src/storage/statistics/base_statistics.cpp +3 -0
  231. package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +90 -82
  232. package/src/duckdb/src/storage/table/column_data.cpp +19 -45
  233. package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +7 -7
  234. package/src/duckdb/src/storage/table/column_segment.cpp +1 -1
  235. package/src/duckdb/src/storage/table/list_column_data.cpp +6 -11
  236. package/src/duckdb/src/storage/table/row_group.cpp +13 -14
  237. package/src/duckdb/src/storage/table/row_group_collection.cpp +10 -4
  238. package/src/duckdb/src/storage/table/standard_column_data.cpp +6 -10
  239. package/src/duckdb/src/storage/table/struct_column_data.cpp +7 -13
  240. package/src/duckdb/src/storage/table/update_segment.cpp +0 -25
  241. package/src/duckdb/src/storage/table/validity_column_data.cpp +2 -6
  242. package/src/duckdb/src/transaction/commit_state.cpp +4 -4
  243. package/src/duckdb/src/verification/no_operator_caching_verifier.cpp +13 -0
  244. package/src/duckdb/src/verification/statement_verifier.cpp +4 -0
  245. package/src/duckdb/third_party/fmt/format.cc +0 -5
  246. package/src/duckdb/third_party/fmt/include/fmt/core.h +10 -12
  247. package/src/duckdb/third_party/fmt/include/fmt/format-inl.h +2 -33
  248. package/src/duckdb/third_party/fmt/include/fmt/format.h +61 -24
  249. package/src/duckdb/third_party/fmt/include/fmt/printf.h +15 -1
  250. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +1 -0
  251. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +10735 -10674
  252. package/src/duckdb/ub_src_core_functions_scalar_string.cpp +2 -0
  253. package/src/duckdb/ub_src_parallel.cpp +2 -0
  254. package/src/duckdb/ub_src_storage.cpp +2 -0
package/binding.gyp CHANGED
@@ -136,6 +136,7 @@
136
136
  "src/duckdb/src/verification/copied_statement_verifier.cpp",
137
137
  "src/duckdb/src/verification/deserialized_statement_verifier.cpp",
138
138
  "src/duckdb/src/verification/external_statement_verifier.cpp",
139
+ "src/duckdb/src/verification/no_operator_caching_verifier.cpp",
139
140
  "src/duckdb/src/verification/parsed_statement_verifier.cpp",
140
141
  "src/duckdb/src/verification/prepared_statement_verifier.cpp",
141
142
  "src/duckdb/src/verification/statement_verifier.cpp",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
4
  "types": "./lib/duckdb.d.ts",
5
- "version": "0.7.2-dev2820.0",
5
+ "version": "0.7.2-dev2995.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -203,6 +203,18 @@ struct ICUDatePart : public ICUDateFunc {
203
203
  return Date::EpochToDate(ExtractEpoch(calendar, 0));
204
204
  }
205
205
 
206
+ static string_t MonthName(icu::Calendar *calendar, const uint64_t micros) {
207
+ const auto mm = ExtractMonth(calendar, micros) - 1;
208
+ if (mm == 12) {
209
+ return "Undecember";
210
+ }
211
+ return Date::MONTH_NAMES[mm];
212
+ }
213
+
214
+ static string_t DayName(icu::Calendar *calendar, const uint64_t micros) {
215
+ return Date::DAY_NAMES[ExtractDayOfWeek(calendar, micros)];
216
+ }
217
+
206
218
  template <typename RESULT_TYPE>
207
219
  struct BindAdapterData : public BindData {
208
220
  using result_t = RESULT_TYPE;
@@ -246,7 +258,7 @@ struct ICUDatePart : public ICUDateFunc {
246
258
  return info.adapters[0](calendar, micros);
247
259
  } else {
248
260
  mask.SetInvalid(idx);
249
- return RESULT_TYPE(0);
261
+ return RESULT_TYPE();
250
262
  }
251
263
  });
252
264
  }
@@ -482,6 +494,44 @@ struct ICUDatePart : public ICUDateFunc {
482
494
  CreateScalarFunctionInfo func_info(set);
483
495
  catalog.AddFunction(context, func_info);
484
496
  }
497
+
498
+ static unique_ptr<FunctionData> BindMonthName(ClientContext &context, ScalarFunction &bound_function,
499
+ vector<unique_ptr<Expression>> &arguments) {
500
+ using data_t = BindAdapterData<string_t>;
501
+ return BindAdapter<data_t>(context, bound_function, arguments, MonthName);
502
+ }
503
+
504
+ template <typename INPUT_TYPE>
505
+ static ScalarFunction GetMonthNameFunction(const LogicalType &temporal_type) {
506
+ return ScalarFunction({temporal_type}, LogicalType::VARCHAR, UnaryTimestampFunction<INPUT_TYPE, string_t>,
507
+ BindMonthName);
508
+ }
509
+ static void AddMonthNameFunctions(const string &name, ClientContext &context) {
510
+ auto &catalog = Catalog::GetSystemCatalog(context);
511
+ ScalarFunctionSet set(name);
512
+ set.AddFunction(GetMonthNameFunction<timestamp_t>(LogicalType::TIMESTAMP_TZ));
513
+ CreateScalarFunctionInfo func_info(set);
514
+ catalog.AddFunction(context, func_info);
515
+ }
516
+
517
+ static unique_ptr<FunctionData> BindDayName(ClientContext &context, ScalarFunction &bound_function,
518
+ vector<unique_ptr<Expression>> &arguments) {
519
+ using data_t = BindAdapterData<string_t>;
520
+ return BindAdapter<data_t>(context, bound_function, arguments, DayName);
521
+ }
522
+
523
+ template <typename INPUT_TYPE>
524
+ static ScalarFunction GetDayNameFunction(const LogicalType &temporal_type) {
525
+ return ScalarFunction({temporal_type}, LogicalType::VARCHAR, UnaryTimestampFunction<INPUT_TYPE, string_t>,
526
+ BindDayName);
527
+ }
528
+ static void AddDayNameFunctions(const string &name, ClientContext &context) {
529
+ auto &catalog = Catalog::GetSystemCatalog(context);
530
+ ScalarFunctionSet set(name);
531
+ set.AddFunction(GetDayNameFunction<timestamp_t>(LogicalType::TIMESTAMP_TZ));
532
+ CreateScalarFunctionInfo func_info(set);
533
+ catalog.AddFunction(context, func_info);
534
+ }
485
535
  };
486
536
 
487
537
  void RegisterICUDatePartFunctions(ClientContext &context) {
@@ -520,6 +570,10 @@ void RegisterICUDatePartFunctions(ClientContext &context) {
520
570
  // register the last_day function
521
571
  ICUDatePart::AddLastDayFunctions("last_day", context);
522
572
 
573
+ // register the dayname/monthname functions
574
+ ICUDatePart::AddMonthNameFunctions("monthname", context);
575
+ ICUDatePart::AddDayNameFunctions("dayname", context);
576
+
523
577
  // finally the actual date_part function
524
578
  ICUDatePart::AddDatePartFunctions("date_part", context);
525
579
  ICUDatePart::AddDatePartFunctions("datepart", context);
@@ -369,7 +369,8 @@ public:
369
369
  continue;
370
370
  }
371
371
  MultiFileReader::InitializeReader(*reader, bind_data.parquet_options.file_options, bind_data.reader_bind,
372
- bind_data.types, bind_data.names, input.column_ids, input.filters);
372
+ bind_data.types, bind_data.names, input.column_ids, input.filters,
373
+ bind_data.files[0]);
373
374
  }
374
375
 
375
376
  result->column_ids = input.column_ids;
@@ -561,9 +562,9 @@ public:
561
562
  shared_ptr<ParquetReader> reader;
562
563
  try {
563
564
  reader = make_shared<ParquetReader>(context, file, pq_options);
564
- MultiFileReader::InitializeReader(*reader, bind_data.parquet_options.file_options,
565
- bind_data.reader_bind, bind_data.types, bind_data.names,
566
- parallel_state.column_ids, parallel_state.filters);
565
+ MultiFileReader::InitializeReader(
566
+ *reader, bind_data.parquet_options.file_options, bind_data.reader_bind, bind_data.types,
567
+ bind_data.names, parallel_state.column_ids, parallel_state.filters, bind_data.files.front());
567
568
  } catch (...) {
568
569
  parallel_lock.lock();
569
570
  parallel_state.error_opening_file = true;
@@ -51,16 +51,27 @@ vector<LogicalType> TableCatalogEntry::GetTypes() {
51
51
  return types;
52
52
  }
53
53
 
54
+ CreateTableInfo TableCatalogEntry::GetTableInfoForSerialization() const {
55
+ CreateTableInfo result;
56
+ result.catalog = catalog.GetName();
57
+ result.schema = schema.name;
58
+ result.table = name;
59
+ result.columns = columns.Copy();
60
+ result.constraints.reserve(constraints.size());
61
+ std::for_each(constraints.begin(), constraints.end(),
62
+ [&result](const unique_ptr<Constraint> &c) { result.constraints.emplace_back(c->Copy()); });
63
+ return result;
64
+ }
65
+
54
66
  void TableCatalogEntry::Serialize(Serializer &serializer) const {
55
67
  D_ASSERT(!internal);
56
-
68
+ const auto info = GetTableInfoForSerialization();
57
69
  FieldWriter writer(serializer);
58
- auto catalog_name = catalog.GetName();
59
- writer.WriteString(catalog_name);
60
- writer.WriteString(schema.name);
61
- writer.WriteString(name);
62
- columns.Serialize(writer);
63
- writer.WriteSerializableList(constraints);
70
+ writer.WriteString(info.catalog);
71
+ writer.WriteString(info.schema);
72
+ writer.WriteString(info.table);
73
+ info.columns.Serialize(writer);
74
+ writer.WriteSerializableList(info.constraints);
64
75
  writer.Finalize();
65
76
  }
66
77
 
@@ -79,6 +79,8 @@ static DefaultMacro internal_macros[] = {
79
79
  {"pg_catalog", "pg_ts_template_is_visible", {"template_oid", nullptr}, "true"},
80
80
  {"pg_catalog", "pg_type_is_visible", {"type_oid", nullptr}, "true"},
81
81
 
82
+ {"pg_catalog", "pg_size_pretty", {"bytes", nullptr}, "format_bytes(bytes)"},
83
+
82
84
  {DEFAULT_SCHEMA, "round_even", {"x", "n", nullptr}, "CASE ((abs(x) * power(10, n+1)) % 10) WHEN 5 THEN round(x/2, n) * 2 ELSE round(x, n) END"},
83
85
  {DEFAULT_SCHEMA, "roundbankers", {"x", "n", nullptr}, "round_even(x, n)"},
84
86
  {DEFAULT_SCHEMA, "nullif", {"a", "b", nullptr}, "CASE WHEN a=b THEN NULL ELSE a END"},
@@ -320,7 +320,7 @@ struct ArrowUUIDConverter {
320
320
  template <class SRC = string_t, class OP = ArrowVarcharConverter>
321
321
  struct ArrowVarcharData {
322
322
  static void Initialize(ArrowAppendData &result, const LogicalType &type, idx_t capacity) {
323
- result.main_buffer.reserve((capacity + 1) * sizeof(uint32_t));
323
+ result.main_buffer.reserve((capacity + 1) * sizeof(uint64_t));
324
324
  result.aux_buffer.reserve(capacity);
325
325
  }
326
326
 
@@ -334,9 +334,9 @@ struct ArrowVarcharData {
334
334
  auto validity_data = (uint8_t *)append_data.validity.data();
335
335
 
336
336
  // resize the offset buffer - the offset buffer holds the offsets into the child array
337
- append_data.main_buffer.resize(append_data.main_buffer.size() + sizeof(uint32_t) * (size + 1));
337
+ append_data.main_buffer.resize(append_data.main_buffer.size() + sizeof(uint64_t) * (size + 1));
338
338
  auto data = (SRC *)format.data;
339
- auto offset_data = (uint32_t *)append_data.main_buffer.data();
339
+ auto offset_data = (uint64_t *)append_data.main_buffer.data();
340
340
  if (append_data.row_count == 0) {
341
341
  // first entry
342
342
  offset_data[0] = 0;
@@ -117,7 +117,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
117
117
  break;
118
118
  case LogicalTypeId::UUID:
119
119
  case LogicalTypeId::VARCHAR:
120
- child.format = "u";
120
+ child.format = "U";
121
121
  break;
122
122
  case LogicalTypeId::DATE:
123
123
  child.format = "tdD";
@@ -171,7 +171,7 @@ void SetArrowFormat(DuckDBArrowSchemaHolder &root_holder, ArrowSchema &child, co
171
171
  }
172
172
  case LogicalTypeId::BLOB:
173
173
  case LogicalTypeId::BIT: {
174
- child.format = "z";
174
+ child.format = "Z";
175
175
  break;
176
176
  }
177
177
  case LogicalTypeId::LIST: {
@@ -977,7 +977,6 @@ vector<string> LocalFileSystem::Glob(const string &path, FileOpener *opener) {
977
977
  throw IOException("Cannot use multiple \'**\' in one path");
978
978
  }
979
979
 
980
- bool recursive_search = false;
981
980
  for (idx_t i = absolute_path ? 1 : 0; i < splits.size(); i++) {
982
981
  bool is_last_chunk = i + 1 == splits.size();
983
982
  bool has_glob = HasGlob(splits[i]);
@@ -989,7 +988,7 @@ vector<string> LocalFileSystem::Glob(const string &path, FileOpener *opener) {
989
988
  if (previous_directories.empty()) {
990
989
  result.push_back(splits[i]);
991
990
  } else {
992
- if (recursive_search && is_last_chunk) {
991
+ if (is_last_chunk) {
993
992
  for (auto &prev_directory : previous_directories) {
994
993
  const string filename = JoinPath(prev_directory, splits[i]);
995
994
  if (FileExists(filename) || DirectoryExists(filename)) {
@@ -1004,7 +1003,6 @@ vector<string> LocalFileSystem::Glob(const string &path, FileOpener *opener) {
1004
1003
  }
1005
1004
  } else {
1006
1005
  if (IsCrawl(splits[i])) {
1007
- recursive_search = true;
1008
1006
  if (!is_last_chunk) {
1009
1007
  result = previous_directories;
1010
1008
  }
@@ -192,7 +192,7 @@ void MultiFileReader::FinalizeBind(const MultiFileReaderOptions &file_options, c
192
192
  void MultiFileReader::CreateNameMapping(const string &file_name, const vector<LogicalType> &local_types,
193
193
  const vector<string> &local_names, const vector<LogicalType> &global_types,
194
194
  const vector<string> &global_names, const vector<column_t> &global_column_ids,
195
- MultiFileReaderData &reader_data) {
195
+ MultiFileReaderData &reader_data, const string &initial_file) {
196
196
  D_ASSERT(global_types.size() == global_names.size());
197
197
  D_ASSERT(local_types.size() == local_names.size());
198
198
  // we have expected types: create a map of name -> column index
@@ -229,11 +229,12 @@ void MultiFileReader::CreateNameMapping(const string &file_name, const vector<Lo
229
229
  }
230
230
  candidate_names += local_name;
231
231
  }
232
- throw IOException(StringUtil::Format(
233
- "Failed to read file \"%s\": schema mismatch in glob: column \"%s\" was read from "
234
- "the original file, but could not be found in file \"%s\".\nCandidate names: %s\nIf you are trying to "
235
- "read files with different schemas, try setting union_by_name=True",
236
- file_name, global_name, file_name, candidate_names));
232
+ throw IOException(
233
+ StringUtil::Format("Failed to read file \"%s\": schema mismatch in glob: column \"%s\" was read from "
234
+ "the original file \"%s\", but could not be found in file \"%s\".\nCandidate names: "
235
+ "%s\nIf you are trying to "
236
+ "read files with different schemas, try setting union_by_name=True",
237
+ file_name, global_name, initial_file, file_name, candidate_names));
237
238
  }
238
239
  // we found the column in the local file - check if the types are the same
239
240
  auto local_id = entry->second;
@@ -254,8 +255,10 @@ void MultiFileReader::CreateNameMapping(const string &file_name, const vector<Lo
254
255
  void MultiFileReader::CreateMapping(const string &file_name, const vector<LogicalType> &local_types,
255
256
  const vector<string> &local_names, const vector<LogicalType> &global_types,
256
257
  const vector<string> &global_names, const vector<column_t> &global_column_ids,
257
- optional_ptr<TableFilterSet> filters, MultiFileReaderData &reader_data) {
258
- CreateNameMapping(file_name, local_types, local_names, global_types, global_names, global_column_ids, reader_data);
258
+ optional_ptr<TableFilterSet> filters, MultiFileReaderData &reader_data,
259
+ const string &initial_file) {
260
+ CreateNameMapping(file_name, local_types, local_names, global_types, global_names, global_column_ids, reader_data,
261
+ initial_file);
259
262
  if (filters) {
260
263
  reader_data.filter_map.resize(global_types.size());
261
264
  for (idx_t c = 0; c < reader_data.column_mapping.size(); c++) {
@@ -554,7 +554,7 @@ void PartitionMergeEvent::Schedule() {
554
554
  auto &ts = TaskScheduler::GetScheduler(context);
555
555
  idx_t num_threads = ts.NumberOfThreads();
556
556
 
557
- vector<unique_ptr<Task>> merge_tasks;
557
+ vector<shared_ptr<Task>> merge_tasks;
558
558
  for (idx_t tnum = 0; tnum < num_threads; tnum++) {
559
559
  merge_tasks.emplace_back(make_uniq<PartitionMergeTask>(shared_from_this(), context, merge_states));
560
560
  }
@@ -163,6 +163,11 @@ string StringUtil::BytesToHumanReadableString(idx_t bytes) {
163
163
  megabytes -= gigabytes * 1000;
164
164
  auto terabytes = gigabytes / 1000;
165
165
  gigabytes -= terabytes * 1000;
166
+ auto petabytes = terabytes / 1000;
167
+ terabytes -= petabytes * 1000;
168
+ if (petabytes > 0) {
169
+ return to_string(petabytes) + "." + to_string(terabytes / 100) + "PB";
170
+ }
166
171
  if (terabytes > 0) {
167
172
  return to_string(terabytes) + "." + to_string(gigabytes / 100) + "TB";
168
173
  } else if (gigabytes > 0) {
@@ -172,7 +177,7 @@ string StringUtil::BytesToHumanReadableString(idx_t bytes) {
172
177
  } else if (kilobytes > 0) {
173
178
  return to_string(kilobytes) + "KB";
174
179
  } else {
175
- return to_string(bytes) + " bytes";
180
+ return to_string(bytes) + (bytes == 1 ? " byte" : " bytes");
176
181
  }
177
182
  }
178
183
 
@@ -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),
@@ -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
@@ -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
@@ -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"
@@ -250,10 +251,10 @@ unique_ptr<LocalSinkState> PhysicalHashAggregate::GetLocalSinkState(ExecutionCon
250
251
  return make_uniq<HashAggregateLocalState>(*this, context);
251
252
  }
252
253
 
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>();
254
+ void PhysicalHashAggregate::SinkDistinctGrouping(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input,
255
+ idx_t grouping_idx) const {
256
+ auto &sink = input.local_state.Cast<HashAggregateLocalState>();
257
+ auto &global_sink = input.global_state.Cast<HashAggregateGlobalState>();
257
258
 
258
259
  auto &grouping_gstate = global_sink.grouping_states[grouping_idx];
259
260
  auto &grouping_lstate = sink.grouping_states[grouping_idx];
@@ -280,6 +281,9 @@ void PhysicalHashAggregate::SinkDistinctGrouping(ExecutionContext &context, Glob
280
281
  auto &radix_global_sink = *distinct_state->radix_states[table_idx];
281
282
  auto &radix_local_sink = *grouping_lstate.distinct_states[table_idx];
282
283
 
284
+ InterruptState interrupt_state;
285
+ OperatorSinkInput sink_input {radix_global_sink, radix_local_sink, interrupt_state};
286
+
283
287
  if (aggregate.filter) {
284
288
  DataChunk filter_chunk;
285
289
  auto &filtered_data = sink.filter_set.GetFilterData(idx);
@@ -288,10 +292,10 @@ void PhysicalHashAggregate::SinkDistinctGrouping(ExecutionContext &context, Glob
288
292
  // Add the filter Vector (BOOL)
289
293
  auto it = filter_indexes.find(aggregate.filter.get());
290
294
  D_ASSERT(it != filter_indexes.end());
291
- D_ASSERT(it->second < input.data.size());
295
+ D_ASSERT(it->second < chunk.data.size());
292
296
  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());
297
+ filter_chunk.data[filter_bound_ref.index].Reference(chunk.data[it->second]);
298
+ filter_chunk.SetCardinality(chunk.size());
295
299
 
296
300
  // We cant use the AggregateFilterData::ApplyFilter method, because the chunk we need to
297
301
  // apply the filter to also has the groups, and the filtered_data.filtered_payload does not have those.
@@ -305,43 +309,42 @@ void PhysicalHashAggregate::SinkDistinctGrouping(ExecutionContext &context, Glob
305
309
  // Because the 'input' chunk needs to be re-used after this, we need to create
306
310
  // a duplicate of it, that we can apply the filter to
307
311
  DataChunk filtered_input;
308
- filtered_input.InitializeEmpty(input.GetTypes());
312
+ filtered_input.InitializeEmpty(chunk.GetTypes());
309
313
 
310
314
  for (idx_t group_idx = 0; group_idx < grouped_aggregate_data.groups.size(); group_idx++) {
311
315
  auto &group = grouped_aggregate_data.groups[group_idx];
312
316
  auto &bound_ref = group->Cast<BoundReferenceExpression>();
313
- filtered_input.data[bound_ref.index].Reference(input.data[bound_ref.index]);
317
+ filtered_input.data[bound_ref.index].Reference(chunk.data[bound_ref.index]);
314
318
  }
315
319
  for (idx_t child_idx = 0; child_idx < aggregate.children.size(); child_idx++) {
316
320
  auto &child = aggregate.children[child_idx];
317
321
  auto &bound_ref = child->Cast<BoundReferenceExpression>();
318
322
 
319
- filtered_input.data[bound_ref.index].Reference(input.data[bound_ref.index]);
323
+ filtered_input.data[bound_ref.index].Reference(chunk.data[bound_ref.index]);
320
324
  }
321
325
  filtered_input.Slice(sel_vec, count);
322
326
  filtered_input.SetCardinality(count);
323
327
 
324
- radix_table.Sink(context, radix_global_sink, radix_local_sink, filtered_input, empty_chunk, empty_filter);
328
+ radix_table.Sink(context, filtered_input, sink_input, empty_chunk, empty_filter);
325
329
  } else {
326
- radix_table.Sink(context, radix_global_sink, radix_local_sink, input, empty_chunk, empty_filter);
330
+ radix_table.Sink(context, chunk, sink_input, empty_chunk, empty_filter);
327
331
  }
328
332
  }
329
333
  }
330
334
 
331
- void PhysicalHashAggregate::SinkDistinct(ExecutionContext &context, GlobalSinkState &state, LocalSinkState &lstate,
332
- DataChunk &input) const {
335
+ void PhysicalHashAggregate::SinkDistinct(ExecutionContext &context, DataChunk &chunk, OperatorSinkInput &input) const {
333
336
  for (idx_t i = 0; i < groupings.size(); i++) {
334
- SinkDistinctGrouping(context, state, lstate, input, i);
337
+ SinkDistinctGrouping(context, chunk, input, i);
335
338
  }
336
339
  }
337
340
 
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>();
341
+ SinkResultType PhysicalHashAggregate::Sink(ExecutionContext &context, DataChunk &chunk,
342
+ OperatorSinkInput &input) const {
343
+ auto &llstate = input.local_state.Cast<HashAggregateLocalState>();
344
+ auto &gstate = input.global_state.Cast<HashAggregateGlobalState>();
342
345
 
343
346
  if (distinct_collection_info) {
344
- SinkDistinct(context, state, lstate, input);
347
+ SinkDistinct(context, chunk, input);
345
348
  }
346
349
 
347
350
  if (CanSkipRegularSink()) {
@@ -359,8 +362,8 @@ SinkResultType PhysicalHashAggregate::Sink(ExecutionContext &context, GlobalSink
359
362
  for (auto &child_expr : aggr.children) {
360
363
  D_ASSERT(child_expr->type == ExpressionType::BOUND_REF);
361
364
  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]);
365
+ D_ASSERT(bound_ref_expr.index < chunk.data.size());
366
+ aggregate_input_chunk.data[aggregate_input_idx++].Reference(chunk.data[bound_ref_expr.index]);
364
367
  }
365
368
  }
366
369
  // Populate the filter vectors
@@ -369,23 +372,24 @@ SinkResultType PhysicalHashAggregate::Sink(ExecutionContext &context, GlobalSink
369
372
  if (aggr.filter) {
370
373
  auto it = filter_indexes.find(aggr.filter.get());
371
374
  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]);
375
+ D_ASSERT(it->second < chunk.data.size());
376
+ aggregate_input_chunk.data[aggregate_input_idx++].Reference(chunk.data[it->second]);
374
377
  }
375
378
  }
376
379
 
377
- aggregate_input_chunk.SetCardinality(input.size());
380
+ aggregate_input_chunk.SetCardinality(chunk.size());
378
381
  aggregate_input_chunk.Verify();
379
382
 
380
383
  // For every grouping set there is one radix_table
381
384
  for (idx_t i = 0; i < groupings.size(); i++) {
382
385
  auto &grouping_gstate = gstate.grouping_states[i];
383
386
  auto &grouping_lstate = llstate.grouping_states[i];
387
+ InterruptState interrupt_state;
388
+ OperatorSinkInput sink_input {*grouping_gstate.table_state, *grouping_lstate.table_state, interrupt_state};
384
389
 
385
390
  auto &grouping = groupings[i];
386
391
  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);
392
+ table.Sink(context, chunk, sink_input, aggregate_input_chunk, non_distinct_filter);
389
393
  }
390
394
 
391
395
  return SinkResultType::NEED_MORE_INPUT;
@@ -452,7 +456,7 @@ public:
452
456
 
453
457
  public:
454
458
  void Schedule() override {
455
- vector<unique_ptr<Task>> tasks;
459
+ vector<shared_ptr<Task>> tasks;
456
460
  for (idx_t i = 0; i < op.groupings.size(); i++) {
457
461
  auto &grouping_gstate = gstate.grouping_states[i];
458
462
 
@@ -504,7 +508,7 @@ public:
504
508
 
505
509
  public:
506
510
  void Schedule() override {
507
- vector<unique_ptr<Task>> tasks;
511
+ vector<shared_ptr<Task>> tasks;
508
512
  tasks.push_back(make_uniq<HashAggregateFinalizeTask>(*pipeline, shared_from_this(), gstate, context, op));
509
513
  D_ASSERT(!tasks.empty());
510
514
  SetTasks(std::move(tasks));
@@ -579,11 +583,18 @@ public:
579
583
  output_chunk.Reset();
580
584
  group_chunk.Reset();
581
585
  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
586
 
585
- if (output_chunk.size() == 0) {
587
+ InterruptState interrupt_state;
588
+ OperatorSourceInput source_input {*global_source, *local_source, interrupt_state};
589
+ auto res = radix_table_p->GetData(temp_exec_context, output_chunk, *state.radix_states[table_idx],
590
+ source_input);
591
+
592
+ if (res == SourceResultType::FINISHED) {
593
+ D_ASSERT(output_chunk.size() == 0);
586
594
  break;
595
+ } else if (res == SourceResultType::BLOCKED) {
596
+ throw InternalException(
597
+ "Unexpected interrupt from radix table GetData in HashDistinctAggregateFinalizeTask");
587
598
  }
588
599
 
589
600
  auto &grouped_aggregate_data = *data.grouped_aggregate_data[table_idx];
@@ -603,8 +614,8 @@ public:
603
614
  aggregate_input_chunk.SetCardinality(output_chunk);
604
615
 
605
616
  // 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});
617
+ OperatorSinkInput sink_input {table_state, *temp_local_state, interrupt_state};
618
+ grouping_data.table_data.Sink(temp_exec_context, group_chunk, sink_input, aggregate_input_chunk, {i});
608
619
  }
609
620
  }
610
621
  grouping_data.table_data.Combine(temp_exec_context, table_state, *temp_local_state);
@@ -650,7 +661,7 @@ public:
650
661
  void Schedule() override {
651
662
  global_sources = CreateGlobalSources();
652
663
 
653
- vector<unique_ptr<Task>> tasks;
664
+ vector<shared_ptr<Task>> tasks;
654
665
  auto &scheduler = TaskScheduler::GetScheduler(context);
655
666
  auto number_of_threads = scheduler.NumberOfThreads();
656
667
  tasks.reserve(number_of_threads);
@@ -714,7 +725,7 @@ public:
714
725
 
715
726
  public:
716
727
  void Schedule() override {
717
- vector<unique_ptr<Task>> tasks;
728
+ vector<shared_ptr<Task>> tasks;
718
729
  for (idx_t i = 0; i < op.groupings.size(); i++) {
719
730
  auto &grouping = op.groupings[i];
720
731
  auto &distinct_data = *grouping.distinct_data;
@@ -868,11 +879,11 @@ unique_ptr<LocalSourceState> PhysicalHashAggregate::GetLocalSourceState(Executio
868
879
  return make_uniq<PhysicalHashAggregateLocalSourceState>(context, *this);
869
880
  }
870
881
 
871
- void PhysicalHashAggregate::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate_p,
872
- LocalSourceState &lstate_p) const {
882
+ SourceResultType PhysicalHashAggregate::GetData(ExecutionContext &context, DataChunk &chunk,
883
+ OperatorSourceInput &input) const {
873
884
  auto &sink_gstate = sink_state->Cast<HashAggregateGlobalState>();
874
- auto &gstate = gstate_p.Cast<PhysicalHashAggregateGlobalSourceState>();
875
- auto &lstate = lstate_p.Cast<PhysicalHashAggregateLocalSourceState>();
885
+ auto &gstate = input.global_state.Cast<PhysicalHashAggregateGlobalSourceState>();
886
+ auto &lstate = input.local_state.Cast<PhysicalHashAggregateLocalSourceState>();
876
887
  while (true) {
877
888
  idx_t radix_idx = gstate.state_index;
878
889
  if (radix_idx >= groupings.size()) {
@@ -881,11 +892,17 @@ void PhysicalHashAggregate::GetData(ExecutionContext &context, DataChunk &chunk,
881
892
  auto &grouping = groupings[radix_idx];
882
893
  auto &radix_table = grouping.table_data;
883
894
  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]);
895
+
896
+ InterruptState interrupt_state;
897
+ OperatorSourceInput source_input {*gstate.radix_states[radix_idx], *lstate.radix_states[radix_idx],
898
+ interrupt_state};
899
+ auto res = radix_table.GetData(context, chunk, *grouping_gstate.table_state, source_input);
886
900
  if (chunk.size() != 0) {
887
- return;
901
+ return SourceResultType::HAVE_MORE_OUTPUT;
902
+ } else if (res == SourceResultType::BLOCKED) {
903
+ throw InternalException("Unexpectedly Blocked from radix_table");
888
904
  }
905
+
889
906
  // move to the next table
890
907
  lock_guard<mutex> l(gstate.lock);
891
908
  radix_idx++;
@@ -895,6 +912,8 @@ void PhysicalHashAggregate::GetData(ExecutionContext &context, DataChunk &chunk,
895
912
  gstate.state_index = radix_idx;
896
913
  }
897
914
  }
915
+
916
+ return chunk.size() == 0 ? SourceResultType::FINISHED : SourceResultType::HAVE_MORE_OUTPUT;
898
917
  }
899
918
 
900
919
  string PhysicalHashAggregate::ParamsToString() const {