duckdb 0.8.1-dev31.0 → 0.8.1-dev327.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 (633) hide show
  1. package/binding.gyp +8 -8
  2. package/package.json +1 -1
  3. package/src/duckdb/extension/icu/icu-datepart.cpp +1 -1
  4. package/src/duckdb/extension/icu/icu-makedate.cpp +5 -4
  5. package/src/duckdb/extension/json/buffered_json_reader.cpp +23 -14
  6. package/src/duckdb/extension/json/include/buffered_json_reader.hpp +6 -6
  7. package/src/duckdb/extension/json/include/json_common.hpp +13 -3
  8. package/src/duckdb/extension/json/include/json_executors.hpp +1 -1
  9. package/src/duckdb/extension/json/include/json_scan.hpp +3 -1
  10. package/src/duckdb/extension/json/json_functions/json_create.cpp +16 -16
  11. package/src/duckdb/extension/json/json_functions/json_merge_patch.cpp +3 -3
  12. package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +2 -2
  13. package/src/duckdb/extension/json/json_functions/json_structure.cpp +5 -3
  14. package/src/duckdb/extension/json/json_functions/json_transform.cpp +12 -12
  15. package/src/duckdb/extension/json/json_functions/read_json.cpp +2 -1
  16. package/src/duckdb/extension/json/json_functions.cpp +6 -3
  17. package/src/duckdb/extension/json/json_scan.cpp +40 -25
  18. package/src/duckdb/extension/parquet/column_reader.cpp +57 -52
  19. package/src/duckdb/extension/parquet/column_writer.cpp +57 -45
  20. package/src/duckdb/extension/parquet/include/cast_column_reader.hpp +1 -1
  21. package/src/duckdb/extension/parquet/include/column_reader.hpp +5 -4
  22. package/src/duckdb/extension/parquet/include/column_writer.hpp +24 -0
  23. package/src/duckdb/extension/parquet/include/decode_utils.hpp +6 -0
  24. package/src/duckdb/extension/parquet/include/list_column_reader.hpp +1 -1
  25. package/src/duckdb/extension/parquet/include/parquet_dbp_decoder.hpp +4 -4
  26. package/src/duckdb/extension/parquet/include/parquet_rle_bp_decoder.hpp +4 -5
  27. package/src/duckdb/extension/parquet/include/resizable_buffer.hpp +4 -4
  28. package/src/duckdb/extension/parquet/include/row_number_column_reader.hpp +1 -1
  29. package/src/duckdb/extension/parquet/include/struct_column_reader.hpp +1 -1
  30. package/src/duckdb/extension/parquet/parquet-extension.cpp +25 -1
  31. package/src/duckdb/extension/parquet/parquet_metadata.cpp +1 -1
  32. package/src/duckdb/extension/parquet/parquet_reader.cpp +18 -18
  33. package/src/duckdb/extension/parquet/parquet_statistics.cpp +23 -26
  34. package/src/duckdb/extension/parquet/parquet_timestamp.cpp +2 -2
  35. package/src/duckdb/extension/parquet/parquet_writer.cpp +3 -3
  36. package/src/duckdb/extension/parquet/zstd_file_system.cpp +3 -3
  37. package/src/duckdb/src/catalog/catalog.cpp +5 -17
  38. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +113 -0
  39. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +7 -0
  40. package/src/duckdb/src/catalog/catalog_entry.cpp +4 -4
  41. package/src/duckdb/src/catalog/catalog_search_path.cpp +49 -12
  42. package/src/duckdb/src/catalog/catalog_set.cpp +1 -1
  43. package/src/duckdb/src/catalog/default/default_types.cpp +9 -84
  44. package/src/duckdb/src/catalog/dependency_manager.cpp +2 -2
  45. package/src/duckdb/src/catalog/duck_catalog.cpp +1 -0
  46. package/src/duckdb/src/common/adbc/adbc.cpp +301 -106
  47. package/src/duckdb/src/common/adbc/driver_manager.cpp +10 -22
  48. package/src/duckdb/src/common/arrow/arrow_appender.cpp +12 -12
  49. package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +7 -7
  50. package/src/duckdb/src/common/checksum.cpp +1 -1
  51. package/src/duckdb/src/common/compressed_file_system.cpp +6 -6
  52. package/src/duckdb/src/common/crypto/md5.cpp +9 -9
  53. package/src/duckdb/src/common/exception.cpp +4 -1
  54. package/src/duckdb/src/common/exception_format_value.cpp +19 -14
  55. package/src/duckdb/src/common/field_writer.cpp +1 -1
  56. package/src/duckdb/src/common/file_system.cpp +15 -2
  57. package/src/duckdb/src/common/fsst.cpp +11 -6
  58. package/src/duckdb/src/common/gzip_file_system.cpp +8 -8
  59. package/src/duckdb/src/common/hive_partitioning.cpp +1 -1
  60. package/src/duckdb/src/common/local_file_system.cpp +11 -11
  61. package/src/duckdb/src/common/multi_file_reader.cpp +3 -0
  62. package/src/duckdb/src/common/operator/cast_operators.cpp +1 -1
  63. package/src/duckdb/src/common/pipe_file_system.cpp +2 -2
  64. package/src/duckdb/src/common/radix_partitioning.cpp +2 -2
  65. package/src/duckdb/src/common/row_operations/row_heap_gather.cpp +1 -1
  66. package/src/duckdb/src/common/row_operations/row_heap_scatter.cpp +5 -5
  67. package/src/duckdb/src/common/row_operations/row_match.cpp +1 -1
  68. package/src/duckdb/src/common/row_operations/row_radix_scatter.cpp +2 -2
  69. package/src/duckdb/src/common/row_operations/row_scatter.cpp +4 -4
  70. package/src/duckdb/src/common/serializer/binary_deserializer.cpp +1 -1
  71. package/src/duckdb/src/common/serializer/binary_serializer.cpp +3 -3
  72. package/src/duckdb/src/common/serializer.cpp +1 -1
  73. package/src/duckdb/src/common/sort/comparators.cpp +1 -1
  74. package/src/duckdb/src/common/sort/merge_sorter.cpp +7 -2
  75. package/src/duckdb/src/common/sort/partition_state.cpp +2 -2
  76. package/src/duckdb/src/common/types/bit.cpp +5 -5
  77. package/src/duckdb/src/common/types/blob.cpp +8 -8
  78. package/src/duckdb/src/common/types/column/column_data_allocator.cpp +4 -4
  79. package/src/duckdb/src/common/types/column/column_data_collection.cpp +3 -3
  80. package/src/duckdb/src/common/types/column/column_data_collection_segment.cpp +1 -1
  81. package/src/duckdb/src/common/types/column/partitioned_column_data.cpp +2 -2
  82. package/src/duckdb/src/common/types/hash.cpp +2 -2
  83. package/src/duckdb/src/common/types/hyperloglog.cpp +22 -21
  84. package/src/duckdb/src/common/types/list_segment.cpp +77 -49
  85. package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +1 -1
  86. package/src/duckdb/src/common/types/row/row_data_collection_scanner.cpp +5 -4
  87. package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +5 -3
  88. package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +61 -24
  89. package/src/duckdb/src/common/types/string_heap.cpp +1 -1
  90. package/src/duckdb/src/common/types/timestamp.cpp +37 -1
  91. package/src/duckdb/src/common/types/value.cpp +3 -2
  92. package/src/duckdb/src/common/types/vector.cpp +98 -101
  93. package/src/duckdb/src/common/types/vector_cache.cpp +6 -6
  94. package/src/duckdb/src/common/types/vector_constants.cpp +2 -1
  95. package/src/duckdb/src/common/types.cpp +44 -33
  96. package/src/duckdb/src/common/vector_operations/boolean_operators.cpp +2 -2
  97. package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +12 -12
  98. package/src/duckdb/src/common/vector_operations/vector_hash.cpp +13 -11
  99. package/src/duckdb/src/common/vector_operations/vector_storage.cpp +1 -1
  100. package/src/duckdb/src/core_functions/aggregate/algebraic/avg.cpp +30 -33
  101. package/src/duckdb/src/core_functions/aggregate/algebraic/covar.cpp +0 -4
  102. package/src/duckdb/src/core_functions/aggregate/distributive/approx_count.cpp +32 -36
  103. package/src/duckdb/src/core_functions/aggregate/distributive/arg_min_max.cpp +53 -66
  104. package/src/duckdb/src/core_functions/aggregate/distributive/bitagg.cpp +48 -48
  105. package/src/duckdb/src/core_functions/aggregate/distributive/bitstring_agg.cpp +44 -44
  106. package/src/duckdb/src/core_functions/aggregate/distributive/bool.cpp +32 -32
  107. package/src/duckdb/src/core_functions/aggregate/distributive/entropy.cpp +34 -34
  108. package/src/duckdb/src/core_functions/aggregate/distributive/kurtosis.cpp +30 -31
  109. package/src/duckdb/src/core_functions/aggregate/distributive/minmax.cpp +91 -103
  110. package/src/duckdb/src/core_functions/aggregate/distributive/product.cpp +17 -17
  111. package/src/duckdb/src/core_functions/aggregate/distributive/skew.cpp +25 -27
  112. package/src/duckdb/src/core_functions/aggregate/distributive/string_agg.cpp +36 -37
  113. package/src/duckdb/src/core_functions/aggregate/distributive/sum.cpp +22 -22
  114. package/src/duckdb/src/core_functions/aggregate/holistic/approximate_quantile.cpp +48 -84
  115. package/src/duckdb/src/core_functions/aggregate/holistic/mode.cpp +49 -51
  116. package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +115 -133
  117. package/src/duckdb/src/core_functions/aggregate/holistic/reservoir_quantile.cpp +62 -99
  118. package/src/duckdb/src/core_functions/aggregate/nested/histogram.cpp +24 -26
  119. package/src/duckdb/src/core_functions/aggregate/nested/list.cpp +22 -23
  120. package/src/duckdb/src/core_functions/aggregate/regression/regr_avg.cpp +16 -18
  121. package/src/duckdb/src/core_functions/aggregate/regression/regr_intercept.cpp +22 -25
  122. package/src/duckdb/src/core_functions/aggregate/regression/regr_r2.cpp +19 -24
  123. package/src/duckdb/src/core_functions/aggregate/regression/regr_sxx_syy.cpp +18 -23
  124. package/src/duckdb/src/core_functions/aggregate/regression/regr_sxy.cpp +14 -18
  125. package/src/duckdb/src/core_functions/function_list.cpp +1 -0
  126. package/src/duckdb/src/core_functions/scalar/blob/base64.cpp +1 -1
  127. package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +45 -45
  128. package/src/duckdb/src/core_functions/scalar/date/strftime.cpp +2 -2
  129. package/src/duckdb/src/core_functions/scalar/generic/current_setting.cpp +1 -1
  130. package/src/duckdb/src/core_functions/scalar/generic/least.cpp +2 -2
  131. package/src/duckdb/src/core_functions/scalar/generic/stats.cpp +1 -1
  132. package/src/duckdb/src/core_functions/scalar/generic/system_functions.cpp +14 -0
  133. package/src/duckdb/src/core_functions/scalar/list/array_slice.cpp +3 -3
  134. package/src/duckdb/src/core_functions/scalar/list/flatten.cpp +2 -4
  135. package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +3 -3
  136. package/src/duckdb/src/core_functions/scalar/list/list_lambdas.cpp +6 -7
  137. package/src/duckdb/src/core_functions/scalar/list/list_sort.cpp +1 -1
  138. package/src/duckdb/src/core_functions/scalar/map/cardinality.cpp +1 -1
  139. package/src/duckdb/src/core_functions/scalar/map/map.cpp +2 -2
  140. package/src/duckdb/src/core_functions/scalar/map/map_concat.cpp +4 -1
  141. package/src/duckdb/src/core_functions/scalar/map/map_extract.cpp +5 -9
  142. package/src/duckdb/src/core_functions/scalar/math/numeric.cpp +3 -3
  143. package/src/duckdb/src/core_functions/scalar/string/starts_with.cpp +3 -2
  144. package/src/duckdb/src/core_functions/scalar/string/string_split.cpp +4 -4
  145. package/src/duckdb/src/core_functions/scalar/string/trim.cpp +1 -1
  146. package/src/duckdb/src/core_functions/scalar/union/union_extract.cpp +1 -1
  147. package/src/duckdb/src/execution/adaptive_filter.cpp +1 -1
  148. package/src/duckdb/src/execution/expression_executor/execute_case.cpp +10 -10
  149. package/src/duckdb/src/execution/expression_executor/execute_conjunction.cpp +7 -7
  150. package/src/duckdb/src/execution/expression_executor.cpp +28 -28
  151. package/src/duckdb/src/execution/index/art/art.cpp +110 -39
  152. package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +23 -5
  153. package/src/duckdb/src/execution/index/art/leaf.cpp +10 -11
  154. package/src/duckdb/src/execution/index/art/leaf_segment.cpp +10 -0
  155. package/src/duckdb/src/execution/index/art/node.cpp +47 -35
  156. package/src/duckdb/src/execution/index/art/node16.cpp +3 -0
  157. package/src/duckdb/src/execution/index/art/node256.cpp +1 -0
  158. package/src/duckdb/src/execution/index/art/node4.cpp +3 -0
  159. package/src/duckdb/src/execution/index/art/node48.cpp +2 -0
  160. package/src/duckdb/src/execution/index/art/prefix.cpp +2 -0
  161. package/src/duckdb/src/execution/join_hashtable.cpp +4 -4
  162. package/src/duckdb/src/execution/nested_loop_join/nested_loop_join_inner.cpp +4 -4
  163. package/src/duckdb/src/execution/nested_loop_join/nested_loop_join_mark.cpp +2 -2
  164. package/src/duckdb/src/execution/operator/aggregate/distinct_aggregate_data.cpp +1 -1
  165. package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +1 -1
  166. package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +2 -2
  167. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +4 -4
  168. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +25 -9
  169. package/src/duckdb/src/execution/operator/filter/physical_filter.cpp +1 -1
  170. package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +5 -2
  171. package/src/duckdb/src/execution/operator/helper/physical_set.cpp +5 -1
  172. package/src/duckdb/src/execution/operator/join/outer_join_marker.cpp +1 -1
  173. package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +1 -1
  174. package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +2 -2
  175. package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +4 -4
  176. package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +3 -3
  177. package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +3 -3
  178. package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +3 -3
  179. package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +1 -1
  180. package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +2 -2
  181. package/src/duckdb/src/execution/operator/persistent/csv_file_handle.cpp +2 -2
  182. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +2 -3
  183. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +1 -1
  184. package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +2 -2
  185. package/src/duckdb/src/execution/operator/projection/physical_projection.cpp +1 -1
  186. package/src/duckdb/src/execution/operator/projection/physical_unnest.cpp +3 -3
  187. package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +2 -1
  188. package/src/duckdb/src/execution/operator/scan/physical_expression_scan.cpp +1 -1
  189. package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +2 -2
  190. package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +29 -3
  191. package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +1 -1
  192. package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +1 -1
  193. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +1 -1
  194. package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +1 -1
  195. package/src/duckdb/src/execution/physical_plan_generator.cpp +2 -2
  196. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +1 -1
  197. package/src/duckdb/src/execution/reservoir_sample.cpp +2 -2
  198. package/src/duckdb/src/execution/window_segment_tree.cpp +8 -6
  199. package/src/duckdb/src/function/aggregate/distributive/count.cpp +158 -20
  200. package/src/duckdb/src/function/aggregate/distributive/first.cpp +66 -74
  201. package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +13 -13
  202. package/src/duckdb/src/function/cast/cast_function_set.cpp +1 -1
  203. package/src/duckdb/src/function/cast/decimal_cast.cpp +1 -1
  204. package/src/duckdb/src/function/cast/enum_casts.cpp +2 -2
  205. package/src/duckdb/src/function/cast/list_casts.cpp +2 -4
  206. package/src/duckdb/src/function/cast/string_cast.cpp +11 -11
  207. package/src/duckdb/src/function/cast/union_casts.cpp +2 -2
  208. package/src/duckdb/src/function/cast/vector_cast_helpers.cpp +3 -2
  209. package/src/duckdb/src/function/pragma/pragma_queries.cpp +33 -23
  210. package/src/duckdb/src/function/scalar/generic/constant_or_null.cpp +1 -1
  211. package/src/duckdb/src/function/scalar/list/list_concat.cpp +2 -2
  212. package/src/duckdb/src/function/scalar/list/list_extract.cpp +3 -3
  213. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +2 -3
  214. package/src/duckdb/src/function/scalar/string/concat.cpp +8 -7
  215. package/src/duckdb/src/function/scalar/string/contains.cpp +4 -4
  216. package/src/duckdb/src/function/scalar/string/like.cpp +5 -5
  217. package/src/duckdb/src/function/scalar/string/regexp/regexp_extract_all.cpp +4 -4
  218. package/src/duckdb/src/function/scalar/string/regexp/regexp_util.cpp +6 -2
  219. package/src/duckdb/src/function/scalar/string/regexp.cpp +3 -3
  220. package/src/duckdb/src/function/scalar/string/strip_accents.cpp +1 -1
  221. package/src/duckdb/src/function/scalar/struct/struct_extract.cpp +1 -1
  222. package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +25 -23
  223. package/src/duckdb/src/function/scalar_function.cpp +3 -3
  224. package/src/duckdb/src/function/table/arrow.cpp +6 -6
  225. package/src/duckdb/src/function/table/arrow_conversion.cpp +67 -61
  226. package/src/duckdb/src/function/table/checkpoint.cpp +1 -1
  227. package/src/duckdb/src/function/table/copy_csv.cpp +11 -7
  228. package/src/duckdb/src/function/table/glob.cpp +1 -1
  229. package/src/duckdb/src/function/table/pragma_last_profiling_output.cpp +1 -1
  230. package/src/duckdb/src/function/table/range.cpp +4 -4
  231. package/src/duckdb/src/function/table/read_csv.cpp +17 -20
  232. package/src/duckdb/src/function/table/repeat.cpp +5 -2
  233. package/src/duckdb/src/function/table/repeat_row.cpp +10 -3
  234. package/src/duckdb/src/function/table/system/duckdb_functions.cpp +1 -1
  235. package/src/duckdb/src/function/table/system/test_vector_types.cpp +82 -26
  236. package/src/duckdb/src/function/table/table_scan.cpp +2 -2
  237. package/src/duckdb/src/function/table/unnest.cpp +1 -1
  238. package/src/duckdb/src/function/table/version/pragma_version.cpp +3 -3
  239. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +2 -5
  240. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +2 -0
  241. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +6 -0
  242. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +2 -2
  243. package/src/duckdb/src/include/duckdb/catalog/catalog_search_path.hpp +8 -2
  244. package/src/duckdb/src/include/duckdb/catalog/default/builtin_types/types.hpp +97 -0
  245. package/src/duckdb/src/include/duckdb/common/adbc/adbc.hpp +5 -0
  246. package/src/duckdb/src/include/duckdb/common/allocator.hpp +15 -4
  247. package/src/duckdb/src/include/duckdb/common/arrow/arrow_buffer.hpp +7 -2
  248. package/src/duckdb/src/include/duckdb/common/crypto/md5.hpp +2 -2
  249. package/src/duckdb/src/include/duckdb/common/exception.hpp +5 -2
  250. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +3 -3
  251. package/src/duckdb/src/include/duckdb/common/file_system.hpp +11 -0
  252. package/src/duckdb/src/include/duckdb/common/fsst.hpp +2 -3
  253. package/src/duckdb/src/include/duckdb/common/radix.hpp +3 -3
  254. package/src/duckdb/src/include/duckdb/common/serializer/binary_deserializer.hpp +1 -1
  255. package/src/duckdb/src/include/duckdb/common/serializer/binary_serializer.hpp +4 -1
  256. package/src/duckdb/src/include/duckdb/common/serializer.hpp +4 -4
  257. package/src/duckdb/src/include/duckdb/common/typedefs.hpp +30 -0
  258. package/src/duckdb/src/include/duckdb/common/types/column/partitioned_column_data.hpp +12 -0
  259. package/src/duckdb/src/include/duckdb/common/types/hyperloglog.hpp +6 -2
  260. package/src/duckdb/src/include/duckdb/common/types/null_value.hpp +1 -1
  261. package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +12 -0
  262. package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +10 -10
  263. package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +4 -14
  264. package/src/duckdb/src/include/duckdb/common/types/value.hpp +1 -1
  265. package/src/duckdb/src/include/duckdb/common/types/vector.hpp +9 -0
  266. package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +18 -6
  267. package/src/duckdb/src/include/duckdb/common/vector_operations/aggregate_executor.hpp +112 -76
  268. package/src/duckdb/src/include/duckdb/common/vector_operations/binary_executor.hpp +16 -15
  269. package/src/duckdb/src/include/duckdb/common/vector_operations/generic_executor.hpp +11 -11
  270. package/src/duckdb/src/include/duckdb/common/vector_operations/ternary_executor.hpp +23 -19
  271. package/src/duckdb/src/include/duckdb/common/vector_operations/unary_executor.hpp +3 -3
  272. package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/corr.hpp +20 -24
  273. package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/covar.hpp +36 -39
  274. package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/stddev.hpp +57 -53
  275. package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_count.hpp +8 -9
  276. package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_slope.hpp +16 -18
  277. package/src/duckdb/src/include/duckdb/core_functions/aggregate/sum_helpers.hpp +7 -8
  278. package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +9 -0
  279. package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +2 -6
  280. package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +16 -36
  281. package/src/duckdb/src/include/duckdb/execution/expression_executor_state.hpp +14 -2
  282. package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +13 -7
  283. package/src/duckdb/src/include/duckdb/execution/index/art/fixed_size_allocator.hpp +3 -0
  284. package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +1 -1
  285. package/src/duckdb/src/include/duckdb/execution/index/art/leaf_segment.hpp +2 -0
  286. package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +13 -3
  287. package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +1 -0
  288. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_result_collector.hpp +3 -0
  289. package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_buffer.hpp +1 -1
  290. package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +5 -2
  291. package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +12 -12
  292. package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +8 -29
  293. package/src/duckdb/src/include/duckdb/function/aggregate_state.hpp +95 -0
  294. package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +13 -2
  295. package/src/duckdb/src/include/duckdb/function/cast/vector_cast_helpers.hpp +4 -4
  296. package/src/duckdb/src/include/duckdb/function/compression_function.hpp +44 -0
  297. package/src/duckdb/src/include/duckdb/function/copy_function.hpp +6 -6
  298. package/src/duckdb/src/include/duckdb/function/function.hpp +3 -3
  299. package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +3 -1
  300. package/src/duckdb/src/include/duckdb/function/macro_function.hpp +2 -2
  301. package/src/duckdb/src/include/duckdb/function/scalar/list/contains_or_position.hpp +3 -3
  302. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +2 -2
  303. package/src/duckdb/src/include/duckdb/function/table_function.hpp +8 -7
  304. package/src/duckdb/src/include/duckdb/main/capi/cast/utils.hpp +1 -1
  305. package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
  306. package/src/duckdb/src/include/duckdb/main/materialized_query_result.hpp +3 -0
  307. package/src/duckdb/src/include/duckdb/main/pending_query_result.hpp +3 -0
  308. package/src/duckdb/src/include/duckdb/main/query_result.hpp +17 -0
  309. package/src/duckdb/src/include/duckdb/main/relation.hpp +12 -0
  310. package/src/duckdb/src/include/duckdb/main/settings.hpp +9 -0
  311. package/src/duckdb/src/include/duckdb/main/stream_query_result.hpp +3 -0
  312. package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +2 -2
  313. package/src/duckdb/src/include/duckdb/parser/base_expression.hpp +6 -12
  314. package/src/duckdb/src/include/duckdb/parser/constraint.hpp +2 -2
  315. package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +1 -1
  316. package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +1 -1
  317. package/src/duckdb/src/include/duckdb/parser/expression/case_expression.hpp +1 -1
  318. package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +1 -1
  319. package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +1 -1
  320. package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +1 -1
  321. package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +1 -1
  322. package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +1 -1
  323. package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +1 -1
  324. package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +1 -1
  325. package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +1 -1
  326. package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +1 -1
  327. package/src/duckdb/src/include/duckdb/parser/expression/parameter_expression.hpp +1 -1
  328. package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +1 -1
  329. package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +1 -1
  330. package/src/duckdb/src/include/duckdb/parser/expression/subquery_expression.hpp +1 -1
  331. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +1 -1
  332. package/src/duckdb/src/include/duckdb/parser/expression_map.hpp +1 -1
  333. package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +2 -2
  334. package/src/duckdb/src/include/duckdb/parser/parsed_expression.hpp +5 -1
  335. package/src/duckdb/src/include/duckdb/parser/parser.hpp +2 -0
  336. package/src/duckdb/src/include/duckdb/parser/query_node.hpp +2 -2
  337. package/src/duckdb/src/include/duckdb/parser/result_modifier.hpp +36 -5
  338. package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +7 -4
  339. package/src/duckdb/src/include/duckdb/parser/statement/select_statement.hpp +1 -1
  340. package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +1 -1
  341. package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +2 -2
  342. package/src/duckdb/src/include/duckdb/parser/tableref/expressionlistref.hpp +1 -1
  343. package/src/duckdb/src/include/duckdb/parser/tableref/joinref.hpp +1 -1
  344. package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +1 -1
  345. package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +1 -1
  346. package/src/duckdb/src/include/duckdb/parser/tableref/table_function_ref.hpp +1 -1
  347. package/src/duckdb/src/include/duckdb/parser/tableref.hpp +4 -3
  348. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +106 -92
  349. package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -2
  350. package/src/duckdb/src/include/duckdb/planner/bound_constraint.hpp +2 -2
  351. package/src/duckdb/src/include/duckdb/planner/bound_query_node.hpp +2 -2
  352. package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +34 -1
  353. package/src/duckdb/src/include/duckdb/planner/bound_tableref.hpp +2 -2
  354. package/src/duckdb/src/include/duckdb/planner/expression/bound_aggregate_expression.hpp +1 -1
  355. package/src/duckdb/src/include/duckdb/planner/expression/bound_between_expression.hpp +1 -1
  356. package/src/duckdb/src/include/duckdb/planner/expression/bound_case_expression.hpp +1 -1
  357. package/src/duckdb/src/include/duckdb/planner/expression/bound_cast_expression.hpp +1 -1
  358. package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +1 -1
  359. package/src/duckdb/src/include/duckdb/planner/expression/bound_comparison_expression.hpp +1 -1
  360. package/src/duckdb/src/include/duckdb/planner/expression/bound_conjunction_expression.hpp +1 -1
  361. package/src/duckdb/src/include/duckdb/planner/expression/bound_constant_expression.hpp +1 -1
  362. package/src/duckdb/src/include/duckdb/planner/expression/bound_function_expression.hpp +1 -1
  363. package/src/duckdb/src/include/duckdb/planner/expression/bound_lambda_expression.hpp +1 -1
  364. package/src/duckdb/src/include/duckdb/planner/expression/bound_lambdaref_expression.hpp +1 -1
  365. package/src/duckdb/src/include/duckdb/planner/expression/bound_operator_expression.hpp +1 -1
  366. package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_expression.hpp +1 -1
  367. package/src/duckdb/src/include/duckdb/planner/expression/bound_reference_expression.hpp +1 -1
  368. package/src/duckdb/src/include/duckdb/planner/expression/bound_subquery_expression.hpp +1 -1
  369. package/src/duckdb/src/include/duckdb/planner/expression/bound_unnest_expression.hpp +1 -1
  370. package/src/duckdb/src/include/duckdb/planner/expression/bound_window_expression.hpp +1 -1
  371. package/src/duckdb/src/include/duckdb/planner/expression.hpp +5 -7
  372. package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +1 -1
  373. package/src/duckdb/src/include/duckdb/planner/filter/conjunction_filter.hpp +6 -0
  374. package/src/duckdb/src/include/duckdb/planner/filter/constant_filter.hpp +3 -0
  375. package/src/duckdb/src/include/duckdb/planner/filter/null_filter.hpp +6 -0
  376. package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +7 -2
  377. package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +6 -2
  378. package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +4 -0
  379. package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +5 -1
  380. package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +5 -1
  381. package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +3 -0
  382. package/src/duckdb/src/include/duckdb/planner/operator/logical_pragma.hpp +6 -2
  383. package/src/duckdb/src/include/duckdb/planner/operator/logical_prepare.hpp +4 -0
  384. package/src/duckdb/src/include/duckdb/planner/table_binding.hpp +26 -0
  385. package/src/duckdb/src/include/duckdb/planner/table_filter.hpp +17 -0
  386. package/src/duckdb/src/include/duckdb/planner/tableref/bound_pivotref.hpp +3 -0
  387. package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/byte_reader.hpp +4 -0
  388. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_analyze.hpp +1 -1
  389. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_compress.hpp +2 -2
  390. package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_analyze.hpp +2 -2
  391. package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_compress.hpp +2 -2
  392. package/src/duckdb/src/include/duckdb/storage/in_memory_block_manager.hpp +13 -13
  393. package/src/duckdb/src/include/duckdb/storage/index.hpp +6 -4
  394. package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +1 -1
  395. package/src/duckdb/src/include/duckdb/storage/storage_extension.hpp +0 -6
  396. package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +12 -0
  397. package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +1 -1
  398. package/src/duckdb/src/include/duckdb/storage/table/chunk_info.hpp +25 -2
  399. package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +12 -0
  400. package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +22 -0
  401. package/src/duckdb/src/include/duckdb/transaction/duck_transaction_manager.hpp +2 -2
  402. package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +2 -2
  403. package/src/duckdb/src/main/capi/appender-c.cpp +5 -5
  404. package/src/duckdb/src/main/capi/arrow-c.cpp +10 -10
  405. package/src/duckdb/src/main/capi/cast/from_decimal-c.cpp +1 -1
  406. package/src/duckdb/src/main/capi/cast/utils-c.cpp +1 -1
  407. package/src/duckdb/src/main/capi/config-c.cpp +3 -6
  408. package/src/duckdb/src/main/capi/data_chunk-c.cpp +17 -17
  409. package/src/duckdb/src/main/capi/duckdb-c.cpp +4 -4
  410. package/src/duckdb/src/main/capi/duckdb_value-c.cpp +4 -4
  411. package/src/duckdb/src/main/capi/logical_types-c.cpp +22 -21
  412. package/src/duckdb/src/main/capi/pending-c.cpp +6 -6
  413. package/src/duckdb/src/main/capi/prepared-c.cpp +10 -10
  414. package/src/duckdb/src/main/capi/replacement_scan-c.cpp +6 -6
  415. package/src/duckdb/src/main/capi/result-c.cpp +23 -23
  416. package/src/duckdb/src/main/capi/table_function-c.cpp +1 -1
  417. package/src/duckdb/src/main/client_context.cpp +3 -3
  418. package/src/duckdb/src/main/config.cpp +1 -0
  419. package/src/duckdb/src/main/database_manager.cpp +1 -1
  420. package/src/duckdb/src/main/error_manager.cpp +1 -1
  421. package/src/duckdb/src/main/extension/extension_load.cpp +1 -1
  422. package/src/duckdb/src/main/relation/create_table_relation.cpp +1 -1
  423. package/src/duckdb/src/main/relation/create_view_relation.cpp +1 -1
  424. package/src/duckdb/src/main/relation/delete_relation.cpp +1 -1
  425. package/src/duckdb/src/main/relation/explain_relation.cpp +1 -1
  426. package/src/duckdb/src/main/relation/insert_relation.cpp +1 -1
  427. package/src/duckdb/src/main/relation/update_relation.cpp +1 -1
  428. package/src/duckdb/src/main/relation/write_csv_relation.cpp +1 -1
  429. package/src/duckdb/src/main/relation/write_parquet_relation.cpp +1 -1
  430. package/src/duckdb/src/main/relation.cpp +1 -1
  431. package/src/duckdb/src/main/settings/settings.cpp +22 -6
  432. package/src/duckdb/src/optimizer/deliminator.cpp +12 -12
  433. package/src/duckdb/src/optimizer/expression_heuristics.cpp +1 -0
  434. package/src/duckdb/src/optimizer/filter_combiner.cpp +3 -3
  435. package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +10 -10
  436. package/src/duckdb/src/optimizer/matcher/expression_matcher.cpp +1 -1
  437. package/src/duckdb/src/optimizer/pullup/pullup_projection.cpp +2 -2
  438. package/src/duckdb/src/optimizer/regex_range_filter.cpp +2 -4
  439. package/src/duckdb/src/optimizer/rule/distributivity.cpp +2 -2
  440. package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +6 -6
  441. package/src/duckdb/src/optimizer/statistics/operator/propagate_get.cpp +2 -2
  442. package/src/duckdb/src/parallel/executor.cpp +1 -1
  443. package/src/duckdb/src/parser/base_expression.cpp +2 -5
  444. package/src/duckdb/src/parser/column_definition.cpp +5 -8
  445. package/src/duckdb/src/parser/expression/between_expression.cpp +4 -4
  446. package/src/duckdb/src/parser/expression/case_expression.cpp +6 -6
  447. package/src/duckdb/src/parser/expression/cast_expression.cpp +4 -4
  448. package/src/duckdb/src/parser/expression/collate_expression.cpp +3 -3
  449. package/src/duckdb/src/parser/expression/columnref_expression.cpp +4 -4
  450. package/src/duckdb/src/parser/expression/comparison_expression.cpp +3 -3
  451. package/src/duckdb/src/parser/expression/conjunction_expression.cpp +2 -2
  452. package/src/duckdb/src/parser/expression/constant_expression.cpp +2 -2
  453. package/src/duckdb/src/parser/expression/function_expression.cpp +10 -14
  454. package/src/duckdb/src/parser/expression/lambda_expression.cpp +2 -2
  455. package/src/duckdb/src/parser/expression/operator_expression.cpp +4 -4
  456. package/src/duckdb/src/parser/expression/parameter_expression.cpp +2 -2
  457. package/src/duckdb/src/parser/expression/positional_reference_expression.cpp +3 -3
  458. package/src/duckdb/src/parser/expression/star_expression.cpp +9 -9
  459. package/src/duckdb/src/parser/expression/subquery_expression.cpp +5 -5
  460. package/src/duckdb/src/parser/expression/window_expression.cpp +13 -24
  461. package/src/duckdb/src/parser/parsed_data/create_info.cpp +0 -3
  462. package/src/duckdb/src/parser/parsed_expression.cpp +34 -18
  463. package/src/duckdb/src/parser/parsed_expression_iterator.cpp +4 -4
  464. package/src/duckdb/src/parser/parser.cpp +4 -4
  465. package/src/duckdb/src/parser/query_node/select_node.cpp +6 -13
  466. package/src/duckdb/src/parser/query_node.cpp +7 -6
  467. package/src/duckdb/src/parser/result_modifier.cpp +25 -18
  468. package/src/duckdb/src/parser/statement/select_statement.cpp +3 -3
  469. package/src/duckdb/src/parser/tableref/basetableref.cpp +4 -4
  470. package/src/duckdb/src/parser/tableref/emptytableref.cpp +1 -1
  471. package/src/duckdb/src/parser/tableref/expressionlistref.cpp +5 -5
  472. package/src/duckdb/src/parser/tableref/joinref.cpp +6 -6
  473. package/src/duckdb/src/parser/tableref/pivotref.cpp +10 -15
  474. package/src/duckdb/src/parser/tableref/subqueryref.cpp +3 -3
  475. package/src/duckdb/src/parser/tableref/table_function.cpp +3 -3
  476. package/src/duckdb/src/parser/tableref.cpp +12 -3
  477. package/src/duckdb/src/parser/transform/expression/transform_array_access.cpp +7 -7
  478. package/src/duckdb/src/parser/transform/expression/transform_bool_expr.cpp +4 -4
  479. package/src/duckdb/src/parser/transform/expression/transform_boolean_test.cpp +4 -4
  480. package/src/duckdb/src/parser/transform/expression/transform_case.cpp +8 -10
  481. package/src/duckdb/src/parser/transform/expression/transform_cast.cpp +7 -9
  482. package/src/duckdb/src/parser/transform/expression/transform_coalesce.cpp +3 -5
  483. package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +22 -22
  484. package/src/duckdb/src/parser/transform/expression/transform_constant.cpp +2 -2
  485. package/src/duckdb/src/parser/transform/expression/transform_expression.cpp +42 -44
  486. package/src/duckdb/src/parser/transform/expression/transform_function.cpp +70 -75
  487. package/src/duckdb/src/parser/transform/expression/transform_grouping_function.cpp +4 -4
  488. package/src/duckdb/src/parser/transform/expression/transform_interval.cpp +7 -7
  489. package/src/duckdb/src/parser/transform/expression/transform_is_null.cpp +4 -5
  490. package/src/duckdb/src/parser/transform/expression/transform_lambda.cpp +5 -6
  491. package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +28 -29
  492. package/src/duckdb/src/parser/transform/expression/transform_param_ref.cpp +13 -14
  493. package/src/duckdb/src/parser/transform/expression/transform_positional_reference.cpp +4 -4
  494. package/src/duckdb/src/parser/transform/expression/transform_subquery.cpp +9 -10
  495. package/src/duckdb/src/parser/transform/helpers/nodetype_to_string.cpp +0 -2
  496. package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +28 -32
  497. package/src/duckdb/src/parser/transform/helpers/transform_groupby.cpp +18 -18
  498. package/src/duckdb/src/parser/transform/helpers/transform_sample.cpp +3 -3
  499. package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +27 -26
  500. package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +11 -14
  501. package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +14 -16
  502. package/src/duckdb/src/parser/transform/statement/transform_attach.cpp +8 -9
  503. package/src/duckdb/src/parser/transform/statement/transform_call.cpp +2 -5
  504. package/src/duckdb/src/parser/transform/statement/transform_checkpoint.cpp +4 -6
  505. package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +22 -23
  506. package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +14 -18
  507. package/src/duckdb/src/parser/transform/statement/transform_create_index.cpp +13 -15
  508. package/src/duckdb/src/parser/transform/statement/transform_create_schema.cpp +8 -10
  509. package/src/duckdb/src/parser/transform/statement/transform_create_sequence.cpp +8 -10
  510. package/src/duckdb/src/parser/transform/statement/transform_create_table.cpp +26 -28
  511. package/src/duckdb/src/parser/transform/statement/transform_create_table_as.cpp +8 -10
  512. package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +12 -15
  513. package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +13 -18
  514. package/src/duckdb/src/parser/transform/statement/transform_delete.cpp +11 -13
  515. package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +3 -4
  516. package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +20 -25
  517. package/src/duckdb/src/parser/transform/statement/transform_explain.cpp +5 -7
  518. package/src/duckdb/src/parser/transform/statement/transform_export.cpp +5 -6
  519. package/src/duckdb/src/parser/transform/statement/transform_import.cpp +2 -3
  520. package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +21 -24
  521. package/src/duckdb/src/parser/transform/statement/transform_load.cpp +4 -5
  522. package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +7 -7
  523. package/src/duckdb/src/parser/transform/statement/transform_pragma.cpp +7 -9
  524. package/src/duckdb/src/parser/transform/statement/transform_prepare.cpp +11 -19
  525. package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +12 -14
  526. package/src/duckdb/src/parser/transform/statement/transform_select.cpp +12 -9
  527. package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +34 -34
  528. package/src/duckdb/src/parser/transform/statement/transform_set.cpp +18 -19
  529. package/src/duckdb/src/parser/transform/statement/transform_show.cpp +5 -7
  530. package/src/duckdb/src/parser/transform/statement/transform_show_select.cpp +4 -5
  531. package/src/duckdb/src/parser/transform/statement/transform_transaction.cpp +3 -5
  532. package/src/duckdb/src/parser/transform/statement/transform_update.cpp +10 -13
  533. package/src/duckdb/src/parser/transform/statement/transform_upsert.cpp +4 -4
  534. package/src/duckdb/src/parser/transform/statement/transform_use.cpp +2 -3
  535. package/src/duckdb/src/parser/transform/statement/transform_vacuum.cpp +6 -10
  536. package/src/duckdb/src/parser/transform/tableref/transform_base_tableref.cpp +18 -18
  537. package/src/duckdb/src/parser/transform/tableref/transform_from.cpp +5 -5
  538. package/src/duckdb/src/parser/transform/tableref/transform_join.cpp +11 -11
  539. package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +30 -27
  540. package/src/duckdb/src/parser/transform/tableref/transform_subquery.cpp +5 -5
  541. package/src/duckdb/src/parser/transform/tableref/transform_table_function.cpp +13 -12
  542. package/src/duckdb/src/parser/transform/tableref/transform_tableref.cpp +8 -8
  543. package/src/duckdb/src/parser/transformer.cpp +45 -47
  544. package/src/duckdb/src/planner/bind_context.cpp +9 -10
  545. package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +1 -1
  546. package/src/duckdb/src/planner/binder/expression/bind_lambda.cpp +1 -1
  547. package/src/duckdb/src/planner/binder/expression/bind_positional_reference_expression.cpp +8 -3
  548. package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +1 -1
  549. package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +6 -3
  550. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +8 -8
  551. package/src/duckdb/src/planner/binder/query_node/plan_query_node.cpp +4 -4
  552. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +1 -28
  553. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +18 -1
  554. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +0 -25
  555. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +2 -2
  556. package/src/duckdb/src/planner/binder/statement/bind_update.cpp +2 -114
  557. package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +4 -2
  558. package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +5 -2
  559. package/src/duckdb/src/planner/binder.cpp +1 -1
  560. package/src/duckdb/src/planner/bound_result_modifier.cpp +16 -11
  561. package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +5 -5
  562. package/src/duckdb/src/planner/expression/bound_between_expression.cpp +5 -5
  563. package/src/duckdb/src/planner/expression/bound_case_expression.cpp +5 -5
  564. package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +3 -3
  565. package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +2 -2
  566. package/src/duckdb/src/planner/expression/bound_comparison_expression.cpp +4 -4
  567. package/src/duckdb/src/planner/expression/bound_conjunction_expression.cpp +2 -2
  568. package/src/duckdb/src/planner/expression/bound_constant_expression.cpp +2 -2
  569. package/src/duckdb/src/planner/expression/bound_expression.cpp +1 -1
  570. package/src/duckdb/src/planner/expression/bound_function_expression.cpp +3 -4
  571. package/src/duckdb/src/planner/expression/bound_lambda_expression.cpp +4 -5
  572. package/src/duckdb/src/planner/expression/bound_lambdaref_expression.cpp +2 -2
  573. package/src/duckdb/src/planner/expression/bound_operator_expression.cpp +3 -4
  574. package/src/duckdb/src/planner/expression/bound_parameter_expression.cpp +2 -2
  575. package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +2 -2
  576. package/src/duckdb/src/planner/expression/bound_subquery_expression.cpp +1 -1
  577. package/src/duckdb/src/planner/expression/bound_unnest_expression.cpp +3 -3
  578. package/src/duckdb/src/planner/expression/bound_window_expression.cpp +8 -21
  579. package/src/duckdb/src/planner/expression.cpp +15 -0
  580. package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +2 -2
  581. package/src/duckdb/src/planner/expression_binder.cpp +3 -2
  582. package/src/duckdb/src/planner/expression_iterator.cpp +2 -2
  583. package/src/duckdb/src/planner/filter/conjunction_filter.cpp +2 -2
  584. package/src/duckdb/src/planner/filter/constant_filter.cpp +1 -1
  585. package/src/duckdb/src/planner/logical_operator.cpp +3 -4
  586. package/src/duckdb/src/planner/logical_operator_visitor.cpp +1 -1
  587. package/src/duckdb/src/planner/operator/logical_pivot.cpp +14 -2
  588. package/src/duckdb/src/planner/planner.cpp +5 -15
  589. package/src/duckdb/src/planner/table_filter.cpp +1 -1
  590. package/src/duckdb/src/storage/arena_allocator.cpp +2 -2
  591. package/src/duckdb/src/storage/buffer/block_handle.cpp +1 -1
  592. package/src/duckdb/src/storage/checkpoint/write_overflow_strings_to_disk.cpp +2 -2
  593. package/src/duckdb/src/storage/checkpoint_manager.cpp +3 -3
  594. package/src/duckdb/src/storage/compression/bitpacking.cpp +8 -8
  595. package/src/duckdb/src/storage/compression/dictionary_compression.cpp +36 -36
  596. package/src/duckdb/src/storage/compression/fixed_size_uncompressed.cpp +11 -11
  597. package/src/duckdb/src/storage/compression/fsst.cpp +34 -34
  598. package/src/duckdb/src/storage/compression/rle.cpp +8 -8
  599. package/src/duckdb/src/storage/compression/string_uncompressed.cpp +13 -13
  600. package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +11 -11
  601. package/src/duckdb/src/storage/data_table.cpp +8 -7
  602. package/src/duckdb/src/storage/index.cpp +14 -3
  603. package/src/duckdb/src/storage/local_storage.cpp +2 -1
  604. package/src/duckdb/src/storage/magic_bytes.cpp +1 -1
  605. package/src/duckdb/src/storage/single_file_block_manager.cpp +3 -3
  606. package/src/duckdb/src/storage/standard_buffer_manager.cpp +3 -3
  607. package/src/duckdb/src/storage/statistics/list_stats.cpp +1 -1
  608. package/src/duckdb/src/storage/statistics/numeric_stats.cpp +1 -1
  609. package/src/duckdb/src/storage/statistics/string_stats.cpp +15 -14
  610. package/src/duckdb/src/storage/table/chunk_info.cpp +2 -2
  611. package/src/duckdb/src/storage/table/column_segment.cpp +3 -3
  612. package/src/duckdb/src/storage/table/list_column_data.cpp +3 -3
  613. package/src/duckdb/src/storage/table/row_group.cpp +4 -4
  614. package/src/duckdb/src/storage/table/standard_column_data.cpp +1 -1
  615. package/src/duckdb/src/storage/table/update_segment.cpp +12 -12
  616. package/src/duckdb/src/storage/wal_replay.cpp +5 -6
  617. package/src/duckdb/src/transaction/cleanup_state.cpp +3 -3
  618. package/src/duckdb/src/transaction/commit_state.cpp +8 -8
  619. package/src/duckdb/src/transaction/duck_transaction.cpp +9 -7
  620. package/src/duckdb/src/transaction/duck_transaction_manager.cpp +16 -16
  621. package/src/duckdb/src/transaction/rollback_state.cpp +3 -3
  622. package/src/duckdb/src/verification/prepared_statement_verifier.cpp +1 -1
  623. package/src/duckdb/src/verification/statement_verifier.cpp +3 -4
  624. package/src/duckdb/third_party/hyperloglog/hyperloglog.hpp +2 -2
  625. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +0 -14
  626. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +12828 -12956
  627. package/src/duckdb/third_party/pcg/pcg_extras.hpp +1 -1
  628. package/src/duckdb/third_party/zstd/compress/zstd_compress.cpp +3 -0
  629. package/src/duckdb/third_party/zstd/include/zstd/compress/zstd_cwksp.h +4 -0
  630. package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +5 -5
  631. package/src/duckdb/ub_src_parser_transform_statement.cpp +0 -2
  632. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +0 -46
  633. package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +0 -28
