duckdb 0.10.1-dev9.0 → 0.10.2-dev0.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 (702) hide show
  1. package/.github/workflows/NodeJS.yml +9 -16
  2. package/binding.gyp +4 -1
  3. package/package.json +1 -1
  4. package/src/database.cpp +1 -0
  5. package/src/duckdb/extension/icu/icu-strptime.cpp +46 -4
  6. package/src/duckdb/extension/icu/icu-table-range.cpp +5 -0
  7. package/src/duckdb/extension/icu/icu-timezone.cpp +28 -4
  8. package/src/duckdb/extension/json/buffered_json_reader.cpp +6 -5
  9. package/src/duckdb/extension/json/include/buffered_json_reader.hpp +3 -3
  10. package/src/duckdb/extension/json/include/json_transform.hpp +2 -0
  11. package/src/duckdb/extension/json/json_functions/json_create.cpp +6 -0
  12. package/src/duckdb/extension/json/json_functions/json_transform.cpp +8 -9
  13. package/src/duckdb/extension/json/json_functions.cpp +1 -2
  14. package/src/duckdb/extension/json/json_scan.cpp +1 -0
  15. package/src/duckdb/extension/parquet/column_reader.cpp +17 -1
  16. package/src/duckdb/extension/parquet/column_writer.cpp +151 -20
  17. package/src/duckdb/extension/parquet/include/column_writer.hpp +3 -4
  18. package/src/duckdb/extension/parquet/parquet_extension.cpp +14 -9
  19. package/src/duckdb/extension/parquet/parquet_timestamp.cpp +10 -0
  20. package/src/duckdb/extension/parquet/parquet_writer.cpp +4 -0
  21. package/src/duckdb/src/catalog/catalog.cpp +94 -10
  22. package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +9 -5
  23. package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +1 -0
  24. package/src/duckdb/src/catalog/catalog_entry/ub_duckdb_catalog_entries.cpp +16 -0
  25. package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +28 -0
  26. package/src/duckdb/src/catalog/default/default_functions.cpp +3 -0
  27. package/src/duckdb/src/catalog/default/default_views.cpp +3 -3
  28. package/src/duckdb/src/catalog/default/ub_duckdb_catalog_default_entries.cpp +5 -0
  29. package/src/duckdb/src/catalog/dependency_catalog_set.cpp +1 -3
  30. package/src/duckdb/src/catalog/dependency_manager.cpp +2 -5
  31. package/src/duckdb/src/catalog/ub_duckdb_catalog.cpp +10 -0
  32. package/src/duckdb/src/common/adbc/adbc.cpp +1 -1
  33. package/src/duckdb/src/common/adbc/driver_manager.cpp +2 -1
  34. package/src/duckdb/src/common/adbc/nanoarrow/ub_duckdb_adbc_nanoarrow.cpp +5 -0
  35. package/src/duckdb/src/common/adbc/ub_duckdb_adbc.cpp +3 -0
  36. package/src/duckdb/src/common/allocator.cpp +34 -8
  37. package/src/duckdb/src/common/arrow/appender/fixed_size_list_data.cpp +39 -0
  38. package/src/duckdb/src/common/arrow/appender/ub_duckdb_common_arrow_appender.cpp +6 -0
  39. package/src/duckdb/src/common/arrow/appender/union_data.cpp +2 -1
  40. package/src/duckdb/src/common/arrow/arrow_appender.cpp +5 -5
  41. package/src/duckdb/src/common/arrow/arrow_converter.cpp +17 -0
  42. package/src/duckdb/src/common/arrow/ub_duckdb_common_arrow.cpp +4 -0
  43. package/src/duckdb/src/common/compressed_file_system.cpp +1 -0
  44. package/src/duckdb/src/common/crypto/ub_duckdb_common_crypto.cpp +2 -0
  45. package/src/duckdb/src/common/enum_util.cpp +153 -13
  46. package/src/duckdb/src/common/enums/logical_operator_type.cpp +0 -2
  47. package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -2
  48. package/src/duckdb/src/common/enums/ub_duckdb_common_enums.cpp +12 -0
  49. package/src/duckdb/src/common/exception/conversion_exception.cpp +23 -0
  50. package/src/duckdb/src/common/exception.cpp +7 -14
  51. package/src/duckdb/src/common/extra_type_info.cpp +6 -5
  52. package/src/duckdb/src/common/gzip_file_system.cpp +5 -4
  53. package/src/duckdb/src/common/local_file_system.cpp +85 -10
  54. package/src/duckdb/src/common/operator/cast_operators.cpp +413 -305
  55. package/src/duckdb/src/common/operator/ub_duckdb_common_operators.cpp +4 -0
  56. package/src/duckdb/src/common/progress_bar/ub_duckdb_progress_bar.cpp +3 -0
  57. package/src/duckdb/src/common/re2_regex.cpp +2 -1
  58. package/src/duckdb/src/common/row_operations/row_heap_scatter.cpp +2 -2
  59. package/src/duckdb/src/common/row_operations/row_matcher.cpp +1 -0
  60. package/src/duckdb/src/common/row_operations/row_scatter.cpp +2 -2
  61. package/src/duckdb/src/common/row_operations/ub_duckdb_row_operations.cpp +9 -0
  62. package/src/duckdb/src/common/serializer/binary_serializer.cpp +3 -3
  63. package/src/duckdb/src/common/serializer/ub_duckdb_common_serializer.cpp +7 -0
  64. package/src/duckdb/src/common/sort/partition_state.cpp +2 -3
  65. package/src/duckdb/src/common/sort/ub_duckdb_sort.cpp +7 -0
  66. package/src/duckdb/src/common/string_util.cpp +3 -3
  67. package/src/duckdb/src/common/types/bit.cpp +7 -6
  68. package/src/duckdb/src/common/types/blob.cpp +20 -9
  69. package/src/duckdb/src/common/types/column/column_data_allocator.cpp +8 -6
  70. package/src/duckdb/src/common/types/column/column_data_collection.cpp +11 -1
  71. package/src/duckdb/src/common/types/column/column_data_collection_segment.cpp +5 -0
  72. package/src/duckdb/src/common/types/column/partitioned_column_data.cpp +1 -1
  73. package/src/duckdb/src/common/types/column/ub_duckdb_common_types_column.cpp +6 -0
  74. package/src/duckdb/src/common/types/data_chunk.cpp +1 -1
  75. package/src/duckdb/src/common/types/date.cpp +1 -1
  76. package/src/duckdb/src/common/types/hugeint.cpp +3 -2
  77. package/src/duckdb/src/common/types/interval.cpp +1 -1
  78. package/src/duckdb/src/common/types/list_segment.cpp +2 -1
  79. package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +3 -9
  80. package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +7 -7
  81. package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +10 -27
  82. package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +168 -88
  83. package/src/duckdb/src/common/types/row/ub_duckdb_common_types_row.cpp +11 -0
  84. package/src/duckdb/src/common/types/selection_vector.cpp +1 -1
  85. package/src/duckdb/src/common/types/string_heap.cpp +5 -1
  86. package/src/duckdb/src/common/types/string_type.cpp +18 -4
  87. package/src/duckdb/src/common/types/time.cpp +4 -2
  88. package/src/duckdb/src/common/types/timestamp.cpp +32 -6
  89. package/src/duckdb/src/common/types/ub_duckdb_common_types.cpp +28 -0
  90. package/src/duckdb/src/common/types/uhugeint.cpp +3 -2
  91. package/src/duckdb/src/common/types/uuid.cpp +11 -0
  92. package/src/duckdb/src/common/types/validity_mask.cpp +4 -3
  93. package/src/duckdb/src/common/types/value.cpp +17 -6
  94. package/src/duckdb/src/common/types/vector.cpp +243 -68
  95. package/src/duckdb/src/common/types.cpp +7 -5
  96. package/src/duckdb/src/common/ub_duckdb_common.cpp +34 -0
  97. package/src/duckdb/src/common/value_operations/ub_duckdb_value_operations.cpp +2 -0
  98. package/src/duckdb/src/common/vector_operations/generators.cpp +2 -1
  99. package/src/duckdb/src/common/vector_operations/vector_cast.cpp +4 -4
  100. package/src/duckdb/src/common/vector_operations/vector_copy.cpp +2 -2
  101. package/src/duckdb/src/common/vector_operations/vector_hash.cpp +17 -6
  102. package/src/duckdb/src/core_functions/aggregate/algebraic/ub_duckdb_aggr_algebraic.cpp +5 -0
  103. package/src/duckdb/src/core_functions/aggregate/distributive/arg_min_max.cpp +30 -6
  104. package/src/duckdb/src/core_functions/aggregate/distributive/bitagg.cpp +1 -1
  105. package/src/duckdb/src/core_functions/aggregate/distributive/bitstring_agg.cpp +12 -5
  106. package/src/duckdb/src/core_functions/aggregate/distributive/minmax.cpp +2 -2
  107. package/src/duckdb/src/core_functions/aggregate/distributive/string_agg.cpp +2 -1
  108. package/src/duckdb/src/core_functions/aggregate/distributive/ub_duckdb_aggr_distributive.cpp +13 -0
  109. package/src/duckdb/src/core_functions/aggregate/holistic/mode.cpp +2 -1
  110. package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +2 -9
  111. package/src/duckdb/src/core_functions/aggregate/holistic/ub_duckdb_aggr_holistic.cpp +5 -0
  112. package/src/duckdb/src/core_functions/aggregate/nested/ub_duckdb_aggr_nested.cpp +3 -0
  113. package/src/duckdb/src/core_functions/aggregate/regression/ub_duckdb_aggr_regr.cpp +8 -0
  114. package/src/duckdb/src/core_functions/function_list.cpp +1 -0
  115. package/src/duckdb/src/core_functions/scalar/bit/bitstring.cpp +2 -2
  116. package/src/duckdb/src/core_functions/scalar/bit/ub_duckdb_func_bit.cpp +2 -0
  117. package/src/duckdb/src/core_functions/scalar/blob/ub_duckdb_func_blob.cpp +3 -0
  118. package/src/duckdb/src/core_functions/scalar/date/date_diff.cpp +8 -0
  119. package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +22 -3
  120. package/src/duckdb/src/core_functions/scalar/date/make_date.cpp +29 -7
  121. package/src/duckdb/src/core_functions/scalar/date/to_interval.cpp +3 -1
  122. package/src/duckdb/src/core_functions/scalar/date/ub_duckdb_func_date.cpp +12 -0
  123. package/src/duckdb/src/core_functions/scalar/debug/ub_duckdb_func_debug.cpp +2 -0
  124. package/src/duckdb/src/core_functions/scalar/enum/ub_duckdb_func_enum.cpp +2 -0
  125. package/src/duckdb/src/core_functions/scalar/generic/ub_duckdb_func_generic.cpp +9 -0
  126. package/src/duckdb/src/core_functions/scalar/list/array_slice.cpp +12 -8
  127. package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +2 -1
  128. package/src/duckdb/src/core_functions/scalar/list/list_reduce.cpp +6 -5
  129. package/src/duckdb/src/core_functions/scalar/list/list_sort.cpp +5 -3
  130. package/src/duckdb/src/core_functions/scalar/list/list_value.cpp +28 -12
  131. package/src/duckdb/src/core_functions/scalar/list/ub_duckdb_func_list.cpp +11 -0
  132. package/src/duckdb/src/core_functions/scalar/map/map.cpp +129 -160
  133. package/src/duckdb/src/core_functions/scalar/map/ub_duckdb_func_map_nested.cpp +8 -0
  134. package/src/duckdb/src/core_functions/scalar/math/numeric.cpp +19 -16
  135. package/src/duckdb/src/core_functions/scalar/math/ub_duckdb_func_math.cpp +1 -0
  136. package/src/duckdb/src/core_functions/scalar/operators/bitwise.cpp +4 -4
  137. package/src/duckdb/src/core_functions/scalar/operators/ub_duckdb_func_ops.cpp +1 -0
  138. package/src/duckdb/src/core_functions/scalar/random/ub_duckdb_func_random.cpp +3 -0
  139. package/src/duckdb/src/core_functions/scalar/string/hex.cpp +2 -1
  140. package/src/duckdb/src/core_functions/scalar/string/pad.cpp +2 -2
  141. package/src/duckdb/src/core_functions/scalar/string/repeat.cpp +1 -1
  142. package/src/duckdb/src/core_functions/scalar/string/replace.cpp +1 -1
  143. package/src/duckdb/src/core_functions/scalar/string/string_split.cpp +2 -1
  144. package/src/duckdb/src/core_functions/scalar/string/translate.cpp +1 -1
  145. package/src/duckdb/src/core_functions/scalar/string/ub_duckdb_func_string.cpp +26 -0
  146. package/src/duckdb/src/core_functions/scalar/struct/ub_duckdb_func_struct.cpp +3 -0
  147. package/src/duckdb/src/core_functions/scalar/union/ub_duckdb_func_union.cpp +4 -0
  148. package/src/duckdb/src/core_functions/ub_duckdb_core_functions.cpp +3 -0
  149. package/src/duckdb/src/execution/adaptive_filter.cpp +1 -1
  150. package/src/duckdb/src/execution/aggregate_hashtable.cpp +1 -1
  151. package/src/duckdb/src/execution/column_binding_resolver.cpp +7 -1
  152. package/src/duckdb/src/execution/expression_executor/execute_case.cpp +2 -2
  153. package/src/duckdb/src/execution/expression_executor/execute_cast.cpp +2 -0
  154. package/src/duckdb/src/execution/expression_executor/execute_function.cpp +2 -2
  155. package/src/duckdb/src/execution/expression_executor/execute_operator.cpp +1 -1
  156. package/src/duckdb/src/execution/expression_executor/ub_duckdb_expression_executor.cpp +11 -0
  157. package/src/duckdb/src/execution/expression_executor.cpp +5 -2
  158. package/src/duckdb/src/execution/index/art/art.cpp +12 -6
  159. package/src/duckdb/src/execution/index/art/art_key.cpp +3 -3
  160. package/src/duckdb/src/execution/index/art/leaf.cpp +2 -2
  161. package/src/duckdb/src/execution/index/art/node16.cpp +2 -2
  162. package/src/duckdb/src/execution/index/art/node256.cpp +3 -3
  163. package/src/duckdb/src/execution/index/art/node48.cpp +5 -5
  164. package/src/duckdb/src/execution/index/art/prefix.cpp +1 -1
  165. package/src/duckdb/src/execution/index/art/ub_duckdb_art_index_execution.cpp +12 -0
  166. package/src/duckdb/src/execution/index/art/ub_duckdb_execution_index_art.cpp +11 -0
  167. package/src/duckdb/src/execution/index/fixed_size_buffer.cpp +6 -5
  168. package/src/duckdb/src/execution/index/ub_duckdb_execution_index.cpp +3 -0
  169. package/src/duckdb/src/execution/nested_loop_join/ub_duckdb_nested_loop_join.cpp +3 -0
  170. package/src/duckdb/src/execution/operator/aggregate/aggregate_object.cpp +1 -1
  171. package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +3 -4
  172. package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +0 -1
  173. package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +3 -4
  174. package/src/duckdb/src/execution/operator/aggregate/ub_duckdb_operator_aggregate.cpp +9 -0
  175. package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_buffer.cpp +1 -1
  176. package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_buffer_manager.cpp +8 -3
  177. package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_file_handle.cpp +1 -1
  178. package/src/duckdb/src/execution/operator/csv_scanner/scanner/base_scanner.cpp +5 -5
  179. package/src/duckdb/src/execution/operator/csv_scanner/scanner/column_count_scanner.cpp +2 -3
  180. package/src/duckdb/src/execution/operator/csv_scanner/scanner/scanner_boundary.cpp +5 -1
  181. package/src/duckdb/src/execution/operator/csv_scanner/scanner/skip_scanner.cpp +2 -2
  182. package/src/duckdb/src/execution/operator/csv_scanner/scanner/string_value_scanner.cpp +151 -79
  183. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp +11 -6
  184. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +27 -6
  185. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/header_detection.cpp +71 -18
  186. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_detection.cpp +22 -11
  187. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_refinement.cpp +6 -4
  188. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_replacement.cpp +5 -3
  189. package/src/duckdb/src/execution/operator/csv_scanner/sniffer/ub_duckdb_operator_csv_sniffer.cpp +7 -0
  190. package/src/duckdb/src/execution/operator/csv_scanner/state_machine/csv_state_machine.cpp +3 -3
  191. package/src/duckdb/src/execution/operator/csv_scanner/state_machine/csv_state_machine_cache.cpp +30 -5
  192. package/src/duckdb/src/execution/operator/csv_scanner/table_function/csv_file_scanner.cpp +6 -2
  193. package/src/duckdb/src/execution/operator/csv_scanner/table_function/global_csv_state.cpp +47 -46
  194. package/src/duckdb/src/execution/operator/csv_scanner/ub_duckdb_operator_csv_scanner.cpp +10 -0
  195. package/src/duckdb/src/execution/operator/csv_scanner/util/csv_error.cpp +102 -54
  196. package/src/duckdb/src/execution/operator/csv_scanner/util/csv_reader_options.cpp +8 -1
  197. package/src/duckdb/src/execution/operator/filter/ub_duckdb_operator_filter.cpp +2 -0
  198. package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +54 -36
  199. package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +56 -32
  200. package/src/duckdb/src/execution/operator/helper/physical_streaming_limit.cpp +9 -13
  201. package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +12 -0
  202. package/src/duckdb/src/execution/operator/helper/physical_verify_vector.cpp +221 -0
  203. package/src/duckdb/src/execution/operator/helper/ub_duckdb_operator_helper.cpp +18 -0
  204. package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +1 -0
  205. package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +23 -8
  206. package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +8 -3
  207. package/src/duckdb/src/execution/operator/join/ub_duckdb_operator_join.cpp +16 -0
  208. package/src/duckdb/src/execution/operator/order/physical_order.cpp +2 -3
  209. package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +2 -7
  210. package/src/duckdb/src/execution/operator/order/ub_duckdb_operator_order.cpp +3 -0
  211. package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +451 -55
  212. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +312 -150
  213. package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +200 -75
  214. package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +1 -0
  215. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +6 -5
  216. package/src/duckdb/src/execution/operator/persistent/ub_duckdb_operator_persistent.cpp +10 -0
  217. package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +3 -2
  218. package/src/duckdb/src/execution/operator/projection/ub_duckdb_operator_projection.cpp +5 -0
  219. package/src/duckdb/src/execution/operator/scan/ub_duckdb_operator_scan.cpp +7 -0
  220. package/src/duckdb/src/execution/operator/schema/ub_duckdb_operator_schema.cpp +12 -0
  221. package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +25 -0
  222. package/src/duckdb/src/execution/operator/set/ub_duckdb_operator_set.cpp +4 -0
  223. package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +4 -4
  224. package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +2 -2
  225. package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +2 -2
  226. package/src/duckdb/src/execution/physical_plan/plan_copy_to_file.cpp +7 -17
  227. package/src/duckdb/src/execution/physical_plan/plan_distinct.cpp +10 -0
  228. package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +7 -0
  229. package/src/duckdb/src/execution/physical_plan/plan_limit.cpp +45 -13
  230. package/src/duckdb/src/execution/physical_plan/ub_duckdb_physical_plan.cpp +44 -0
  231. package/src/duckdb/src/execution/physical_plan_generator.cpp +5 -3
  232. package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +13 -12
  233. package/src/duckdb/src/execution/ub_duckdb_execution.cpp +15 -0
  234. package/src/duckdb/src/execution/window_executor.cpp +71 -61
  235. package/src/duckdb/src/execution/window_segment_tree.cpp +6 -6
  236. package/src/duckdb/src/extension_forward_decl/icu.cpp +59 -0
  237. package/src/duckdb/src/function/aggregate/algebraic/ub_duckdb_aggr_algebraic.cpp +5 -0
  238. package/src/duckdb/src/function/aggregate/distributive/first.cpp +2 -2
  239. package/src/duckdb/src/function/aggregate/distributive/ub_duckdb_aggr_distr.cpp +3 -0
  240. package/src/duckdb/src/function/aggregate/holistic/ub_duckdb_aggr_holistic.cpp +5 -0
  241. package/src/duckdb/src/function/aggregate/nested/ub_duckdb_aggr_nested.cpp +3 -0
  242. package/src/duckdb/src/function/aggregate/regression/ub_duckdb_aggr_regr.cpp +8 -0
  243. package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +3 -2
  244. package/src/duckdb/src/function/aggregate/ub_duckdb_func_aggr.cpp +3 -0
  245. package/src/duckdb/src/function/cast/array_casts.cpp +2 -4
  246. package/src/duckdb/src/function/cast/bit_cast.cpp +13 -13
  247. package/src/duckdb/src/function/cast/cast_function_set.cpp +2 -0
  248. package/src/duckdb/src/function/cast/decimal_cast.cpp +38 -44
  249. package/src/duckdb/src/function/cast/default_casts.cpp +5 -2
  250. package/src/duckdb/src/function/cast/enum_casts.cpp +5 -5
  251. package/src/duckdb/src/function/cast/list_casts.cpp +24 -14
  252. package/src/duckdb/src/function/cast/string_cast.cpp +48 -30
  253. package/src/duckdb/src/function/cast/struct_cast.cpp +2 -2
  254. package/src/duckdb/src/function/cast/time_casts.cpp +12 -0
  255. package/src/duckdb/src/function/cast/ub_duckdb_func_cast.cpp +17 -0
  256. package/src/duckdb/src/function/cast/union/ub_duckdb_union_cast.cpp +2 -0
  257. package/src/duckdb/src/function/cast/union_casts.cpp +13 -15
  258. package/src/duckdb/src/function/cast/vector_cast_helpers.cpp +1 -1
  259. package/src/duckdb/src/function/cast_rules.cpp +2 -1
  260. package/src/duckdb/src/function/pragma/ub_duckdb_func_pragma.cpp +3 -0
  261. package/src/duckdb/src/function/scalar/bit/ub_duckdb_func_bit.cpp +2 -0
  262. package/src/duckdb/src/function/scalar/blob/ub_duckdb_func_blob.cpp +3 -0
  263. package/src/duckdb/src/function/scalar/compressed_materialization/compress_integral.cpp +7 -6
  264. package/src/duckdb/src/function/scalar/compressed_materialization/compress_string.cpp +3 -3
  265. package/src/duckdb/src/function/scalar/compressed_materialization/ub_duckdb_func_compressed_materialization.cpp +3 -0
  266. package/src/duckdb/src/function/scalar/date/ub_duckdb_func_date.cpp +12 -0
  267. package/src/duckdb/src/function/scalar/enum/ub_duckdb_func_enum.cpp +2 -0
  268. package/src/duckdb/src/function/scalar/generic/ub_duckdb_func_generic.cpp +8 -0
  269. package/src/duckdb/src/function/scalar/generic/ub_duckdb_func_generic_main.cpp +2 -0
  270. package/src/duckdb/src/function/scalar/list/list_resize.cpp +3 -1
  271. package/src/duckdb/src/function/scalar/list/list_zip.cpp +3 -4
  272. package/src/duckdb/src/function/scalar/list/ub_duckdb_func_list.cpp +11 -0
  273. package/src/duckdb/src/function/scalar/list/ub_duckdb_func_list_nested.cpp +5 -0
  274. package/src/duckdb/src/function/scalar/map/ub_duckdb_func_map_nested.cpp +7 -0
  275. package/src/duckdb/src/function/scalar/math/ub_duckdb_func_math.cpp +4 -0
  276. package/src/duckdb/src/function/scalar/nested_functions.cpp +7 -3
  277. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +1 -1
  278. package/src/duckdb/src/function/scalar/operators/multiply.cpp +4 -2
  279. package/src/duckdb/src/function/scalar/operators/subtract.cpp +9 -3
  280. package/src/duckdb/src/function/scalar/operators/ub_duckdb_func_ops.cpp +6 -0
  281. package/src/duckdb/src/function/scalar/operators/ub_duckdb_func_ops_main.cpp +5 -0
  282. package/src/duckdb/src/function/scalar/sequence/ub_duckdb_func_seq.cpp +2 -0
  283. package/src/duckdb/src/function/scalar/strftime_format.cpp +21 -20
  284. package/src/duckdb/src/function/scalar/string/like.cpp +14 -3
  285. package/src/duckdb/src/function/scalar/string/regexp/regexp_extract_all.cpp +4 -2
  286. package/src/duckdb/src/function/scalar/string/regexp/ub_duckdb_func_string_regexp.cpp +3 -0
  287. package/src/duckdb/src/function/scalar/string/regexp.cpp +6 -4
  288. package/src/duckdb/src/function/scalar/string/suffix.cpp +1 -1
  289. package/src/duckdb/src/function/scalar/string/ub_duckdb_func_string.cpp +31 -0
  290. package/src/duckdb/src/function/scalar/string/ub_duckdb_func_string_main.cpp +12 -0
  291. package/src/duckdb/src/function/scalar/struct/ub_duckdb_func_struct.cpp +4 -0
  292. package/src/duckdb/src/function/scalar/struct/ub_duckdb_func_struct_main.cpp +2 -0
  293. package/src/duckdb/src/function/scalar/system/ub_duckdb_func_system.cpp +2 -0
  294. package/src/duckdb/src/function/scalar/ub_duckdb_func_scalar.cpp +9 -0
  295. package/src/duckdb/src/function/scalar/union/ub_duckdb_func_union.cpp +4 -0
  296. package/src/duckdb/src/function/table/arrow/arrow_array_scan_state.cpp +28 -2
  297. package/src/duckdb/src/function/table/arrow/ub_duckdb_arrow_conversion.cpp +2 -0
  298. package/src/duckdb/src/function/table/arrow.cpp +23 -6
  299. package/src/duckdb/src/function/table/arrow_conversion.cpp +75 -33
  300. package/src/duckdb/src/function/table/copy_csv.cpp +8 -3
  301. package/src/duckdb/src/function/table/range.cpp +5 -0
  302. package/src/duckdb/src/function/table/read_csv.cpp +9 -8
  303. package/src/duckdb/src/function/table/read_file.cpp +1 -1
  304. package/src/duckdb/src/function/table/sniff_csv.cpp +5 -5
  305. package/src/duckdb/src/function/table/system/duckdb_columns.cpp +6 -2
  306. package/src/duckdb/src/function/table/system/duckdb_secrets.cpp +5 -1
  307. package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +3 -1
  308. package/src/duckdb/src/function/table/system/duckdb_settings.cpp +13 -1
  309. package/src/duckdb/src/function/table/system/test_all_types.cpp +64 -0
  310. package/src/duckdb/src/function/table/system/ub_duckdb_table_func_system.cpp +23 -0
  311. package/src/duckdb/src/function/table/ub_duckdb_func_table.cpp +16 -0
  312. package/src/duckdb/src/function/table/version/pragma_version.cpp +11 -2
  313. package/src/duckdb/src/function/table/version/ub_duckdb_func_table_version.cpp +2 -0
  314. package/src/duckdb/src/function/ub_duckdb_function.cpp +14 -0
  315. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +11 -1
  316. package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +2 -0
  317. package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +1 -1
  318. package/src/duckdb/src/include/duckdb/common/allocator.hpp +8 -11
  319. package/src/duckdb/src/include/duckdb/common/arrow/appender/enum_data.hpp +2 -2
  320. package/src/duckdb/src/include/duckdb/common/arrow/appender/fixed_size_list_data.hpp +14 -0
  321. package/src/duckdb/src/include/duckdb/common/arrow/appender/list.hpp +1 -0
  322. package/src/duckdb/src/include/duckdb/common/arrow/appender/list_data.hpp +1 -1
  323. package/src/duckdb/src/include/duckdb/common/arrow/appender/varchar_data.hpp +2 -2
  324. package/src/duckdb/src/include/duckdb/common/bitpacking.hpp +2 -2
  325. package/src/duckdb/src/include/duckdb/common/bswap.hpp +6 -2
  326. package/src/duckdb/src/include/duckdb/common/enum_util.hpp +32 -0
  327. package/src/duckdb/src/include/duckdb/common/enums/catalog_lookup_behavior.hpp +21 -0
  328. package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +0 -1
  329. package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -1
  330. package/src/duckdb/src/include/duckdb/common/enums/prepared_statement_mode.hpp +20 -0
  331. package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +2 -0
  332. package/src/duckdb/src/include/duckdb/common/exception/conversion_exception.hpp +6 -0
  333. package/src/duckdb/src/include/duckdb/common/exception/parser_exception.hpp +4 -0
  334. package/src/duckdb/src/include/duckdb/common/exception.hpp +2 -0
  335. package/src/duckdb/src/include/duckdb/common/extra_type_info.hpp +3 -3
  336. package/src/duckdb/src/include/duckdb/common/file_opener.hpp +6 -5
  337. package/src/duckdb/src/include/duckdb/common/file_system.hpp +4 -2
  338. package/src/duckdb/src/include/duckdb/common/helper.hpp +7 -0
  339. package/src/duckdb/src/include/duckdb/common/limits.hpp +2 -2
  340. package/src/duckdb/src/include/duckdb/common/local_file_system.hpp +3 -0
  341. package/src/duckdb/src/include/duckdb/common/numeric_utils.hpp +64 -0
  342. package/src/duckdb/src/include/duckdb/common/operator/cast_operators.hpp +34 -33
  343. package/src/duckdb/src/include/duckdb/common/operator/decimal_cast_operators.hpp +150 -124
  344. package/src/duckdb/src/include/duckdb/common/operator/integer_cast_operator.hpp +5 -5
  345. package/src/duckdb/src/include/duckdb/common/radix.hpp +1 -1
  346. package/src/duckdb/src/include/duckdb/common/serializer/deserializer.hpp +1 -1
  347. package/src/duckdb/src/include/duckdb/common/sort/duckdb_pdqsort.hpp +4 -4
  348. package/src/duckdb/src/include/duckdb/common/types/bit.hpp +1 -1
  349. package/src/duckdb/src/include/duckdb/common/types/blob.hpp +4 -1
  350. package/src/duckdb/src/include/duckdb/common/types/cast_helpers.hpp +15 -13
  351. package/src/duckdb/src/include/duckdb/common/types/column/column_data_allocator.hpp +5 -0
  352. package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection.hpp +2 -0
  353. package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection_segment.hpp +3 -0
  354. package/src/duckdb/src/include/duckdb/common/types/column/partitioned_column_data.hpp +1 -1
  355. package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +1 -1
  356. package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_states.hpp +4 -1
  357. package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +2 -1
  358. package/src/duckdb/src/include/duckdb/common/types/string_heap.hpp +2 -0
  359. package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +11 -4
  360. package/src/duckdb/src/include/duckdb/common/types/time.hpp +1 -1
  361. package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +7 -2
  362. package/src/duckdb/src/include/duckdb/common/types/uuid.hpp +3 -0
  363. package/src/duckdb/src/include/duckdb/common/types/value.hpp +7 -0
  364. package/src/duckdb/src/include/duckdb/common/types/vector.hpp +40 -7
  365. package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +1 -1
  366. package/src/duckdb/src/include/duckdb/common/types.hpp +1 -1
  367. package/src/duckdb/src/include/duckdb/common/vector_operations/general_cast.hpp +12 -4
  368. package/src/duckdb/src/include/duckdb/common/vector_operations/generic_executor.hpp +6 -6
  369. package/src/duckdb/src/include/duckdb/common/vector_operations/vector_operations.hpp +3 -2
  370. package/src/duckdb/src/include/duckdb/common/windows_undefs.hpp +4 -0
  371. package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_count.hpp +1 -1
  372. package/src/duckdb/src/include/duckdb/core_functions/scalar/list_functions.hpp +9 -0
  373. package/src/duckdb/src/include/duckdb/execution/column_binding_resolver.hpp +2 -1
  374. package/src/duckdb/src/include/duckdb/execution/executor.hpp +10 -0
  375. package/src/duckdb/src/include/duckdb/execution/expression_executor_state.hpp +1 -1
  376. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/base_scanner.hpp +262 -0
  377. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/column_count_scanner.hpp +70 -0
  378. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_buffer.hpp +103 -0
  379. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_buffer_manager.hpp +74 -0
  380. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_casting.hpp +154 -0
  381. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_error.hpp +130 -0
  382. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_file_handle.hpp +60 -0
  383. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_file_scanner.hpp +70 -0
  384. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_option.hpp +155 -0
  385. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_reader_options.hpp +166 -0
  386. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_sniffer.hpp +191 -0
  387. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state.hpp +30 -0
  388. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine.hpp +99 -0
  389. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine_cache.hpp +91 -0
  390. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/global_csv_state.hpp +80 -0
  391. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/quote_rules.hpp +21 -0
  392. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/scanner_boundary.hpp +93 -0
  393. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/skip_scanner.hpp +60 -0
  394. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/state_machine_options.hpp +35 -0
  395. package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/string_value_scanner.hpp +200 -0
  396. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +13 -10
  397. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit_percent.hpp +5 -11
  398. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_streaming_limit.hpp +4 -6
  399. package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_verify_vector.hpp +51 -0
  400. package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +3 -0
  401. package/src/duckdb/src/include/duckdb/execution/operator/persistent/batch_memory_manager.hpp +165 -0
  402. package/src/duckdb/src/include/duckdb/execution/operator/persistent/batch_task_manager.hpp +48 -0
  403. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_copy_to_file.hpp +10 -17
  404. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +4 -0
  405. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +2 -0
  406. package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +10 -6
  407. package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +0 -2
  408. package/src/duckdb/src/include/duckdb/execution/window_executor.hpp +2 -1
  409. package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +1 -1
  410. package/src/duckdb/src/include/duckdb/function/cast/cast_function_set.hpp +1 -0
  411. package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +14 -5
  412. package/src/duckdb/src/include/duckdb/function/cast/vector_cast_helpers.hpp +27 -43
  413. package/src/duckdb/src/include/duckdb/function/compression_function.hpp +4 -4
  414. package/src/duckdb/src/include/duckdb/function/copy_function.hpp +3 -3
  415. package/src/duckdb/src/include/duckdb/function/function.hpp +1 -1
  416. package/src/duckdb/src/include/duckdb/function/scalar/list/contains_or_position.hpp +1 -0
  417. package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -1
  418. package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +1 -1
  419. package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +10 -4
  420. package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +8 -6
  421. package/src/duckdb/src/include/duckdb/function/table_function.hpp +3 -3
  422. package/src/duckdb/src/include/duckdb/main/attached_database.hpp +3 -0
  423. package/src/duckdb/src/include/duckdb/main/capi/cast/from_decimal.hpp +6 -4
  424. package/src/duckdb/src/include/duckdb/main/capi/cast/to_decimal.hpp +17 -10
  425. package/src/duckdb/src/include/duckdb/main/client_config.hpp +2 -0
  426. package/src/duckdb/src/include/duckdb/main/client_context.hpp +17 -3
  427. package/src/duckdb/src/include/duckdb/main/client_context_file_opener.hpp +2 -2
  428. package/src/duckdb/src/include/duckdb/main/client_context_state.hpp +20 -0
  429. package/src/duckdb/src/include/duckdb/main/client_data.hpp +1 -1
  430. package/src/duckdb/src/include/duckdb/main/database.hpp +3 -2
  431. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +2 -1
  432. package/src/duckdb/src/include/duckdb/main/extension/generated_extension_loader.hpp +1 -1
  433. package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +230 -199
  434. package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +18 -0
  435. package/src/duckdb/src/include/duckdb/main/relation/read_csv_relation.hpp +1 -1
  436. package/src/duckdb/src/include/duckdb/main/relation/table_function_relation.hpp +2 -0
  437. package/src/duckdb/src/include/duckdb/main/relation.hpp +1 -1
  438. package/src/duckdb/src/include/duckdb/main/secret/secret_manager.hpp +4 -0
  439. package/src/duckdb/src/include/duckdb/main/settings.hpp +54 -10
  440. package/src/duckdb/src/include/duckdb/optimizer/join_order/relation_manager.hpp +2 -1
  441. package/src/duckdb/src/include/duckdb/optimizer/rule/ordered_aggregate_optimizer.hpp +2 -0
  442. package/src/duckdb/src/include/duckdb/parallel/concurrentqueue.hpp +21 -5
  443. package/src/duckdb/src/include/duckdb/parallel/event.hpp +1 -1
  444. package/src/duckdb/src/include/duckdb/parallel/executor_task.hpp +37 -0
  445. package/src/duckdb/src/include/duckdb/parallel/interrupt.hpp +1 -1
  446. package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +1 -1
  447. package/src/duckdb/src/include/duckdb/parallel/task.hpp +0 -20
  448. package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +4 -2
  449. package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +10 -0
  450. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +2 -1
  451. package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +0 -24
  452. package/src/duckdb/src/include/duckdb/parser/parsed_data/comment_on_column_info.hpp +46 -0
  453. package/src/duckdb/src/include/duckdb/parser/parsed_data/create_view_info.hpp +2 -0
  454. package/src/duckdb/src/include/duckdb/parser/parsed_data/extra_drop_info.hpp +1 -1
  455. package/src/duckdb/src/include/duckdb/parser/parsed_data/parse_info.hpp +3 -2
  456. package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +3 -3
  457. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +3 -3
  458. package/src/duckdb/src/include/duckdb/planner/binder.hpp +11 -4
  459. package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +59 -23
  460. package/src/duckdb/src/include/duckdb/planner/expression.hpp +1 -0
  461. package/src/duckdb/src/include/duckdb/planner/expression_binder/column_alias_binder.hpp +2 -2
  462. package/src/duckdb/src/include/duckdb/planner/expression_iterator.hpp +11 -3
  463. package/src/duckdb/src/include/duckdb/planner/extension_callback.hpp +6 -0
  464. package/src/duckdb/src/include/duckdb/planner/operator/list.hpp +0 -1
  465. package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +1 -1
  466. package/src/duckdb/src/include/duckdb/planner/operator/logical_limit.hpp +5 -9
  467. package/src/duckdb/src/include/duckdb/planner/subquery/rewrite_correlated_expressions.hpp +0 -15
  468. package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +5 -0
  469. package/src/duckdb/src/include/duckdb/storage/buffer/buffer_pool.hpp +40 -5
  470. package/src/duckdb/src/include/duckdb/storage/compression/alp/algorithm/alp.hpp +1 -1
  471. package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_analyze.hpp +5 -1
  472. package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_compress.hpp +4 -4
  473. package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_utils.hpp +2 -1
  474. package/src/duckdb/src/include/duckdb/storage/compression/alprd/algorithm/alprd.hpp +10 -8
  475. package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_analyze.hpp +5 -1
  476. package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_compress.hpp +3 -3
  477. package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/bit_reader.hpp +11 -10
  478. package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/bit_utils.hpp +3 -1
  479. package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/chimp128.hpp +1 -1
  480. package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/leading_zero_buffer.hpp +5 -3
  481. package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_scan.hpp +2 -1
  482. package/src/duckdb/src/include/duckdb/storage/data_pointer.hpp +1 -1
  483. package/src/duckdb/src/include/duckdb/storage/data_table.hpp +3 -1
  484. package/src/duckdb/src/include/duckdb/storage/index.hpp +1 -1
  485. package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +1 -1
  486. package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +3 -0
  487. package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +1 -1
  488. package/src/duckdb/src/include/duckdb/storage/table/append_state.hpp +0 -2
  489. package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +1 -1
  490. package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +5 -3
  491. package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +2 -2
  492. package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +5 -0
  493. package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +9 -2
  494. package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +2 -6
  495. package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +3 -3
  496. package/src/duckdb/src/include/duckdb/storage/temporary_file_manager.hpp +169 -0
  497. package/src/duckdb/src/include/duckdb/transaction/duck_transaction_manager.hpp +11 -1
  498. package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +6 -1
  499. package/src/duckdb/src/include/duckdb/transaction/transaction.hpp +1 -1
  500. package/src/duckdb/src/include/duckdb.h +119 -67
  501. package/src/duckdb/src/main/appender.cpp +2 -1
  502. package/src/duckdb/src/main/attached_database.cpp +49 -27
  503. package/src/duckdb/src/main/capi/appender-c.cpp +1 -1
  504. package/src/duckdb/src/main/capi/cast/ub_duckdb_main_capi_cast.cpp +3 -0
  505. package/src/duckdb/src/main/capi/cast/utils-c.cpp +1 -1
  506. package/src/duckdb/src/main/capi/data_chunk-c.cpp +9 -1
  507. package/src/duckdb/src/main/capi/datetime-c.cpp +14 -8
  508. package/src/duckdb/src/main/capi/duckdb_value-c.cpp +29 -2
  509. package/src/duckdb/src/main/capi/helper-c.cpp +2 -0
  510. package/src/duckdb/src/main/capi/hugeint-c.cpp +2 -1
  511. package/src/duckdb/src/main/capi/logical_types-c.cpp +35 -1
  512. package/src/duckdb/src/main/capi/result-c.cpp +9 -0
  513. package/src/duckdb/src/main/capi/ub_duckdb_main_capi.cpp +19 -0
  514. package/src/duckdb/src/main/chunk_scan_state/ub_duckdb_main_chunk_scan_state.cpp +2 -0
  515. package/src/duckdb/src/main/client_context.cpp +133 -33
  516. package/src/duckdb/src/main/client_context_file_opener.cpp +8 -7
  517. package/src/duckdb/src/main/config.cpp +2 -0
  518. package/src/duckdb/src/main/connection_manager.cpp +8 -0
  519. package/src/duckdb/src/main/database.cpp +13 -4
  520. package/src/duckdb/src/main/database_manager.cpp +10 -1
  521. package/src/duckdb/src/main/extension/extension_helper.cpp +8 -5
  522. package/src/duckdb/src/main/extension/extension_install.cpp +1 -1
  523. package/src/duckdb/src/main/extension/ub_duckdb_main_extension.cpp +6 -0
  524. package/src/duckdb/src/main/prepared_statement_data.cpp +23 -6
  525. package/src/duckdb/src/main/query_profiler.cpp +9 -7
  526. package/src/duckdb/src/main/relation/read_csv_relation.cpp +17 -12
  527. package/src/duckdb/src/main/relation/ub_duckdb_main_relation.cpp +26 -0
  528. package/src/duckdb/src/main/relation/value_relation.cpp +2 -0
  529. package/src/duckdb/src/main/secret/secret.cpp +1 -1
  530. package/src/duckdb/src/main/secret/secret_manager.cpp +41 -8
  531. package/src/duckdb/src/main/secret/secret_storage.cpp +8 -2
  532. package/src/duckdb/src/main/settings/settings.cpp +42 -2
  533. package/src/duckdb/src/main/settings/ub_duckdb_main_settings.cpp +2 -0
  534. package/src/duckdb/src/main/ub_duckdb_main.cpp +25 -0
  535. package/src/duckdb/src/optimizer/compressed_materialization/ub_duckdb_optimizer_compressed_materialization.cpp +4 -0
  536. package/src/duckdb/src/optimizer/filter_combiner.cpp +20 -14
  537. package/src/duckdb/src/optimizer/in_clause_rewriter.cpp +5 -1
  538. package/src/duckdb/src/optimizer/join_order/relation_manager.cpp +23 -11
  539. package/src/duckdb/src/optimizer/join_order/ub_duckdb_optimizer_join_order.cpp +12 -0
  540. package/src/duckdb/src/optimizer/matcher/ub_duckdb_optimizer_matcher.cpp +2 -0
  541. package/src/duckdb/src/optimizer/pullup/ub_duckdb_optimizer_pullup.cpp +6 -0
  542. package/src/duckdb/src/optimizer/pushdown/pushdown_limit.cpp +1 -1
  543. package/src/duckdb/src/optimizer/pushdown/ub_duckdb_optimizer_pushdown.cpp +12 -0
  544. package/src/duckdb/src/optimizer/remove_unused_columns.cpp +7 -6
  545. package/src/duckdb/src/optimizer/rule/ordered_aggregate_optimizer.cpp +8 -6
  546. package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +1 -1
  547. package/src/duckdb/src/optimizer/rule/ub_duckdb_optimizer_rules.cpp +16 -0
  548. package/src/duckdb/src/optimizer/statistics/expression/propagate_cast.cpp +71 -1
  549. package/src/duckdb/src/optimizer/statistics/expression/ub_duckdb_optimizer_statistics_expr.cpp +11 -0
  550. package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +1 -1
  551. package/src/duckdb/src/optimizer/statistics/operator/propagate_limit.cpp +5 -1
  552. package/src/duckdb/src/optimizer/statistics/operator/ub_duckdb_optimizer_statistics_op.cpp +11 -0
  553. package/src/duckdb/src/optimizer/topn_optimizer.cpp +12 -11
  554. package/src/duckdb/src/optimizer/ub_duckdb_optimizer.cpp +20 -0
  555. package/src/duckdb/src/parallel/executor.cpp +8 -19
  556. package/src/duckdb/src/parallel/executor_task.cpp +6 -2
  557. package/src/duckdb/src/parallel/pipeline.cpp +12 -6
  558. package/src/duckdb/src/parallel/pipeline_executor.cpp +1 -1
  559. package/src/duckdb/src/parallel/pipeline_finish_event.cpp +2 -2
  560. package/src/duckdb/src/parallel/pipeline_initialize_event.cpp +1 -2
  561. package/src/duckdb/src/parallel/task_scheduler.cpp +15 -8
  562. package/src/duckdb/src/parallel/ub_duckdb_parallel.cpp +15 -0
  563. package/src/duckdb/src/parser/constraints/ub_duckdb_constraints.cpp +5 -0
  564. package/src/duckdb/src/parser/expression/ub_duckdb_expression.cpp +18 -0
  565. package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +0 -18
  566. package/src/duckdb/src/parser/parsed_data/comment_on_column_info.cpp +44 -0
  567. package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +1 -0
  568. package/src/duckdb/src/parser/parsed_data/extra_drop_info.cpp +2 -0
  569. package/src/duckdb/src/parser/parsed_data/ub_duckdb_parsed_data.cpp +24 -0
  570. package/src/duckdb/src/parser/parser.cpp +1 -1
  571. package/src/duckdb/src/parser/query_error_context.cpp +15 -1
  572. package/src/duckdb/src/parser/query_node/ub_duckdb_query_node.cpp +5 -0
  573. package/src/duckdb/src/parser/statement/export_statement.cpp +2 -1
  574. package/src/duckdb/src/parser/statement/relation_statement.cpp +2 -2
  575. package/src/duckdb/src/parser/statement/ub_duckdb_statement.cpp +25 -0
  576. package/src/duckdb/src/parser/tableref/pivotref.cpp +3 -3
  577. package/src/duckdb/src/parser/tableref/showref.cpp +2 -0
  578. package/src/duckdb/src/parser/tableref/ub_duckdb_parser_tableref.cpp +8 -0
  579. package/src/duckdb/src/parser/transform/constraint/ub_duckdb_transformer_constraint.cpp +2 -0
  580. package/src/duckdb/src/parser/transform/expression/transform_boolean_test.cpp +1 -1
  581. package/src/duckdb/src/parser/transform/expression/transform_cast.cpp +10 -2
  582. package/src/duckdb/src/parser/transform/expression/transform_constant.cpp +7 -7
  583. package/src/duckdb/src/parser/transform/expression/transform_interval.cpp +2 -1
  584. package/src/duckdb/src/parser/transform/expression/ub_duckdb_transformer_expression.cpp +20 -0
  585. package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +2 -2
  586. package/src/duckdb/src/parser/transform/helpers/ub_duckdb_transformer_helpers.cpp +8 -0
  587. package/src/duckdb/src/parser/transform/statement/transform_comment_on.cpp +3 -8
  588. package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +3 -1
  589. package/src/duckdb/src/parser/transform/statement/transform_show_select.cpp +2 -3
  590. package/src/duckdb/src/parser/transform/statement/ub_duckdb_transformer_statement.cpp +37 -0
  591. package/src/duckdb/src/parser/transform/tableref/transform_join.cpp +16 -0
  592. package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +49 -32
  593. package/src/duckdb/src/parser/transform/tableref/ub_duckdb_transformer_tableref.cpp +8 -0
  594. package/src/duckdb/src/parser/ub_duckdb_parser.cpp +15 -0
  595. package/src/duckdb/src/planner/binder/expression/bind_lambda.cpp +11 -4
  596. package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +4 -1
  597. package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +71 -5
  598. package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +35 -1
  599. package/src/duckdb/src/planner/binder/expression/ub_duckdb_bind_expression.cpp +20 -0
  600. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +55 -51
  601. package/src/duckdb/src/planner/binder/query_node/plan_query_node.cpp +1 -11
  602. package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +2 -2
  603. package/src/duckdb/src/planner/binder/query_node/ub_duckdb_bind_query_node.cpp +12 -0
  604. package/src/duckdb/src/planner/binder/statement/bind_create.cpp +12 -6
  605. package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +1 -1
  606. package/src/duckdb/src/planner/binder/statement/bind_export.cpp +8 -2
  607. package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +6 -3
  608. package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +13 -2
  609. package/src/duckdb/src/planner/binder/statement/ub_duckdb_bind_statement.cpp +26 -0
  610. package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +15 -4
  611. package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +9 -2
  612. package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +93 -45
  613. package/src/duckdb/src/planner/binder/tableref/bind_subqueryref.cpp +6 -1
  614. package/src/duckdb/src/planner/binder/tableref/ub_duckdb_bind_tableref.cpp +17 -0
  615. package/src/duckdb/src/planner/binder.cpp +22 -23
  616. package/src/duckdb/src/planner/bound_result_modifier.cpp +67 -4
  617. package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +5 -1
  618. package/src/duckdb/src/planner/expression/bound_window_expression.cpp +3 -0
  619. package/src/duckdb/src/planner/expression/ub_duckdb_planner_expression.cpp +19 -0
  620. package/src/duckdb/src/planner/expression_binder/column_alias_binder.cpp +14 -9
  621. package/src/duckdb/src/planner/expression_binder/having_binder.cpp +17 -9
  622. package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +61 -37
  623. package/src/duckdb/src/planner/expression_binder/qualify_binder.cpp +8 -4
  624. package/src/duckdb/src/planner/expression_binder/ub_duckdb_expression_binders.cpp +20 -0
  625. package/src/duckdb/src/planner/expression_binder/where_binder.cpp +3 -2
  626. package/src/duckdb/src/planner/expression_iterator.cpp +73 -52
  627. package/src/duckdb/src/planner/filter/ub_duckdb_planner_filter.cpp +4 -0
  628. package/src/duckdb/src/planner/logical_operator_visitor.cpp +4 -14
  629. package/src/duckdb/src/planner/operator/logical_limit.cpp +14 -6
  630. package/src/duckdb/src/planner/operator/ub_duckdb_planner_operator.cpp +43 -0
  631. package/src/duckdb/src/planner/parsed_data/ub_duckdb_planner_parsed_data.cpp +2 -0
  632. package/src/duckdb/src/planner/planner.cpp +3 -0
  633. package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +46 -18
  634. package/src/duckdb/src/planner/subquery/rewrite_correlated_expressions.cpp +39 -33
  635. package/src/duckdb/src/planner/subquery/ub_duckdb_planner_subquery.cpp +4 -0
  636. package/src/duckdb/src/planner/ub_duckdb_planner.cpp +15 -0
  637. package/src/duckdb/src/storage/arena_allocator.cpp +9 -0
  638. package/src/duckdb/src/storage/buffer/block_handle.cpp +7 -2
  639. package/src/duckdb/src/storage/buffer/block_manager.cpp +7 -3
  640. package/src/duckdb/src/storage/buffer/buffer_pool.cpp +121 -24
  641. package/src/duckdb/src/storage/buffer/ub_duckdb_storage_buffer.cpp +6 -0
  642. package/src/duckdb/src/storage/checkpoint/ub_duckdb_storage_checkpoint.cpp +5 -0
  643. package/src/duckdb/src/storage/checkpoint/write_overflow_strings_to_disk.cpp +4 -4
  644. package/src/duckdb/src/storage/compression/chimp/ub_duckdb_storage_compression_chimp.cpp +6 -0
  645. package/src/duckdb/src/storage/compression/dictionary_compression.cpp +6 -5
  646. package/src/duckdb/src/storage/compression/fsst.cpp +3 -2
  647. package/src/duckdb/src/storage/compression/rle.cpp +1 -1
  648. package/src/duckdb/src/storage/compression/string_uncompressed.cpp +4 -4
  649. package/src/duckdb/src/storage/compression/ub_duckdb_storage_compression.cpp +12 -0
  650. package/src/duckdb/src/storage/data_table.cpp +6 -3
  651. package/src/duckdb/src/storage/local_storage.cpp +5 -2
  652. package/src/duckdb/src/storage/metadata/metadata_manager.cpp +4 -4
  653. package/src/duckdb/src/storage/metadata/metadata_reader.cpp +1 -1
  654. package/src/duckdb/src/storage/metadata/metadata_writer.cpp +1 -1
  655. package/src/duckdb/src/storage/metadata/ub_duckdb_storage_metadata.cpp +4 -0
  656. package/src/duckdb/src/storage/partial_block_manager.cpp +1 -1
  657. package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +2 -0
  658. package/src/duckdb/src/storage/serialization/serialize_expression.cpp +3 -0
  659. package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +5 -29
  660. package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +22 -4
  661. package/src/duckdb/src/storage/serialization/serialize_parse_info.cpp +12 -32
  662. package/src/duckdb/src/storage/serialization/ub_duckdb_storage_serialization.cpp +16 -0
  663. package/src/duckdb/src/storage/standard_buffer_manager.cpp +29 -397
  664. package/src/duckdb/src/storage/statistics/string_stats.cpp +1 -1
  665. package/src/duckdb/src/storage/statistics/ub_duckdb_storage_statistics.cpp +10 -0
  666. package/src/duckdb/src/storage/storage_info.cpp +1 -1
  667. package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +3 -3
  668. package/src/duckdb/src/storage/table/column_data.cpp +7 -16
  669. package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +4 -1
  670. package/src/duckdb/src/storage/table/column_segment.cpp +68 -78
  671. package/src/duckdb/src/storage/table/list_column_data.cpp +1 -0
  672. package/src/duckdb/src/storage/table/row_group.cpp +17 -7
  673. package/src/duckdb/src/storage/table/row_group_collection.cpp +28 -27
  674. package/src/duckdb/src/storage/table/ub_duckdb_storage_table.cpp +17 -0
  675. package/src/duckdb/src/storage/table/update_segment.cpp +7 -7
  676. package/src/duckdb/src/storage/temporary_file_manager.cpp +334 -0
  677. package/src/duckdb/src/storage/ub_duckdb_storage.cpp +20 -0
  678. package/src/duckdb/src/storage/write_ahead_log.cpp +3 -2
  679. package/src/duckdb/src/transaction/commit_state.cpp +4 -2
  680. package/src/duckdb/src/transaction/duck_transaction_manager.cpp +32 -17
  681. package/src/duckdb/src/transaction/meta_transaction.cpp +24 -0
  682. package/src/duckdb/src/transaction/transaction_context.cpp +0 -9
  683. package/src/duckdb/src/transaction/ub_duckdb_transaction.cpp +11 -0
  684. package/src/duckdb/src/transaction/undo_buffer.cpp +1 -1
  685. package/src/duckdb/third_party/jaro_winkler/details/common.hpp +1 -1
  686. package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +2 -0
  687. package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +1032 -551
  688. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +24122 -24304
  689. package/src/duckdb/third_party/mbedtls/include/mbedtls/mbedtls_config.h +0 -3
  690. package/src/duckdb/third_party/mbedtls/library/entropy_poll.cpp +32 -4
  691. package/src/duckdb/third_party/miniz/miniz_wrapper.hpp +4 -4
  692. package/src/duckdb/third_party/tdigest/t_digest.hpp +3 -3
  693. package/src/duckdb/ub_src_common_arrow_appender.cpp +2 -0
  694. package/src/duckdb/ub_src_common_exception.cpp +2 -0
  695. package/src/duckdb/ub_src_execution_operator_helper.cpp +2 -0
  696. package/src/duckdb/ub_src_execution_operator_persistent.cpp +0 -2
  697. package/src/duckdb/ub_src_execution_physical_plan.cpp +0 -2
  698. package/src/duckdb/ub_src_parser_parsed_data.cpp +1 -1
  699. package/src/duckdb/ub_src_planner_operator.cpp +0 -2
  700. package/src/duckdb/ub_src_storage.cpp +2 -0
  701. package/test/columns.test.ts +1 -1
  702. package/test/test_all_types.test.ts +1 -1
