duckdb 0.7.2-dev2867.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 (231) hide show
  1. package/binding.gyp +1 -0
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/icu/icu-datepart.cpp +5 -1
  4. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +18 -7
  5. package/src/duckdb/src/catalog/default/default_functions.cpp +2 -0
  6. package/src/duckdb/src/common/arrow/arrow_appender.cpp +3 -3
  7. package/src/duckdb/src/common/arrow/arrow_converter.cpp +2 -2
  8. package/src/duckdb/src/common/sort/partition_state.cpp +1 -1
  9. package/src/duckdb/src/common/string_util.cpp +6 -1
  10. package/src/duckdb/src/core_functions/function_list.cpp +2 -0
  11. package/src/duckdb/src/core_functions/scalar/string/format_bytes.cpp +29 -0
  12. package/src/duckdb/src/execution/index/art/art.cpp +5 -1
  13. package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +62 -43
  14. package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +17 -11
  15. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +32 -39
  16. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +10 -9
  17. package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +4 -4
  18. package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +6 -21
  19. package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +13 -13
  20. package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +15 -14
  21. package/src/duckdb/src/execution/operator/helper/physical_load.cpp +3 -2
  22. package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +4 -4
  23. package/src/duckdb/src/execution/operator/helper/physical_pragma.cpp +4 -2
  24. package/src/duckdb/src/execution/operator/helper/physical_prepare.cpp +4 -2
  25. package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +10 -8
  26. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +4 -3
  27. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +7 -6
  28. package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +4 -2
  29. package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +8 -8
  30. package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +17 -16
  31. package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +10 -8
  32. package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +3 -4
  33. package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +5 -5
  34. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +16 -15
  35. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +13 -12
  36. package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +12 -10
  37. package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +13 -11
  38. package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +8 -6
  39. package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
  40. package/src/duckdb/src/execution/operator/order/physical_order.cpp +13 -13
  41. package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +8 -8
  42. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +160 -145
  43. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +10 -25
  44. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +14 -19
  45. package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +7 -6
  46. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +18 -30
  47. package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +14 -18
  48. package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +6 -4
  49. package/src/duckdb/src/execution/operator/scan/physical_dummy_scan.cpp +4 -19
  50. package/src/duckdb/src/execution/operator/scan/physical_empty_result.cpp +3 -2
  51. package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +14 -5
  52. package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +6 -4
  53. package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +3 -19
  54. package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +4 -18
  55. package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +4 -19
  56. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +8 -9
  57. package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +4 -19
  58. package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +4 -19
  59. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +4 -19
  60. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +9 -26
  61. package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +4 -19
  62. package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +4 -19
  63. package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +3 -19
  64. package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +9 -8
  65. package/src/duckdb/src/execution/operator/set/physical_union.cpp +1 -1
  66. package/src/duckdb/src/execution/physical_operator.cpp +11 -5
  67. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +16 -16
  68. package/src/duckdb/src/function/table/arrow_conversion.cpp +3 -3
  69. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  70. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +7 -1
  71. package/src/duckdb/src/include/duckdb/common/enums/operator_result_type.hpp +16 -4
  72. package/src/duckdb/src/include/duckdb/common/optional_idx.hpp +45 -0
  73. package/src/duckdb/src/include/duckdb/common/set.hpp +2 -1
  74. package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +15 -0
  75. package/src/duckdb/src/include/duckdb/execution/executor.hpp +10 -1
  76. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +5 -8
  77. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +2 -4
  78. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +3 -7
  79. package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +2 -4
  80. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +1 -2
  81. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +2 -5
  82. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +2 -4
  83. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit_percent.hpp +2 -4
  84. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_load.hpp +1 -2
  85. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +1 -2
  86. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_pragma.hpp +1 -2
  87. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_prepare.hpp +1 -2
  88. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +2 -4
  89. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reset.hpp +1 -2
  90. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +1 -2
  91. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_transaction.hpp +1 -2
  92. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +2 -4
  93. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +2 -4
  94. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +2 -4
  95. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -2
  96. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +1 -2
  97. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +2 -4
  98. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +2 -4
  99. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_nested_loop_join.hpp +2 -4
  100. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +2 -4
  101. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +2 -4
  102. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +2 -4
  103. package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +2 -4
  104. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +3 -5
  105. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +2 -5
  106. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_delete.hpp +2 -4
  107. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +2 -4
  108. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +2 -4
  109. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +2 -4
  110. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +1 -2
  111. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_dummy_scan.hpp +1 -3
  112. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_empty_result.hpp +1 -2
  113. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_positional_scan.hpp +1 -2
  114. package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +1 -2
  115. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_alter.hpp +1 -3
  116. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +1 -3
  117. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_function.hpp +1 -3
  118. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +2 -4
  119. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_schema.hpp +1 -3
  120. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_sequence.hpp +1 -3
  121. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +1 -3
  122. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +2 -5
  123. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_view.hpp +1 -3
  124. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +1 -3
  125. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_drop.hpp +1 -3
  126. package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +2 -4
  127. package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +7 -4
  128. package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +26 -6
  129. package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +5 -5
  130. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +2 -1
  131. package/src/duckdb/src/include/duckdb/function/table_function.hpp +0 -1
  132. package/src/duckdb/src/include/duckdb/main/client_config.hpp +2 -0
  133. package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
  134. package/src/duckdb/src/include/duckdb/parallel/event.hpp +1 -1
  135. package/src/duckdb/src/include/duckdb/parallel/interrupt.hpp +63 -0
  136. package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +16 -3
  137. package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +51 -7
  138. package/src/duckdb/src/include/duckdb/parallel/task.hpp +21 -2
  139. package/src/duckdb/src/include/duckdb/parallel/task_counter.hpp +2 -2
  140. package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +2 -2
  141. package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +6 -0
  142. package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +1 -0
  143. package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +1 -0
  144. package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +1 -0
  145. package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +1 -0
  146. package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +1 -0
  147. package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +1 -0
  148. package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +1 -0
  149. package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +1 -0
  150. package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +1 -0
  151. package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +1 -0
  152. package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +1 -0
  153. package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +1 -0
  154. package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +1 -0
  155. package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +1 -0
  156. package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +1 -0
  157. package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +1 -0
  158. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -0
  159. package/src/duckdb/src/include/duckdb/storage/optimistic_data_writer.hpp +46 -0
  160. package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +24 -3
  161. package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +46 -1
  162. package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +9 -10
  163. package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +1 -1
  164. package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +2 -2
  165. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +3 -3
  166. package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -0
  167. package/src/duckdb/src/include/duckdb/storage/table/segment_base.hpp +1 -1
  168. package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +22 -0
  169. package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +3 -3
  170. package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +2 -2
  171. package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +0 -2
  172. package/src/duckdb/src/include/duckdb/storage/table/validity_column_data.hpp +1 -2
  173. package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +9 -34
  174. package/src/duckdb/src/include/duckdb/verification/no_operator_caching_verifier.hpp +25 -0
  175. package/src/duckdb/src/include/duckdb/verification/statement_verifier.hpp +5 -0
  176. package/src/duckdb/src/main/client_verify.cpp +4 -0
  177. package/src/duckdb/src/main/config.cpp +4 -0
  178. package/src/duckdb/src/main/database.cpp +11 -11
  179. package/src/duckdb/src/main/extension/extension_load.cpp +19 -15
  180. package/src/duckdb/src/parallel/event.cpp +1 -1
  181. package/src/duckdb/src/parallel/executor.cpp +39 -3
  182. package/src/duckdb/src/parallel/executor_task.cpp +11 -0
  183. package/src/duckdb/src/parallel/interrupt.cpp +57 -0
  184. package/src/duckdb/src/parallel/pipeline.cpp +49 -6
  185. package/src/duckdb/src/parallel/pipeline_executor.cpp +248 -69
  186. package/src/duckdb/src/parallel/pipeline_initialize_event.cpp +1 -1
  187. package/src/duckdb/src/parallel/task_scheduler.cpp +57 -22
  188. package/src/duckdb/src/parser/base_expression.cpp +6 -0
  189. package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +17 -3
  190. package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +8 -2
  191. package/src/duckdb/src/planner/operator/logical_aggregate.cpp +13 -1
  192. package/src/duckdb/src/planner/operator/logical_column_data_get.cpp +11 -0
  193. package/src/duckdb/src/planner/operator/logical_cteref.cpp +11 -0
  194. package/src/duckdb/src/planner/operator/logical_delete.cpp +10 -0
  195. package/src/duckdb/src/planner/operator/logical_delim_get.cpp +12 -1
  196. package/src/duckdb/src/planner/operator/logical_dummy_scan.cpp +12 -1
  197. package/src/duckdb/src/planner/operator/logical_expression_get.cpp +12 -1
  198. package/src/duckdb/src/planner/operator/logical_get.cpp +10 -4
  199. package/src/duckdb/src/planner/operator/logical_insert.cpp +12 -1
  200. package/src/duckdb/src/planner/operator/logical_pivot.cpp +11 -0
  201. package/src/duckdb/src/planner/operator/logical_projection.cpp +11 -0
  202. package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +11 -0
  203. package/src/duckdb/src/planner/operator/logical_set_operation.cpp +11 -0
  204. package/src/duckdb/src/planner/operator/logical_unnest.cpp +12 -1
  205. package/src/duckdb/src/planner/operator/logical_update.cpp +10 -0
  206. package/src/duckdb/src/planner/operator/logical_window.cpp +11 -0
  207. package/src/duckdb/src/storage/checkpoint_manager.cpp +1 -1
  208. package/src/duckdb/src/storage/data_table.cpp +5 -0
  209. package/src/duckdb/src/storage/local_storage.cpp +40 -110
  210. package/src/duckdb/src/storage/optimistic_data_writer.cpp +96 -0
  211. package/src/duckdb/src/storage/partial_block_manager.cpp +73 -9
  212. package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -1
  213. package/src/duckdb/src/storage/standard_buffer_manager.cpp +17 -12
  214. package/src/duckdb/src/storage/statistics/base_statistics.cpp +3 -0
  215. package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +90 -82
  216. package/src/duckdb/src/storage/table/column_data.cpp +19 -45
  217. package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +7 -7
  218. package/src/duckdb/src/storage/table/column_segment.cpp +1 -1
  219. package/src/duckdb/src/storage/table/list_column_data.cpp +6 -11
  220. package/src/duckdb/src/storage/table/row_group.cpp +13 -14
  221. package/src/duckdb/src/storage/table/row_group_collection.cpp +10 -4
  222. package/src/duckdb/src/storage/table/standard_column_data.cpp +6 -10
  223. package/src/duckdb/src/storage/table/struct_column_data.cpp +7 -13
  224. package/src/duckdb/src/storage/table/update_segment.cpp +0 -25
  225. package/src/duckdb/src/storage/table/validity_column_data.cpp +2 -6
  226. package/src/duckdb/src/transaction/commit_state.cpp +4 -4
  227. package/src/duckdb/src/verification/no_operator_caching_verifier.cpp +13 -0
  228. package/src/duckdb/src/verification/statement_verifier.cpp +4 -0
  229. package/src/duckdb/ub_src_core_functions_scalar_string.cpp +2 -0
  230. package/src/duckdb/ub_src_parallel.cpp +2 -0
  231. 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-dev2867.0",
5
+ "version": "0.7.2-dev2995.0",
6
6
  "description": "DuckDB node.js API",
7
7
  "gypfile": true,
8
8
  "dependencies": {
@@ -204,7 +204,11 @@ struct ICUDatePart : public ICUDateFunc {
204
204
  }
205
205
 
206
206
  static string_t MonthName(icu::Calendar *calendar, const uint64_t micros) {
207
- return Date::MONTH_NAMES[ExtractMonth(calendar, micros) - 1];
207
+ const auto mm = ExtractMonth(calendar, micros) - 1;
208
+ if (mm == 12) {
209
+ return "Undecember";
210
+ }
211
+ return Date::MONTH_NAMES[mm];
208
212
  }
209
213
 
210
214
  static string_t DayName(icu::Calendar *calendar, const uint64_t micros) {
@@ -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: {
@@ -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 {
@@ -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 {