@@ -7,6 +7,8 @@
7
7
  #include "duckdb/storage/storage_manager.hpp"
8
8
  #include "duckdb/main/database_manager.hpp"
9
9
  #include "duckdb/execution/index/art/art_key.hpp"
10
+ #include "duckdb/execution/index/art/node.hpp"
11
+ #include "duckdb/execution/index/art/leaf.hpp"
10
12
 
11
13
  namespace duckdb {
12
14
 
@@ -106,6 +108,28 @@ SinkResultType PhysicalCreateIndex::Sink(ExecutionContext &context, DataChunk &c
106
108
  if (!lstate.local_index->MergeIndexes(*art)) {
107
109
  throw ConstraintException("Data contains duplicates on indexed column(s)");
108
110
  }
111
+
112
+ #ifdef DEBUG
113
+ // ensure that all row IDs of this chunk exist in the ART
114
+ auto row_ids = FlatVector::GetData<row_t>(row_identifiers);
115
+ for (idx_t i = 0; i < lstate.key_chunk.size(); i++) {
116
+ auto leaf_node =
117
+ lstate.local_index->Cast<ART>().Lookup(*lstate.local_index->Cast<ART>().tree, lstate.keys[i], 0);
118
+ D_ASSERT(leaf_node.IsSet());
119
+ auto &leaf = Leaf::Get(lstate.local_index->Cast<ART>(), leaf_node);
120
+
121
+ if (leaf.IsInlined()) {
122
+ D_ASSERT(row_ids[i] == leaf.row_ids.inlined);
123
+ continue;
124
+ }
125
+
126
+ D_ASSERT(leaf.row_ids.ptr.IsSet());
127
+ Node leaf_segment = leaf.row_ids.ptr;
128
+ auto position = leaf.FindRowId(lstate.local_index->Cast<ART>(), leaf_segment, row_ids[i]);
129
+ D_ASSERT(position != (uint32_t)DConstants::INVALID_INDEX);
130
+ }
131
+ #endif
132
+
109
133
  return SinkResultType::NEED_MORE_INPUT;
110
134
  }
111
135
 
@@ -119,6 +143,9 @@ void PhysicalCreateIndex::Combine(ExecutionContext &context, GlobalSinkState &gs
119
143
  if (!gstate.global_index->MergeIndexes(*lstate.local_index)) {
120
144
  throw ConstraintException("Data contains duplicates on indexed column(s)");
121
145
  }
146
+
147
+ // vacuum excess memory
148
+ gstate.global_index->Vacuum();
122
149
  }
123
150
 
124
151
  SinkFinalizeType PhysicalCreateIndex::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
@@ -127,6 +154,8 @@ SinkFinalizeType PhysicalCreateIndex::Finalize(Pipeline &pipeline, Event &event,
127
154
  // here, we just set the resulting global index as the newly created index of the table
128
155
 
129
156
  auto &state = gstate_p.Cast<CreateIndexGlobalSinkState>();
157
+ D_ASSERT(!state.global_index->VerifyAndToString(true).empty());
158
+
130
159
  auto &storage = table.GetStorage();
131
160
  if (!storage.IsRoot()) {
132
161
  throw TransactionException("Transaction conflict: cannot add an index to a table that has been altered!");
@@ -147,9 +176,6 @@ SinkFinalizeType PhysicalCreateIndex::Finalize(Pipeline &pipeline, Event &event,
147
176
  index.parsed_expressions.push_back(parsed_expr->Copy());
148
177
  }
149
178
 
150
- // vacuum excess memory
151
- state.global_index->Vacuum();
152
-
153
179
  // add index to storage
154
180
  storage.info->indexes.AddIndex(std::move(state.global_index));
155
181
  return SinkFinalizeType::READY;
@@ -45,7 +45,7 @@ SinkResultType PhysicalCreateType::Sink(ExecutionContext &context, DataChunk &ch
45
45
  gstate.capacity *= 2;
46
46
  }
47
47
 
48
- auto src_ptr = (string_t *)sdata.data;
48
+ auto src_ptr = UnifiedVectorFormat::GetData<string_t>(sdata);
49
49
  auto result_ptr = FlatVector::GetData<string_t>(gstate.result);
50
50
  // Input vector has NULL value, we just throw an exception
51
51
  for (idx_t i = 0; i < chunk.size(); i++) {
@@ -51,7 +51,7 @@ PerfectAggregateHashTable::~PerfectAggregateHashTable() {
51
51
  template <class T>
52
52
  static void ComputeGroupLocationTemplated(UnifiedVectorFormat &group_data, Value &min, uintptr_t *address_data,
53
53
  idx_t current_shift, idx_t count) {
54
- auto data = (T *)group_data.data;
54
+ auto data = UnifiedVectorFormat::GetData<T>(group_data);
55
55
  auto min_val = min.GetValueUnsafe<T>();
56
56
  if (!group_data.validity.AllValid()) {
57
57
  for (idx_t i = 0; i < count; i++) {
@@ -186,7 +186,7 @@ static bool PlanIndexJoin(ClientContext &context, LogicalComparisonJoin &op, uni
186
186
  }
187
187
  // index joins are not supported if there are pushed down table filters
188
188
  D_ASSERT(right->type == PhysicalOperatorType::TABLE_SCAN);
189
- auto &tbl_scan = (PhysicalTableScan &)*right;
189
+ auto &tbl_scan = right->Cast<PhysicalTableScan>();
190
190
  // if (tbl_scan.table_filters && !tbl_scan.table_filters->filters.empty()) {
191
191
  // return false;
192
192
  // }
@@ -34,7 +34,7 @@ unique_ptr<PhysicalOperator> DuckCatalog::PlanCreateTableAs(ClientContext &conte
34
34
  }
35
35
 
36
36
  unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalCreateTable &op) {
37
- const auto &create_info = (CreateTableInfo &)*op.info->base;
37
+ const auto &create_info = op.info->base->Cast<CreateTableInfo>();
38
38
  auto &catalog = op.info->schema.catalog;
39
39
  auto existing_entry = catalog.GetEntry<TableCatalogEntry>(context, create_info.schema, create_info.table,
40
40
  OnEntryNotFound::RETURN_NULL);
@@ -207,10 +207,10 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalOperator &
207
207
  plan = CreatePlan(op.Cast<LogicalReset>());
208
208
  break;
209
209
  case LogicalOperatorType::LOGICAL_PIVOT:
210
- plan = CreatePlan((LogicalPivot &)op);
210
+ plan = CreatePlan(op.Cast<LogicalPivot>());
211
211
  break;
212
212
  case LogicalOperatorType::LOGICAL_EXTENSION_OPERATOR:
213
- plan = ((LogicalExtensionOperator &)op).CreatePlan(context, *this);
213
+ plan = op.Cast<LogicalExtensionOperator>().CreatePlan(context, *this);
214
214
 
215
215
  if (!plan) {
216
216
  throw InternalException("Missing PhysicalOperator for Extension Operator");
@@ -408,7 +408,7 @@ SourceResultType RadixPartitionedHashTable::GetData(ExecutionContext &context, D
408
408
  aggr.function.initialize(aggr_state.get());
409
409
 
410
410
  AggregateInputData aggr_input_data(aggr.bind_info.get(), Allocator::DefaultAllocator());
411
- Vector state_vector(Value::POINTER((uintptr_t)aggr_state.get()));
411
+ Vector state_vector(Value::POINTER(CastPointerToValue(aggr_state.get())));
412
412
  aggr.function.finalize(state_vector, aggr_input_data, chunk.data[null_groups.size() + i], 1, 0);
413
413
  if (aggr.function.destructor) {
414
414
  aggr.function.destructor(state_vector, aggr_input_data, 1);
@@ -186,7 +186,7 @@ void BaseReservoirSampling::InitializeReservoir(idx_t cur_size, idx_t sample_siz
186
186
  //! we use a priority queue to extract the minimum key in O(1) time
187
187
  for (idx_t i = 0; i < sample_size; i++) {
188
188
  double k_i = random.NextRandom();
189
- reservoir_weights.push(std::make_pair(-k_i, i));
189
+ reservoir_weights.emplace(-k_i, i);
190
190
  }
191
191
  SetNextEntry();
192
192
  }
@@ -217,7 +217,7 @@ void BaseReservoirSampling::ReplaceElement() {
217
217
  //! we generate a random number between (min_threshold, 1)
218
218
  double r2 = random.NextRandom(min_threshold, 1);
219
219
  //! now we insert the new weight into the reservoir
220
- reservoir_weights.push(std::make_pair(-r2, min_entry));
220
+ reservoir_weights.emplace(-r2, min_entry);
221
221
  //! we update the min entry with the new min entry in the reservoir
222
222
  SetNextEntry();
223
223
  }
@@ -12,7 +12,8 @@ namespace duckdb {
12
12
 
13
13
  WindowAggregateState::WindowAggregateState(AggregateObject aggr, const LogicalType &result_type_p)
14
14
  : aggr(std::move(aggr)), result_type(result_type_p), state(aggr.function.state_size()),
15
- statev(Value::POINTER((idx_t)state.data())), statep(Value::POINTER((idx_t)state.data())) {
15
+ statev(Value::POINTER(CastPointerToValue(state.data()))),
16
+ statep(Value::POINTER(CastPointerToValue(state.data()))) {
16
17
  statev.SetVectorType(VectorType::FLAT_VECTOR); // Prevent conversion of results to constants
17
18
  }
18
19
 
@@ -180,11 +181,12 @@ void WindowConstantAggregate::Compute(Vector &target, idx_t rid, idx_t start, id
180
181
  //===--------------------------------------------------------------------===//
181
182
  // WindowSegmentTree
182
183
  //===--------------------------------------------------------------------===//
183
- WindowSegmentTree::WindowSegmentTree(AggregateObject aggr, const LogicalType &result_type_p, DataChunk *input,
184
+ WindowSegmentTree::WindowSegmentTree(AggregateObject aggr_p, const LogicalType &result_type_p, DataChunk *input,
184
185
  const ValidityMask &filter_mask_p, WindowAggregationMode mode_p)
185
- : aggr(std::move(aggr)), result_type(result_type_p), state(aggr.function.state_size()),
186
- statep(Value::POINTER((idx_t)state.data())), frame(0, 0), statev(Value::POINTER((idx_t)state.data())),
187
- internal_nodes(0), input_ref(input), filter_mask(filter_mask_p), mode(mode_p) {
186
+ : aggr(std::move(aggr_p)), result_type(result_type_p), state(aggr.function.state_size()),
187
+ statep(Value::POINTER(CastPointerToValue(state.data()))), frame(0, 0),
188
+ statev(Value::POINTER(CastPointerToValue(state.data()))), internal_nodes(0), input_ref(input),
189
+ filter_mask(filter_mask_p), mode(mode_p) {
188
190
  statep.Flatten(input->size());
189
191
  statev.SetVectorType(VectorType::FLAT_VECTOR); // Prevent conversion of results to constants
190
192
 
@@ -212,7 +214,7 @@ WindowSegmentTree::~WindowSegmentTree() {
212
214
  AggregateInputData aggr_input_data(aggr.GetFunctionData(), Allocator::DefaultAllocator());
213
215
  // call the destructor for all the intermediate states
214
216
  data_ptr_t address_data[STANDARD_VECTOR_SIZE];
215
- Vector addresses(LogicalType::POINTER, (data_ptr_t)address_data);
217
+ Vector addresses(LogicalType::POINTER, data_ptr_cast(address_data));
216
218
  idx_t count = 0;
217
219
  for (idx_t i = 0; i < internal_nodes; i++) {
218
220
  address_data[count++] = data_ptr_t(levels_flat_native.get() + i * state.size());
@@ -7,30 +7,30 @@ namespace duckdb {
7
7
 
8
8
  struct BaseCountFunction {
9
9
  template <class STATE>
10
- static void Initialize(STATE *state) {
11
- *state = 0;
10
+ static void Initialize(STATE &state) {
11
+ state = 0;
12
12
  }
13
13
 
14
14
  template <class STATE, class OP>
15
- static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
16
- *target += source;
15
+ static void Combine(const STATE &source, STATE &target, AggregateInputData &) {
16
+ target += source;
17
17
  }
18
18
 
19
19
  template <class T, class STATE>
20
- static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
21
- target[idx] = *state;
20
+ static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
21
+ target = state;
22
22
  }
23
23
  };
24
24
 
25
25
  struct CountStarFunction : public BaseCountFunction {
26
26
  template <class STATE, class OP>
27
- static void Operation(STATE *state, AggregateInputData &, idx_t idx) {
28
- *state += 1;
27
+ static void Operation(STATE &state, AggregateInputData &, idx_t idx) {
28
+ state += 1;
29
29
  }
30
30
 
31
31
  template <class STATE, class OP>
32
- static void ConstantOperation(STATE *state, AggregateInputData &, idx_t count) {
33
- *state += count;
32
+ static void ConstantOperation(STATE &state, AggregateInputData &, idx_t count) {
33
+ state += count;
34
34
  }
35
35
 
36
36
  template <typename RESULT_TYPE>
@@ -55,27 +55,165 @@ struct CountStarFunction : public BaseCountFunction {
55
55
  };
56
56
 
57
57
  struct CountFunction : public BaseCountFunction {
58
- template <class INPUT_TYPE, class STATE, class OP>
59
- static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
60
- *state += 1;
58
+ using STATE = int64_t;
59
+
60
+ static void Operation(STATE &state) {
61
+ state += 1;
61
62
  }
62
63
 
63
- template <class INPUT_TYPE, class STATE, class OP>
64
- static void ConstantOperation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask,
65
- idx_t count) {
66
- *state += count;
64
+ static void ConstantOperation(STATE &state, idx_t count) {
65
+ state += count;
67
66
  }
68
67
 
69
68
  static bool IgnoreNull() {
70
69
  return true;
71
70
  }
71
+
72
+ static inline void CountFlatLoop(STATE **__restrict states, ValidityMask &mask, idx_t count) {
73
+ if (!mask.AllValid()) {
74
+ idx_t base_idx = 0;
75
+ auto entry_count = ValidityMask::EntryCount(count);
76
+ for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
77
+ auto validity_entry = mask.GetValidityEntry(entry_idx);
78
+ idx_t next = MinValue<idx_t>(base_idx + ValidityMask::BITS_PER_VALUE, count);
79
+ if (ValidityMask::AllValid(validity_entry)) {
80
+ // all valid: perform operation
81
+ for (; base_idx < next; base_idx++) {
82
+ CountFunction::Operation(*states[base_idx]);
83
+ }
84
+ } else if (ValidityMask::NoneValid(validity_entry)) {
85
+ // nothing valid: skip all
86
+ base_idx = next;
87
+ continue;
88
+ } else {
89
+ // partially valid: need to check individual elements for validity
90
+ idx_t start = base_idx;
91
+ for (; base_idx < next; base_idx++) {
92
+ if (ValidityMask::RowIsValid(validity_entry, base_idx - start)) {
93
+ CountFunction::Operation(*states[base_idx]);
94
+ }
95
+ }
96
+ }
97
+ }
98
+ } else {
99
+ for (idx_t i = 0; i < count; i++) {
100
+ CountFunction::Operation(*states[i]);
101
+ }
102
+ }
103
+ }
104
+
105
+ static inline void CountScatterLoop(STATE **__restrict states, const SelectionVector &isel,
106
+ const SelectionVector &ssel, ValidityMask &mask, idx_t count) {
107
+ if (!mask.AllValid()) {
108
+ // potential NULL values
109
+ for (idx_t i = 0; i < count; i++) {
110
+ auto idx = isel.get_index(i);
111
+ auto sidx = ssel.get_index(i);
112
+ if (mask.RowIsValid(idx)) {
113
+ CountFunction::Operation(*states[sidx]);
114
+ }
115
+ }
116
+ } else {
117
+ // quick path: no NULL values
118
+ for (idx_t i = 0; i < count; i++) {
119
+ auto sidx = ssel.get_index(i);
120
+ CountFunction::Operation(*states[sidx]);
121
+ }
122
+ }
123
+ }
124
+
125
+ static void CountScatter(Vector inputs[], AggregateInputData &aggr_input_data, idx_t input_count, Vector &states,
126
+ idx_t count) {
127
+ auto &input = inputs[0];
128
+ if (input.GetVectorType() == VectorType::FLAT_VECTOR && states.GetVectorType() == VectorType::FLAT_VECTOR) {
129
+ auto sdata = FlatVector::GetData<STATE *>(states);
130
+ CountFlatLoop(sdata, FlatVector::Validity(input), count);
131
+ } else {
132
+ UnifiedVectorFormat idata, sdata;
133
+ input.ToUnifiedFormat(count, idata);
134
+ states.ToUnifiedFormat(count, sdata);
135
+ CountScatterLoop(reinterpret_cast<STATE **>(sdata.data), *idata.sel, *sdata.sel, idata.validity, count);
136
+ }
137
+ }
138
+
139
+ static inline void CountFlatUpdateLoop(STATE &result, ValidityMask &mask, idx_t count) {
140
+ idx_t base_idx = 0;
141
+ auto entry_count = ValidityMask::EntryCount(count);
142
+ for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
143
+ auto validity_entry = mask.GetValidityEntry(entry_idx);
144
+ idx_t next = MinValue<idx_t>(base_idx + ValidityMask::BITS_PER_VALUE, count);
145
+ if (ValidityMask::AllValid(validity_entry)) {
146
+ // all valid
147
+ result += next - base_idx;
148
+ base_idx = next;
149
+ } else if (ValidityMask::NoneValid(validity_entry)) {
150
+ // nothing valid: skip all
151
+ base_idx = next;
152
+ continue;
153
+ } else {
154
+ // partially valid: need to check individual elements for validity
155
+ idx_t start = base_idx;
156
+ for (; base_idx < next; base_idx++) {
157
+ if (ValidityMask::RowIsValid(validity_entry, base_idx - start)) {
158
+ result++;
159
+ }
160
+ }
161
+ }
162
+ }
163
+ }
164
+
165
+ static inline void CountUpdateLoop(STATE &result, ValidityMask &mask, idx_t count,
166
+ const SelectionVector &sel_vector) {
167
+ if (mask.AllValid()) {
168
+ // no NULL values
169
+ result += count;
170
+ return;
171
+ }
172
+ for (idx_t i = 0; i < count; i++) {
173
+ auto idx = sel_vector.get_index(i);
174
+ if (mask.RowIsValid(idx)) {
175
+ result++;
176
+ }
177
+ }
178
+ }
179
+
180
+ static void CountUpdate(Vector inputs[], AggregateInputData &, idx_t input_count, data_ptr_t state_p, idx_t count) {
181
+ auto &input = inputs[0];
182
+ auto &result = *reinterpret_cast<STATE *>(state_p);
183
+ switch (input.GetVectorType()) {
184
+ case VectorType::CONSTANT_VECTOR: {
185
+ if (!ConstantVector::IsNull(input)) {
186
+ // if the constant is not null increment the state
187
+ result += count;
188
+ }
189
+ break;
190
+ }
191
+ case VectorType::FLAT_VECTOR: {
192
+ CountFlatUpdateLoop(result, FlatVector::Validity(input), count);
193
+ break;
194
+ }
195
+ case VectorType::SEQUENCE_VECTOR: {
196
+ // sequence vectors cannot have NULL values
197
+ result += count;
198
+ break;
199
+ }
200
+ default: {
201
+ UnifiedVectorFormat idata;
202
+ input.ToUnifiedFormat(count, idata);
203
+ CountUpdateLoop(result, idata.validity, count, *idata.sel);
204
+ break;
205
+ }
206
+ }
207
+ }
72
208
  };
73
209
 
74
210
  AggregateFunction CountFun::GetFunction() {
75
- auto fun = AggregateFunction::UnaryAggregate<int64_t, int64_t, int64_t, CountFunction>(
76
- LogicalType(LogicalTypeId::ANY), LogicalType::BIGINT);
211
+ AggregateFunction fun({LogicalType(LogicalTypeId::ANY)}, LogicalType::BIGINT, AggregateFunction::StateSize<int64_t>,
212
+ AggregateFunction::StateInitialize<int64_t, CountFunction>, CountFunction::CountScatter,
213
+ AggregateFunction::StateCombine<int64_t, CountFunction>,
214
+ AggregateFunction::StateFinalize<int64_t, int64_t, CountFunction>,
215
+ FunctionNullHandling::SPECIAL_HANDLING, CountFunction::CountUpdate);
77
216
  fun.name = "count";
78
- fun.null_handling = FunctionNullHandling::SPECIAL_HANDLING;
79
217
  fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
80
218
  return fun;
81
219
  }
@@ -14,9 +14,9 @@ struct FirstState {
14
14
 
15
15
  struct FirstFunctionBase {
16
16
  template <class STATE>
17
- static void Initialize(STATE *state) {
18
- state->is_set = false;
19
- state->is_null = false;
17
+ static void Initialize(STATE &state) {
18
+ state.is_set = false;
19
+ state.is_null = false;
20
20
  }
21
21
 
22
22
  static bool IgnoreNull() {
@@ -27,40 +27,40 @@ struct FirstFunctionBase {
27
27
  template <bool LAST, bool SKIP_NULLS>
28
28
  struct FirstFunction : public FirstFunctionBase {
29
29
  template <class INPUT_TYPE, class STATE, class OP>
30
- static void Operation(STATE *state, AggregateInputData &, INPUT_TYPE *input, ValidityMask &mask, idx_t idx) {
31
- if (LAST || !state->is_set) {
32
- if (!mask.RowIsValid(idx)) {
30
+ static void Operation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input) {
31
+ if (LAST || !state.is_set) {
32
+ if (!unary_input.RowIsValid()) {
33
33
  if (!SKIP_NULLS) {
34
- state->is_set = true;
34
+ state.is_set = true;
35
35
  }
36
- state->is_null = true;
36
+ state.is_null = true;
37
37
  } else {
38
- state->is_set = true;
39
- state->is_null = false;
40
- state->value = input[idx];
38
+ state.is_set = true;
39
+ state.is_null = false;
40
+ state.value = input;
41
41
  }
42
42
  }
43
43
  }
44
44
 
45
45
  template <class INPUT_TYPE, class STATE, class OP>
46
- static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
47
- ValidityMask &mask, idx_t count) {
48
- Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
46
+ static void ConstantOperation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input,
47
+ idx_t count) {
48
+ Operation<INPUT_TYPE, STATE, OP>(state, input, unary_input);
49
49
  }
50
50
 
51
51
  template <class STATE, class OP>
52
- static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
53
- if (!target->is_set) {
54
- *target = source;
52
+ static void Combine(const STATE &source, STATE &target, AggregateInputData &) {
53
+ if (!target.is_set) {
54
+ target = source;
55
55
  }
56
56
  }
57
57
 
58
58
  template <class T, class STATE>
59
- static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
60
- if (!state->is_set || state->is_null) {
61
- mask.SetInvalid(idx);
59
+ static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
60
+ if (!state.is_set || state.is_null) {
61
+ finalize_data.ReturnNull();
62
62
  } else {
63
- target[idx] = state->value;
63
+ target = state.value;
64
64
  }
65
65
  }
66
66
  };
@@ -68,65 +68,64 @@ struct FirstFunction : public FirstFunctionBase {
68
68
  template <bool LAST, bool SKIP_NULLS>
69
69
  struct FirstFunctionString : public FirstFunctionBase {
70
70
  template <class STATE>
71
- static void SetValue(STATE *state, AggregateInputData &input_data, string_t value, bool is_null) {
72
- if (LAST && state->is_set) {
73
- Destroy(input_data, state);
71
+ static void SetValue(STATE &state, AggregateInputData &input_data, string_t value, bool is_null) {
72
+ if (LAST && state.is_set) {
73
+ Destroy(state, input_data);
74
74
  }
75
75
  if (is_null) {
76
76
  if (!SKIP_NULLS) {
77
- state->is_set = true;
78
- state->is_null = true;
77
+ state.is_set = true;
78
+ state.is_null = true;
79
79
  }
80
80
  } else {
81
- state->is_set = true;
82
- state->is_null = false;
81
+ state.is_set = true;
82
+ state.is_null = false;
83
83
  if (value.IsInlined()) {
84
- state->value = value;
84
+ state.value = value;
85
85
  } else {
86
86
  // non-inlined string, need to allocate space for it
87
87
  auto len = value.GetSize();
88
88
  auto ptr = new char[len];
89
89
  memcpy(ptr, value.GetData(), len);
90
90
 
91
- state->value = string_t(ptr, len);
91
+ state.value = string_t(ptr, len);
92
92
  }
93
93
  }
94
94
  }
95
95
 
96
96
  template <class INPUT_TYPE, class STATE, class OP>
97
- static void Operation(STATE *state, AggregateInputData &input_data, INPUT_TYPE *input, ValidityMask &mask,
98
- idx_t idx) {
99
- if (LAST || !state->is_set) {
100
- SetValue(state, input_data, input[idx], !mask.RowIsValid(idx));
97
+ static void Operation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input) {
98
+ if (LAST || !state.is_set) {
99
+ SetValue(state, unary_input.input, input, !unary_input.RowIsValid());
101
100
  }
102
101
  }
103
102
 
104
103
  template <class INPUT_TYPE, class STATE, class OP>
105
- static void ConstantOperation(STATE *state, AggregateInputData &aggr_input_data, INPUT_TYPE *input,
106
- ValidityMask &mask, idx_t count) {
107
- Operation<INPUT_TYPE, STATE, OP>(state, aggr_input_data, input, mask, 0);
104
+ static void ConstantOperation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input,
105
+ idx_t count) {
106
+ Operation<INPUT_TYPE, STATE, OP>(state, input, unary_input);
108
107
  }
109
108
 
110
109
  template <class STATE, class OP>
111
- static void Combine(const STATE &source, STATE *target, AggregateInputData &input_data) {
112
- if (source.is_set && (LAST || !target->is_set)) {
110
+ static void Combine(const STATE &source, STATE &target, AggregateInputData &input_data) {
111
+ if (source.is_set && (LAST || !target.is_set)) {
113
112
  SetValue(target, input_data, source.value, source.is_null);
114
113
  }
115
114
  }
116
115
 
117
116
  template <class T, class STATE>
118
- static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
119
- if (!state->is_set || state->is_null) {
120
- mask.SetInvalid(idx);
117
+ static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
118
+ if (!state.is_set || state.is_null) {
119
+ finalize_data.ReturnNull();
121
120
  } else {
122
- target[idx] = StringVector::AddStringOrBlob(result, state->value);
121
+ target = StringVector::AddStringOrBlob(finalize_data.result, state.value);
123
122
  }
124
123
  }
125
124
 
126
125
  template <class STATE>
127
- static void Destroy(AggregateInputData &aggr_input_data, STATE *state) {
128
- if (state->is_set && !state->is_null && !state->value.IsInlined()) {
129
- delete[] state->value.GetData();
126
+ static void Destroy(STATE &state, AggregateInputData &aggr_input_data) {
127
+ if (state.is_set && !state.is_null && !state.value.IsInlined()) {
128
+ delete[] state.value.GetData();
130
129
  }
131
130
  }
132
131
  };
@@ -138,14 +137,14 @@ struct FirstStateVector {
138
137
  template <bool LAST, bool SKIP_NULLS>
139
138
  struct FirstVectorFunction {
140
139
  template <class STATE>
141
- static void Initialize(STATE *state) {
142
- state->value = nullptr;
140
+ static void Initialize(STATE &state) {
141
+ state.value = nullptr;
143
142
  }
144
143
 
145
144
  template <class STATE>
146
- static void Destroy(AggregateInputData &aggr_input_data, STATE *state) {
147
- if (state->value) {
148
- delete state->value;
145
+ static void Destroy(STATE &state, AggregateInputData &aggr_input_data) {
146
+ if (state.value) {
147
+ delete state.value;
149
148
  }
150
149
  }
151
150
  static bool IgnoreNull() {
@@ -153,14 +152,14 @@ struct FirstVectorFunction {
153
152
  }
154
153
 
155
154
  template <class STATE>
156
- static void SetValue(STATE *state, Vector &input, const idx_t idx) {
157
- if (!state->value) {
158
- state->value = new Vector(input.GetType());
159
- state->value->SetVectorType(VectorType::CONSTANT_VECTOR);
155
+ static void SetValue(STATE &state, Vector &input, const idx_t idx) {
156
+ if (!state.value) {
157
+ state.value = new Vector(input.GetType());
158
+ state.value->SetVectorType(VectorType::CONSTANT_VECTOR);
160
159
  }
161
160
  sel_t selv = idx;
162
161
  SelectionVector sel(&selv);
163
- VectorOperations::Copy(input, *state->value, sel, 1, 0, 0);
162
+ VectorOperations::Copy(input, *state.value, sel, 1, 0, 0);
164
163
  }
165
164
 
166
165
  static void Update(Vector inputs[], AggregateInputData &, idx_t input_count, Vector &state_vector, idx_t count) {
@@ -171,39 +170,32 @@ struct FirstVectorFunction {
171
170
  UnifiedVectorFormat sdata;
172
171
  state_vector.ToUnifiedFormat(count, sdata);
173
172
 
174
- auto states = (FirstStateVector **)sdata.data;
173
+ auto states = UnifiedVectorFormat::GetData<FirstStateVector *>(sdata);
175
174
  for (idx_t i = 0; i < count; i++) {
176
175
  const auto idx = idata.sel->get_index(i);
177
176
  if (SKIP_NULLS && !idata.validity.RowIsValid(idx)) {
178
177
  continue;
179
178
  }
180
- auto state = states[sdata.sel->get_index(i)];
181
- if (LAST || !state->value) {
179
+ auto &state = *states[sdata.sel->get_index(i)];
180
+ if (LAST || !state.value) {
182
181
  SetValue(state, input, i);
183
182
  }
184
183
  }
185
184
  }
186
185
 
187
186
  template <class STATE, class OP>
188
- static void Combine(const STATE &source, STATE *target, AggregateInputData &) {
189
- if (source.value && (LAST || !target->value)) {
187
+ static void Combine(const STATE &source, STATE &target, AggregateInputData &) {
188
+ if (source.value && (LAST || !target.value)) {
190
189
  SetValue(target, *source.value, 0);
191
190
  }
192
191
  }
193
192
 
194
- template <class T, class STATE>
195
- static void Finalize(Vector &result, AggregateInputData &, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
196
- if (!state->value) {
197
- // we need to use FlatVector::SetNull here
198
- // since for STRUCT columns only setting the validity mask of the struct is incorrect
199
- // as for a struct column, we need to also set ALL child columns to NULL
200
- if (result.GetVectorType() == VectorType::CONSTANT_VECTOR) {
201
- ConstantVector::SetNull(result, true);
202
- } else {
203
- FlatVector::SetNull(result, idx, true);
204
- }
193
+ template <class STATE>
194
+ static void Finalize(STATE &state, AggregateFinalizeData &finalize_data) {
195
+ if (!state.value) {
196
+ finalize_data.ReturnNull();
205
197
  } else {
206
- VectorOperations::Copy(*state->value, result, 1, 0, idx);
198
+ VectorOperations::Copy(*state.value, finalize_data.result, 1, 0, finalize_data.result_idx);
207
199
  }
208
200
  }
209
201
 
@@ -289,7 +281,7 @@ static AggregateFunction GetFirstFunction(const LogicalType &type) {
289
281
  return AggregateFunction({type}, type, AggregateFunction::StateSize<FirstStateVector>,
290
282
  AggregateFunction::StateInitialize<FirstStateVector, OP>, OP::Update,
291
283
  AggregateFunction::StateCombine<FirstStateVector, OP>,
292
- AggregateFunction::StateFinalize<FirstStateVector, void, OP>, nullptr, OP::Bind,
284
+ AggregateFunction::StateVoidFinalize<FirstStateVector, OP>, nullptr, OP::Bind,
293
285
  AggregateFunction::StateDestroy<FirstStateVector, OP>, nullptr, nullptr);
294
286
  }
295
287
  }