@@ -27,11 +27,15 @@ static inline void TupleDataValueStore(const T &source, const data_ptr_t &row_lo
27
27
  template <>
28
28
  inline void TupleDataValueStore(const string_t &source, const data_ptr_t &row_location, const idx_t offset_in_row,
29
29
  data_ptr_t &heap_location) {
30
+ #ifdef DEBUG
31
+ source.VerifyCharacters();
32
+ #endif
30
33
  if (source.IsInlined()) {
31
34
  Store<string_t>(source, row_location + offset_in_row);
32
35
  } else {
33
36
  memcpy(heap_location, source.GetData(), source.GetSize());
34
- Store<string_t>(string_t(const_char_ptr_cast(heap_location), source.GetSize()), row_location + offset_in_row);
37
+ Store<string_t>(string_t(const_char_ptr_cast(heap_location), UnsafeNumericCast<uint32_t>(source.GetSize())),
38
+ row_location + offset_in_row);
35
39
  heap_location += source.GetSize();
36
40
  }
37
41
  }
@@ -45,11 +49,30 @@ static inline void TupleDataWithinListValueStore(const T &source, const data_ptr
45
49
  template <>
46
50
  inline void TupleDataWithinListValueStore(const string_t &source, const data_ptr_t &location,
47
51
  data_ptr_t &heap_location) {
48
- Store<uint32_t>(source.GetSize(), location);
52
+ #ifdef DEBUG
53
+ source.VerifyCharacters();
54
+ #endif
55
+ Store<uint32_t>(NumericCast<uint32_t>(source.GetSize()), location);
49
56
  memcpy(heap_location, source.GetData(), source.GetSize());
50
57
  heap_location += source.GetSize();
51
58
  }
52
59
 
60
+ template <class T>
61
+ inline void TupleDataValueVerify(const LogicalType &type, const T &value) {
62
+ #ifdef DEBUG
63
+ // NOP
64
+ #endif
65
+ }
66
+
67
+ template <>
68
+ inline void TupleDataValueVerify(const LogicalType &type, const string_t &value) {
69
+ #ifdef DEBUG
70
+ if (type.id() == LogicalTypeId::VARCHAR) {
71
+ value.Verify();
72
+ }
73
+ #endif
74
+ }
75
+
53
76
  template <class T>
54
77
  static inline T TupleDataWithinListValueLoad(const data_ptr_t &location, data_ptr_t &heap_location) {
55
78
  return Load<T>(location);
@@ -63,20 +86,18 @@ inline string_t TupleDataWithinListValueLoad(const data_ptr_t &location, data_pt
63
86
  return result;
64
87
  }
65
88
 
89
+ static inline void ResetCombinedListData(vector<TupleDataVectorFormat> &vector_data) {
66
90
  #ifdef DEBUG
67
- static void ResetCombinedListData(vector<TupleDataVectorFormat> &vector_data) {
68
91
  for (auto &vd : vector_data) {
69
92
  vd.combined_list_data = nullptr;
70
93
  ResetCombinedListData(vd.children);
71
94
  }
72
- }
73
95
  #endif
96
+ }
74
97
 
75
98
  void TupleDataCollection::ComputeHeapSizes(TupleDataChunkState &chunk_state, const DataChunk &new_chunk,
76
99
  const SelectionVector &append_sel, const idx_t append_count) {
77
- #ifdef DEBUG
78
100
  ResetCombinedListData(chunk_state.vector_data);
79
- #endif
80
101
 
81
102
  auto heap_sizes = FlatVector::GetData<idx_t>(chunk_state.heap_sizes);
82
103
  std::fill_n(heap_sizes, new_chunk.size(), 0);
@@ -104,6 +125,7 @@ void TupleDataCollection::ComputeHeapSizes(Vector &heap_sizes_v, const Vector &s
104
125
 
105
126
  auto heap_sizes = FlatVector::GetData<idx_t>(heap_sizes_v);
106
127
 
128
+ // Source
107
129
  const auto &source_vector_data = source_format.unified;
108
130
  const auto &source_sel = *source_vector_data.sel;
109
131
  const auto &source_validity = source_vector_data.validity;
@@ -209,7 +231,7 @@ void TupleDataCollection::ComputeFixedWithinCollectionHeapSizes(Vector &heap_siz
209
231
  const SelectionVector &append_sel,
210
232
  const idx_t append_count,
211
233
  const UnifiedVectorFormat &list_data) {
212
- // List data
234
+ // Parent list data
213
235
  const auto list_sel = *list_data.sel;
214
236
  const auto list_entries = UnifiedVectorFormat::GetData<list_entry_t>(list_data);
215
237
  const auto &list_validity = list_data.validity;
@@ -227,6 +249,9 @@ void TupleDataCollection::ComputeFixedWithinCollectionHeapSizes(Vector &heap_siz
227
249
 
228
250
  // Get the current list length
229
251
  const auto &list_length = list_entries[list_idx].length;
252
+ if (list_length == 0) {
253
+ continue;
254
+ }
230
255
 
231
256
  // Size is validity mask and all values
232
257
  auto &heap_size = heap_sizes[i];
@@ -240,17 +265,17 @@ void TupleDataCollection::StringWithinCollectionComputeHeapSizes(Vector &heap_si
240
265
  const SelectionVector &append_sel,
241
266
  const idx_t append_count,
242
267
  const UnifiedVectorFormat &list_data) {
268
+ // Parent list data
269
+ const auto list_sel = *list_data.sel;
270
+ const auto list_entries = UnifiedVectorFormat::GetData<list_entry_t>(list_data);
271
+ const auto &list_validity = list_data.validity;
272
+
243
273
  // Source
244
274
  const auto &source_data = source_format.unified;
245
275
  const auto &source_sel = *source_data.sel;
246
276
  const auto data = UnifiedVectorFormat::GetData<string_t>(source_data);
247
277
  const auto &source_validity = source_data.validity;
248
278
 
249
- // List data
250
- const auto list_sel = *list_data.sel;
251
- const auto list_entries = UnifiedVectorFormat::GetData<list_entry_t>(list_data);
252
- const auto &list_validity = list_data.validity;
253
-
254
279
  // Target
255
280
  auto heap_sizes = FlatVector::GetData<idx_t>(heap_sizes_v);
256
281
 
@@ -264,6 +289,9 @@ void TupleDataCollection::StringWithinCollectionComputeHeapSizes(Vector &heap_si
264
289
  const auto &list_entry = list_entries[list_idx];
265
290
  const auto &list_offset = list_entry.offset;
266
291
  const auto &list_length = list_entry.length;
292
+ if (list_length == 0) {
293
+ continue;
294
+ }
267
295
 
268
296
  // Size is validity mask and all string sizes
269
297
  auto &heap_size = heap_sizes[i];
@@ -285,7 +313,7 @@ void TupleDataCollection::StructWithinCollectionComputeHeapSizes(Vector &heap_si
285
313
  const SelectionVector &append_sel,
286
314
  const idx_t append_count,
287
315
  const UnifiedVectorFormat &list_data) {
288
- // List data
316
+ // Parent list data
289
317
  const auto list_sel = *list_data.sel;
290
318
  const auto list_entries = UnifiedVectorFormat::GetData<list_entry_t>(list_data);
291
319
  const auto &list_validity = list_data.validity;
@@ -301,6 +329,9 @@ void TupleDataCollection::StructWithinCollectionComputeHeapSizes(Vector &heap_si
301
329
 
302
330
  // Get the current list length
303
331
  const auto &list_length = list_entries[list_idx].length;
332
+ if (list_length == 0) {
333
+ continue;
334
+ }
304
335
 
305
336
  // Size is just the validity mask
306
337
  heap_sizes[i] += ValidityBytes::SizeInBytes(list_length);
@@ -348,17 +379,20 @@ void TupleDataCollection::CollectionWithinCollectionComputeHeapSizes(Vector &hea
348
379
  const SelectionVector &append_sel,
349
380
  const idx_t append_count,
350
381
  const UnifiedVectorFormat &list_data) {
351
- // List data (of the list Vector that "source_v" is in)
382
+ // Parent list data
352
383
  const auto list_sel = *list_data.sel;
353
384
  const auto list_entries = UnifiedVectorFormat::GetData<list_entry_t>(list_data);
354
385
  const auto &list_validity = list_data.validity;
355
386
 
356
- // Child list ("source_v")
387
+ // Source
357
388
  const auto &child_list_data = source_format.unified;
358
389
  const auto child_list_sel = *child_list_data.sel;
359
390
  const auto child_list_entries = UnifiedVectorFormat::GetData<list_entry_t>(child_list_data);
360
391
  const auto &child_list_validity = child_list_data.validity;
361
392
 
393
+ // Target
394
+ auto heap_sizes = FlatVector::GetData<idx_t>(heap_sizes_v);
395
+
362
396
  // Figure out actual child list size (can differ from ListVector::GetListSize if dict/const vector),
363
397
  // and we cannot use ConstantVector::ZeroSelectionVector because it may need to be longer than STANDARD_VECTOR_SIZE
364
398
  idx_t sum_of_sizes = 0;
@@ -367,9 +401,14 @@ void TupleDataCollection::CollectionWithinCollectionComputeHeapSizes(Vector &hea
367
401
  if (!list_validity.RowIsValid(list_idx)) {
368
402
  continue;
369
403
  }
404
+
405
+ // Get the current list entry
370
406
  const auto &list_entry = list_entries[list_idx];
371
407
  const auto &list_offset = list_entry.offset;
372
408
  const auto &list_length = list_entry.length;
409
+ if (list_length == 0) {
410
+ continue;
411
+ }
373
412
 
374
413
  for (idx_t child_i = 0; child_i < list_length; child_i++) {
375
414
  const auto child_list_idx = child_list_sel.get_index(list_offset + child_i);
@@ -388,10 +427,7 @@ void TupleDataCollection::CollectionWithinCollectionComputeHeapSizes(Vector &hea
388
427
  sum_of_sizes, source_v.GetType().InternalType() == PhysicalType::LIST ? ListVector::GetListSize(source_v)
389
428
  : ArrayVector::GetTotalSize(source_v));
390
429
 
391
- // Target
392
- auto heap_sizes = FlatVector::GetData<idx_t>(heap_sizes_v);
393
-
394
- // Construct combined list entries and a selection vector for the child list child
430
+ D_ASSERT(source_format.children.size() == 1);
395
431
  auto &child_format = source_format.children[0];
396
432
  #ifdef DEBUG
397
433
  // In debug mode this should be deleted by ResetCombinedListData
@@ -401,16 +437,22 @@ void TupleDataCollection::CollectionWithinCollectionComputeHeapSizes(Vector &hea
401
437
  child_format.combined_list_data = make_uniq<CombinedListData>();
402
438
  }
403
439
  auto &combined_list_data = *child_format.combined_list_data;
404
- auto &combined_list_entries = combined_list_data.combined_list_entries;
440
+
441
+ // Construct combined list entries and a selection/validity vector for the child list child
405
442
  SelectionVector combined_sel(child_list_child_count);
406
443
  for (idx_t i = 0; i < child_list_child_count; i++) {
407
444
  combined_sel.set_index(i, 0);
408
445
  }
446
+ auto &combined_list_entries = combined_list_data.combined_list_entries;
447
+ auto &combined_validity = combined_list_data.combined_validity;
448
+ combined_validity.SetAllValid(STANDARD_VECTOR_SIZE);
409
449
 
410
450
  idx_t combined_list_offset = 0;
411
451
  for (idx_t i = 0; i < append_count; i++) {
412
- const auto list_idx = list_sel.get_index(append_sel.get_index(i));
452
+ const auto append_idx = append_sel.get_index(i);
453
+ const auto list_idx = list_sel.get_index(append_idx);
413
454
  if (!list_validity.RowIsValid(list_idx)) {
455
+ combined_validity.SetInvalidUnsafe(append_idx);
414
456
  continue; // Original list entry is invalid - no need to serialize the child list
415
457
  }
416
458
 
@@ -427,10 +469,13 @@ void TupleDataCollection::CollectionWithinCollectionComputeHeapSizes(Vector &hea
427
469
  idx_t child_list_size = 0;
428
470
  for (idx_t child_i = 0; child_i < list_length; child_i++) {
429
471
  const auto child_list_idx = child_list_sel.get_index(list_offset + child_i);
430
- const auto &child_list_entry = child_list_entries[child_list_idx];
431
472
  if (child_list_validity.RowIsValid(child_list_idx)) {
473
+ const auto &child_list_entry = child_list_entries[child_list_idx];
432
474
  const auto &child_list_offset = child_list_entry.offset;
433
475
  const auto &child_list_length = child_list_entry.length;
476
+ if (child_list_length == 0) {
477
+ continue;
478
+ }
434
479
 
435
480
  // Add this child's list entries to the combined selection vector
436
481
  for (idx_t child_value_i = 0; child_value_i < child_list_length; child_value_i++) {
@@ -444,25 +489,23 @@ void TupleDataCollection::CollectionWithinCollectionComputeHeapSizes(Vector &hea
444
489
  }
445
490
 
446
491
  // Combine the child list entries into one
447
- combined_list_entries[list_idx] = {combined_list_offset, child_list_size};
492
+ auto &combined_list_entry = combined_list_entries[append_idx];
493
+ combined_list_entry.offset = combined_list_offset;
494
+ combined_list_entry.length = child_list_size;
448
495
  combined_list_offset += child_list_size;
449
496
  }
450
497
 
451
- // Create a combined child_list_data to be used as list_data in the recursion
452
- auto &combined_child_list_data = combined_list_data.combined_data;
453
- combined_child_list_data.sel = list_data.sel;
454
- combined_child_list_data.data = data_ptr_cast(combined_list_entries);
455
- combined_child_list_data.validity = list_data.validity;
456
-
457
- // Combine the selection vectors
458
- D_ASSERT(source_format.children.size() == 1);
459
-
460
498
  // TODO: Template this?
461
499
  auto &child_source = source_v.GetType().InternalType() == PhysicalType::LIST ? ListVector::GetEntry(source_v)
462
500
  : ArrayVector::GetEntry(source_v);
463
-
464
501
  ApplySliceRecursive(child_source, child_format, combined_sel, child_list_child_count);
465
502
 
503
+ // Create a combined child_list_data to be used as list_data in the recursion
504
+ auto &combined_child_list_data = combined_list_data.combined_data;
505
+ combined_child_list_data.sel = FlatVector::IncrementalSelectionVector();
506
+ combined_child_list_data.data = data_ptr_cast(combined_list_entries);
507
+ combined_child_list_data.validity.Initialize(combined_validity);
508
+
466
509
  // Recurse
467
510
  TupleDataCollection::WithinCollectionComputeHeapSizes(heap_sizes_v, child_source, child_format, append_sel,
468
511
  append_count, combined_child_list_data);
@@ -470,6 +513,13 @@ void TupleDataCollection::CollectionWithinCollectionComputeHeapSizes(Vector &hea
470
513
 
471
514
  void TupleDataCollection::Scatter(TupleDataChunkState &chunk_state, const DataChunk &new_chunk,
472
515
  const SelectionVector &append_sel, const idx_t append_count) const {
516
+ #ifdef DEBUG
517
+ Vector heap_locations_copy(LogicalType::POINTER);
518
+ if (!layout.AllConstant()) {
519
+ VectorOperations::Copy(chunk_state.heap_locations, heap_locations_copy, append_count, 0, 0);
520
+ }
521
+ #endif
522
+
473
523
  const auto row_locations = FlatVector::GetData<data_ptr_t>(chunk_state.row_locations);
474
524
 
475
525
  // Set the validity mask for each row before inserting data
@@ -483,7 +533,7 @@ void TupleDataCollection::Scatter(TupleDataChunkState &chunk_state, const DataCh
483
533
  const auto heap_size_offset = layout.GetHeapSizeOffset();
484
534
  const auto heap_sizes = FlatVector::GetData<idx_t>(chunk_state.heap_sizes);
485
535
  for (idx_t i = 0; i < append_count; i++) {
486
- Store<uint32_t>(heap_sizes[i], row_locations[i] + heap_size_offset);
536
+ Store<uint32_t>(NumericCast<uint32_t>(heap_sizes[i]), row_locations[i] + heap_size_offset);
487
537
  }
488
538
  }
489
539
 
@@ -491,6 +541,18 @@ void TupleDataCollection::Scatter(TupleDataChunkState &chunk_state, const DataCh
491
541
  for (const auto &col_idx : chunk_state.column_ids) {
492
542
  Scatter(chunk_state, new_chunk.data[col_idx], col_idx, append_sel, append_count);
493
543
  }
544
+
545
+ #ifdef DEBUG
546
+ // Verify that the size of the data written to the heap is the same as the size we computed it would be
547
+ if (!layout.AllConstant()) {
548
+ const auto original_heap_locations = FlatVector::GetData<data_ptr_t>(heap_locations_copy);
549
+ const auto heap_sizes = FlatVector::GetData<idx_t>(chunk_state.heap_sizes);
550
+ const auto offset_heap_locations = FlatVector::GetData<data_ptr_t>(chunk_state.heap_locations);
551
+ for (idx_t i = 0; i < append_count; i++) {
552
+ D_ASSERT(offset_heap_locations[i] == original_heap_locations[i] + heap_sizes[i]);
553
+ }
554
+ }
555
+ #endif
494
556
  }
495
557
 
496
558
  void TupleDataCollection::Scatter(TupleDataChunkState &chunk_state, const Vector &source, const column_t column_id,
@@ -601,7 +663,6 @@ static void TupleDataStructScatter(const Vector &source, const TupleDataVectorFo
601
663
  //------------------------------------------------------------------------------
602
664
  // List Scatter
603
665
  //------------------------------------------------------------------------------
604
-
605
666
  static void TupleDataListScatter(const Vector &source, const TupleDataVectorFormat &source_format,
606
667
  const SelectionVector &append_sel, const idx_t append_count,
607
668
  const TupleDataLayout &layout, const Vector &row_locations, Vector &heap_locations,
@@ -650,7 +711,6 @@ static void TupleDataListScatter(const Vector &source, const TupleDataVectorForm
650
711
  //------------------------------------------------------------------------------
651
712
  // Array Scatter
652
713
  //------------------------------------------------------------------------------
653
-
654
714
  static void TupleDataArrayScatter(const Vector &source, const TupleDataVectorFormat &source_format,
655
715
  const SelectionVector &append_sel, const idx_t append_count,
656
716
  const TupleDataLayout &layout, const Vector &row_locations, Vector &heap_locations,
@@ -659,7 +719,7 @@ static void TupleDataArrayScatter(const Vector &source, const TupleDataVectorFor
659
719
  // Source
660
720
  // The Array vector has fake list_entry_t's set by this point, so this is fine
661
721
  const auto &source_data = source_format.unified;
662
- const auto source_sel = *source_data.sel;
722
+ const auto &source_sel = *source_data.sel;
663
723
  const auto data = UnifiedVectorFormat::GetData<list_entry_t>(source_data);
664
724
  const auto &validity = source_data.validity;
665
725
 
@@ -707,17 +767,17 @@ static void TupleDataTemplatedWithinCollectionScatter(const Vector &source, cons
707
767
  Vector &heap_locations, const idx_t col_idx,
708
768
  const UnifiedVectorFormat &list_data,
709
769
  const vector<TupleDataScatterFunction> &child_functions) {
770
+ // Parent list data
771
+ const auto &list_sel = *list_data.sel;
772
+ const auto list_entries = UnifiedVectorFormat::GetData<list_entry_t>(list_data);
773
+ const auto &list_validity = list_data.validity;
774
+
710
775
  // Source
711
776
  const auto &source_data = source_format.unified;
712
777
  const auto &source_sel = *source_data.sel;
713
778
  const auto data = UnifiedVectorFormat::GetData<T>(source_data);
714
779
  const auto &source_validity = source_data.validity;
715
780
 
716
- // List data
717
- const auto list_sel = *list_data.sel;
718
- const auto list_entries = UnifiedVectorFormat::GetData<list_entry_t>(list_data);
719
- const auto &list_validity = list_data.validity;
720
-
721
781
  // Target
722
782
  auto target_heap_locations = FlatVector::GetData<data_ptr_t>(heap_locations);
723
783
 
@@ -731,6 +791,9 @@ static void TupleDataTemplatedWithinCollectionScatter(const Vector &source, cons
731
791
  const auto &list_entry = list_entries[list_idx];
732
792
  const auto &list_offset = list_entry.offset;
733
793
  const auto &list_length = list_entry.length;
794
+ if (list_length == 0) {
795
+ continue;
796
+ }
734
797
 
735
798
  // Initialize validity mask and skip heap pointer over it
736
799
  auto &target_heap_location = target_heap_locations[i];
@@ -762,16 +825,16 @@ static void TupleDataStructWithinCollectionScatter(const Vector &source, const T
762
825
  Vector &heap_locations, const idx_t col_idx,
763
826
  const UnifiedVectorFormat &list_data,
764
827
  const vector<TupleDataScatterFunction> &child_functions) {
828
+ // Parent list data
829
+ const auto &list_sel = *list_data.sel;
830
+ const auto list_entries = UnifiedVectorFormat::GetData<list_entry_t>(list_data);
831
+ const auto &list_validity = list_data.validity;
832
+
765
833
  // Source
766
834
  const auto &source_data = source_format.unified;
767
835
  const auto &source_sel = *source_data.sel;
768
836
  const auto &source_validity = source_data.validity;
769
837
 
770
- // List data
771
- const auto list_sel = *list_data.sel;
772
- const auto list_entries = UnifiedVectorFormat::GetData<list_entry_t>(list_data);
773
- const auto &list_validity = list_data.validity;
774
-
775
838
  // Target
776
839
  auto target_heap_locations = FlatVector::GetData<data_ptr_t>(heap_locations);
777
840
 
@@ -786,6 +849,9 @@ static void TupleDataStructWithinCollectionScatter(const Vector &source, const T
786
849
  const auto &list_entry = list_entries[list_idx];
787
850
  const auto &list_offset = list_entry.offset;
788
851
  const auto &list_length = list_entry.length;
852
+ if (list_length == 0) {
853
+ continue;
854
+ }
789
855
 
790
856
  // Initialize validity mask and skip the heap pointer over it
791
857
  auto &target_heap_location = target_heap_locations[i];
@@ -822,14 +888,14 @@ static void TupleDataCollectionWithinCollectionScatter(const Vector &child_list,
822
888
  Vector &heap_locations, const idx_t col_idx,
823
889
  const UnifiedVectorFormat &list_data,
824
890
  const vector<TupleDataScatterFunction> &child_functions) {
825
- // List data (of the list Vector that "child_list" is in)
826
- const auto list_sel = *list_data.sel;
891
+ // Parent list data
892
+ const auto &list_sel = *list_data.sel;
827
893
  const auto list_entries = UnifiedVectorFormat::GetData<list_entry_t>(list_data);
828
894
  const auto &list_validity = list_data.validity;
829
895
 
830
- // Child list
896
+ // Source
831
897
  const auto &child_list_data = child_list_format.unified;
832
- const auto child_list_sel = *child_list_data.sel;
898
+ const auto &child_list_sel = *child_list_data.sel;
833
899
  const auto child_list_entries = UnifiedVectorFormat::GetData<list_entry_t>(child_list_data);
834
900
  const auto &child_list_validity = child_list_data.validity;
835
901
 
@@ -846,6 +912,9 @@ static void TupleDataCollectionWithinCollectionScatter(const Vector &child_list,
846
912
  const auto &list_entry = list_entries[list_idx];
847
913
  const auto &list_offset = list_entry.offset;
848
914
  const auto &list_length = list_entry.length;
915
+ if (list_length == 0) {
916
+ continue;
917
+ }
849
918
 
850
919
  // Initialize validity mask and skip heap pointer over it
851
920
  auto &target_heap_location = target_heap_locations[i];
@@ -960,7 +1029,6 @@ TupleDataScatterFunction TupleDataCollection::GetScatterFunction(const LogicalTy
960
1029
  //-------------------------------------------------------------------------------
961
1030
  // Gather
962
1031
  //-------------------------------------------------------------------------------
963
-
964
1032
  void TupleDataCollection::Gather(Vector &row_locations, const SelectionVector &scan_sel, const idx_t scan_count,
965
1033
  DataChunk &result, const SelectionVector &target_sel,
966
1034
  vector<unique_ptr<Vector>> &cached_cast_vectors) const {
@@ -989,6 +1057,7 @@ void TupleDataCollection::Gather(Vector &row_locations, const SelectionVector &s
989
1057
  const auto &gather_function = gather_functions[column_id];
990
1058
  gather_function.function(layout, row_locations, column_id, scan_sel, scan_count, result, target_sel,
991
1059
  cached_cast_vector, gather_function.child_functions);
1060
+ Vector::Verify(result, target_sel, scan_count);
992
1061
  }
993
1062
 
994
1063
  template <class T>
@@ -1015,6 +1084,7 @@ static void TupleDataTemplatedGather(const TupleDataLayout &layout, Vector &row_
1015
1084
  ValidityBytes row_mask(source_row);
1016
1085
  if (row_mask.RowIsValid(row_mask.GetValidityEntryUnsafe(entry_idx), idx_in_entry)) {
1017
1086
  target_data[target_idx] = Load<T>(source_row + offset_in_row);
1087
+ TupleDataValueVerify<T>(target.GetType(), target_data[target_idx]);
1018
1088
  } else {
1019
1089
  target_validity.SetInvalid(target_idx);
1020
1090
  }
@@ -1082,7 +1152,7 @@ static void TupleDataListGather(const TupleDataLayout &layout, Vector &row_locat
1082
1152
 
1083
1153
  // Target
1084
1154
  auto target_list_entries = FlatVector::GetData<list_entry_t>(target);
1085
- auto &target_validity = FlatVector::Validity(target);
1155
+ auto &target_list_validity = FlatVector::Validity(target);
1086
1156
 
1087
1157
  // Precompute mask indexes
1088
1158
  idx_t entry_idx;
@@ -1092,18 +1162,16 @@ static void TupleDataListGather(const TupleDataLayout &layout, Vector &row_locat
1092
1162
  // Load pointers to the data from the row
1093
1163
  Vector heap_locations(LogicalType::POINTER);
1094
1164
  auto source_heap_locations = FlatVector::GetData<data_ptr_t>(heap_locations);
1095
- auto &source_heap_validity = FlatVector::Validity(heap_locations);
1096
1165
 
1097
1166
  const auto offset_in_row = layout.GetOffsets()[col_idx];
1098
1167
  uint64_t target_list_offset = 0;
1099
1168
  for (idx_t i = 0; i < scan_count; i++) {
1100
- const auto source_idx = scan_sel.get_index(i);
1101
- const auto target_idx = target_sel.get_index(i);
1102
-
1103
- const auto &source_row = source_locations[source_idx];
1169
+ const auto &source_row = source_locations[scan_sel.get_index(i)];
1104
1170
  ValidityBytes row_mask(source_row);
1171
+
1172
+ const auto target_idx = target_sel.get_index(i);
1105
1173
  if (row_mask.RowIsValid(row_mask.GetValidityEntryUnsafe(entry_idx), idx_in_entry)) {
1106
- auto &source_heap_location = source_heap_locations[source_idx];
1174
+ auto &source_heap_location = source_heap_locations[i];
1107
1175
  source_heap_location = Load<data_ptr_t>(source_row + offset_in_row);
1108
1176
 
1109
1177
  // Load list size and skip over
@@ -1111,11 +1179,12 @@ static void TupleDataListGather(const TupleDataLayout &layout, Vector &row_locat
1111
1179
  source_heap_location += sizeof(uint64_t);
1112
1180
 
1113
1181
  // Initialize list entry, and increment offset
1114
- target_list_entries[target_idx] = {target_list_offset, list_length};
1182
+ auto &target_list_entry = target_list_entries[target_idx];
1183
+ target_list_entry.offset = target_list_offset;
1184
+ target_list_entry.length = list_length;
1115
1185
  target_list_offset += list_length;
1116
1186
  } else {
1117
- source_heap_validity.SetInvalid(source_idx);
1118
- target_validity.SetInvalid(target_idx);
1187
+ target_list_validity.SetInvalid(target_idx);
1119
1188
  }
1120
1189
  }
1121
1190
  auto list_size_before = ListVector::GetListSize(target);
@@ -1139,28 +1208,31 @@ static void TupleDataTemplatedWithinCollectionGather(const TupleDataLayout &layo
1139
1208
  const SelectionVector &target_sel,
1140
1209
  optional_ptr<Vector> list_vector,
1141
1210
  const vector<TupleDataGatherFunction> &child_functions) {
1211
+ // List parent
1212
+ const auto list_entries = FlatVector::GetData<list_entry_t>(*list_vector);
1213
+ const auto &list_validity = FlatVector::Validity(*list_vector);
1214
+
1142
1215
  // Source
1143
1216
  auto source_heap_locations = FlatVector::GetData<data_ptr_t>(heap_locations);
1144
- auto &source_heap_validity = FlatVector::Validity(heap_locations);
1145
1217
 
1146
1218
  // Target
1147
1219
  auto target_data = FlatVector::GetData<T>(target);
1148
1220
  auto &target_validity = FlatVector::Validity(target);
1149
1221
 
1150
- // List parent
1151
- const auto list_entries = FlatVector::GetData<list_entry_t>(*list_vector);
1152
-
1153
1222
  uint64_t target_offset = list_size_before;
1154
1223
  for (idx_t i = 0; i < scan_count; i++) {
1155
- const auto source_idx = scan_sel.get_index(i);
1156
- if (!source_heap_validity.RowIsValid(source_idx)) {
1224
+ const auto target_idx = target_sel.get_index(i);
1225
+ if (!list_validity.RowIsValid(target_idx)) {
1157
1226
  continue;
1158
1227
  }
1159
1228
 
1160
- const auto &list_length = list_entries[target_sel.get_index(i)].length;
1229
+ const auto &list_length = list_entries[target_idx].length;
1230
+ if (list_length == 0) {
1231
+ continue;
1232
+ }
1161
1233
 
1162
1234
  // Initialize validity mask
1163
- auto &source_heap_location = source_heap_locations[source_idx];
1235
+ auto &source_heap_location = source_heap_locations[i];
1164
1236
  ValidityBytes source_mask(source_heap_location);
1165
1237
  source_heap_location += ValidityBytes::SizeInBytes(list_length);
1166
1238
 
@@ -1171,8 +1243,10 @@ static void TupleDataTemplatedWithinCollectionGather(const TupleDataLayout &layo
1171
1243
  // Load the child validity and data belonging to this list entry
1172
1244
  for (idx_t child_i = 0; child_i < list_length; child_i++) {
1173
1245
  if (source_mask.RowIsValidUnsafe(child_i)) {
1174
- target_data[target_offset + child_i] = TupleDataWithinListValueLoad<T>(
1246
+ auto &target_value = target_data[target_offset + child_i];
1247
+ target_value = TupleDataWithinListValueLoad<T>(
1175
1248
  source_data_location + child_i * TupleDataWithinListFixedSize<T>(), source_heap_location);
1249
+ TupleDataValueVerify(target.GetType(), target_value);
1176
1250
  } else {
1177
1251
  target_validity.SetInvalid(target_offset + child_i);
1178
1252
  }
@@ -1186,27 +1260,30 @@ static void TupleDataStructWithinCollectionGather(const TupleDataLayout &layout,
1186
1260
  const idx_t scan_count, Vector &target,
1187
1261
  const SelectionVector &target_sel, optional_ptr<Vector> list_vector,
1188
1262
  const vector<TupleDataGatherFunction> &child_functions) {
1263
+ // List parent
1264
+ const auto list_entries = FlatVector::GetData<list_entry_t>(*list_vector);
1265
+ const auto &list_validity = FlatVector::Validity(*list_vector);
1266
+
1189
1267
  // Source
1190
1268
  auto source_heap_locations = FlatVector::GetData<data_ptr_t>(heap_locations);
1191
- auto &source_heap_validity = FlatVector::Validity(heap_locations);
1192
1269
 
1193
1270
  // Target
1194
1271
  auto &target_validity = FlatVector::Validity(target);
1195
1272
 
1196
- // List parent
1197
- const auto list_entries = FlatVector::GetData<list_entry_t>(*list_vector);
1198
-
1199
1273
  uint64_t target_offset = list_size_before;
1200
1274
  for (idx_t i = 0; i < scan_count; i++) {
1201
- const auto source_idx = scan_sel.get_index(i);
1202
- if (!source_heap_validity.RowIsValid(source_idx)) {
1275
+ const auto target_idx = target_sel.get_index(i);
1276
+ if (!list_validity.RowIsValid(target_idx)) {
1203
1277
  continue;
1204
1278
  }
1205
1279
 
1206
- const auto &list_length = list_entries[target_sel.get_index(i)].length;
1280
+ const auto &list_length = list_entries[target_idx].length;
1281
+ if (list_length == 0) {
1282
+ continue;
1283
+ }
1207
1284
 
1208
1285
  // Initialize validity mask and skip over it
1209
- auto &source_heap_location = source_heap_locations[source_idx];
1286
+ auto &source_heap_location = source_heap_locations[i];
1210
1287
  ValidityBytes source_mask(source_heap_location);
1211
1288
  source_heap_location += ValidityBytes::SizeInBytes(list_length);
1212
1289
 
@@ -1235,34 +1312,38 @@ static void TupleDataCollectionWithinCollectionGather(const TupleDataLayout &lay
1235
1312
  const SelectionVector &target_sel,
1236
1313
  optional_ptr<Vector> list_vector,
1237
1314
  const vector<TupleDataGatherFunction> &child_functions) {
1315
+ // List parent
1316
+ const auto list_entries = FlatVector::GetData<list_entry_t>(*list_vector);
1317
+ const auto &list_validity = FlatVector::Validity(*list_vector);
1318
+
1238
1319
  // Source
1239
1320
  auto source_heap_locations = FlatVector::GetData<data_ptr_t>(heap_locations);
1240
- auto &source_heap_validity = FlatVector::Validity(heap_locations);
1241
1321
 
1242
1322
  // Target
1243
1323
  auto target_list_entries = FlatVector::GetData<list_entry_t>(target);
1244
1324
  auto &target_validity = FlatVector::Validity(target);
1245
1325
  const auto child_list_size_before = ListVector::GetListSize(target);
1246
1326
 
1247
- // List parent
1248
- const auto list_entries = FlatVector::GetData<list_entry_t>(*list_vector);
1249
-
1250
1327
  // We need to create a vector that has the combined list sizes (hugeint_t has same size as list_entry_t)
1251
1328
  Vector combined_list_vector(LogicalType::HUGEINT);
1329
+ FlatVector::SetValidity(combined_list_vector, list_validity); // Has same validity as list parent
1252
1330
  auto combined_list_entries = FlatVector::GetData<list_entry_t>(combined_list_vector);
1253
1331
 
1254
1332
  uint64_t target_offset = list_size_before;
1255
1333
  uint64_t target_child_offset = child_list_size_before;
1256
1334
  for (idx_t i = 0; i < scan_count; i++) {
1257
- const auto source_idx = scan_sel.get_index(i);
1258
- if (!source_heap_validity.RowIsValid(source_idx)) {
1335
+ const auto target_idx = target_sel.get_index(i);
1336
+ if (!list_validity.RowIsValid(target_idx)) {
1259
1337
  continue;
1260
1338
  }
1261
1339
 
1262
- const auto &list_length = list_entries[target_sel.get_index(i)].length;
1340
+ const auto &list_length = list_entries[target_idx].length;
1341
+ if (list_length == 0) {
1342
+ continue;
1343
+ }
1263
1344
 
1264
1345
  // Initialize validity mask and skip over it
1265
- auto &source_heap_location = source_heap_locations[source_idx];
1346
+ auto &source_heap_location = source_heap_locations[i];
1266
1347
  ValidityBytes source_mask(source_heap_location);
1267
1348
  source_heap_location += ValidityBytes::SizeInBytes(list_length);
1268
1349
 
@@ -1348,7 +1429,6 @@ static void TupleDataCastToArrayStructGather(const TupleDataLayout &layout, Vect
1348
1429
  //------------------------------------------------------------------------------
1349
1430
  // Get Gather Function
1350
1431
  //------------------------------------------------------------------------------
1351
-
1352
1432
  template <class T>
1353
1433
  tuple_data_gather_function_t TupleDataGetGatherFunction(bool within_collection) {
1354
1434
  return within_collection ? TupleDataTemplatedWithinCollectionGather<T> : TupleDataTemplatedGather<T>;
@@ -0,0 +1,11 @@
1
+ // Unity Build generated by CMake
2
+ #include </Users/carlo/duckdb/src/common/types/row/partitioned_tuple_data.cpp>
3
+ #include </Users/carlo/duckdb/src/common/types/row/row_data_collection.cpp>
4
+ #include </Users/carlo/duckdb/src/common/types/row/row_data_collection_scanner.cpp>
5
+ #include </Users/carlo/duckdb/src/common/types/row/row_layout.cpp>
6
+ #include </Users/carlo/duckdb/src/common/types/row/tuple_data_allocator.cpp>
7
+ #include </Users/carlo/duckdb/src/common/types/row/tuple_data_collection.cpp>
8
+ #include </Users/carlo/duckdb/src/common/types/row/tuple_data_iterator.cpp>
9
+ #include </Users/carlo/duckdb/src/common/types/row/tuple_data_layout.cpp>
10
+ #include </Users/carlo/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp>
11
+ #include </Users/carlo/duckdb/src/common/types/row/tuple_data_segment.cpp>
@@ -38,7 +38,7 @@ buffer_ptr<SelectionData> SelectionVector::Slice(const SelectionVector &sel, idx
38
38
  for (idx_t i = 0; i < count; i++) {
39
39
  auto new_idx = sel.get_index(i);
40
40
  auto idx = this->get_index(new_idx);
41
- result_ptr[i] = idx;
41
+ result_ptr[i] = UnsafeNumericCast<sel_t>(idx);
42
42
  }
43
43
  return data;
44
44
  }