duckdb 0.7.2-dev225.0 → 0.7.2-dev2320.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.
- package/binding.gyp +13 -6
- package/lib/duckdb.d.ts +55 -2
- package/lib/duckdb.js +20 -1
- package/package.json +1 -1
- package/src/connection.cpp +13 -14
- package/src/data_chunk.cpp +14 -2
- package/src/database.cpp +15 -16
- package/src/duckdb/extension/icu/icu-dateadd.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datefunc.cpp +23 -11
- package/src/duckdb/extension/icu/icu-datepart.cpp +18 -18
- package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +32 -29
- package/src/duckdb/extension/icu/icu-list-range.cpp +207 -0
- package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
- package/src/duckdb/extension/icu/icu-strptime.cpp +133 -45
- package/src/duckdb/extension/icu/icu-table-range.cpp +10 -10
- package/src/duckdb/extension/icu/icu-timebucket.cpp +6 -6
- package/src/duckdb/extension/icu/icu-timezone.cpp +19 -18
- package/src/duckdb/extension/icu/include/icu-datefunc.hpp +10 -8
- package/src/duckdb/extension/icu/include/icu-list-range.hpp +17 -0
- package/src/duckdb/extension/icu/third_party/icu/common/unicode/localpointer.h +22 -22
- package/src/duckdb/extension/icu/third_party/icu/i18n/unicode/numberformatter.h +1 -1
- package/src/duckdb/extension/icu/third_party/icu/stubdata/stubdata.cpp +1 -1
- package/src/duckdb/extension/json/buffered_json_reader.cpp +3 -3
- package/src/duckdb/extension/json/include/buffered_json_reader.hpp +5 -5
- package/src/duckdb/extension/json/include/json_common.hpp +1 -0
- package/src/duckdb/extension/json/include/json_deserializer.hpp +92 -0
- package/src/duckdb/extension/json/include/json_executors.hpp +2 -2
- package/src/duckdb/extension/json/include/json_functions.hpp +8 -1
- package/src/duckdb/extension/json/include/json_scan.hpp +9 -10
- package/src/duckdb/extension/json/include/json_serializer.hpp +82 -0
- package/src/duckdb/extension/json/include/json_structure.hpp +1 -1
- package/src/duckdb/extension/json/json-extension.cpp +6 -0
- package/src/duckdb/extension/json/json_deserializer.cpp +306 -0
- package/src/duckdb/extension/json/json_functions/copy_json.cpp +19 -19
- package/src/duckdb/extension/json/json_functions/json_create.cpp +27 -26
- package/src/duckdb/extension/json/json_functions/json_merge_patch.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +279 -0
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +3 -3
- package/src/duckdb/extension/json/json_functions/read_json.cpp +26 -35
- package/src/duckdb/extension/json/json_functions.cpp +35 -18
- package/src/duckdb/extension/json/json_scan.cpp +9 -32
- package/src/duckdb/extension/json/json_serializer.cpp +253 -0
- package/src/duckdb/extension/parquet/column_reader.cpp +162 -99
- package/src/duckdb/extension/parquet/column_writer.cpp +106 -105
- package/src/duckdb/extension/parquet/include/boolean_column_reader.hpp +5 -3
- package/src/duckdb/extension/parquet/include/callback_column_reader.hpp +3 -0
- package/src/duckdb/extension/parquet/include/cast_column_reader.hpp +7 -4
- package/src/duckdb/extension/parquet/include/column_reader.hpp +26 -10
- package/src/duckdb/extension/parquet/include/column_writer.hpp +7 -8
- package/src/duckdb/extension/parquet/include/decode_utils.hpp +5 -4
- package/src/duckdb/extension/parquet/include/list_column_reader.hpp +6 -4
- package/src/duckdb/extension/parquet/include/parquet_dbp_decoder.hpp +3 -3
- package/src/duckdb/extension/parquet/include/parquet_decimal_utils.hpp +3 -3
- package/src/duckdb/extension/parquet/include/parquet_file_metadata_cache.hpp +2 -2
- package/src/duckdb/extension/parquet/include/parquet_metadata.hpp +1 -0
- package/src/duckdb/extension/parquet/include/parquet_reader.hpp +27 -52
- package/src/duckdb/extension/parquet/include/parquet_statistics.hpp +2 -2
- package/src/duckdb/extension/parquet/include/parquet_support.hpp +10 -9
- package/src/duckdb/extension/parquet/include/parquet_timestamp.hpp +2 -1
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +3 -3
- package/src/duckdb/extension/parquet/include/row_number_column_reader.hpp +6 -3
- package/src/duckdb/extension/parquet/include/string_column_reader.hpp +4 -1
- package/src/duckdb/extension/parquet/include/struct_column_reader.hpp +7 -3
- package/src/duckdb/extension/parquet/include/templated_column_reader.hpp +3 -0
- package/src/duckdb/extension/parquet/include/zstd_file_system.hpp +2 -2
- package/src/duckdb/extension/parquet/parquet-extension.cpp +113 -253
- package/src/duckdb/extension/parquet/parquet_metadata.cpp +11 -19
- package/src/duckdb/extension/parquet/parquet_reader.cpp +120 -255
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +53 -40
- package/src/duckdb/extension/parquet/parquet_timestamp.cpp +16 -6
- package/src/duckdb/extension/parquet/parquet_writer.cpp +2 -2
- package/src/duckdb/extension/parquet/zstd_file_system.cpp +4 -4
- package/src/duckdb/src/catalog/catalog.cpp +79 -49
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +33 -33
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +52 -75
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +5 -5
- package/src/duckdb/src/catalog/catalog_entry/scalar_function_catalog_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +8 -12
- package/src/duckdb/src/catalog/catalog_entry/table_function_catalog_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +11 -5
- package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_set.cpp +56 -53
- package/src/duckdb/src/catalog/default/default_functions.cpp +15 -11
- package/src/duckdb/src/catalog/default/default_schemas.cpp +1 -1
- package/src/duckdb/src/catalog/default/default_types.cpp +4 -4
- package/src/duckdb/src/catalog/default/default_views.cpp +5 -5
- package/src/duckdb/src/catalog/dependency_list.cpp +15 -2
- package/src/duckdb/src/catalog/dependency_manager.cpp +46 -40
- package/src/duckdb/src/catalog/duck_catalog.cpp +37 -10
- package/src/duckdb/src/common/adbc/adbc.cpp +441 -0
- package/src/duckdb/src/common/adbc/driver_manager.cpp +749 -0
- package/src/duckdb/src/common/allocator.cpp +2 -2
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +121 -52
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +5 -5
- package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +21 -3
- package/src/duckdb/src/common/box_renderer.cpp +113 -25
- package/src/duckdb/src/common/compressed_file_system.cpp +15 -0
- package/src/duckdb/src/common/constants.cpp +10 -1
- package/src/duckdb/src/common/enums/expression_type.cpp +8 -222
- package/src/duckdb/src/common/enums/join_type.cpp +3 -22
- package/src/duckdb/src/common/enums/logical_operator_type.cpp +4 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/exception.cpp +19 -1
- package/src/duckdb/src/common/exception_format_value.cpp +1 -1
- package/src/duckdb/src/common/field_writer.cpp +2 -1
- package/src/duckdb/src/common/file_system.cpp +5 -3
- package/src/duckdb/src/common/filename_pattern.cpp +41 -0
- package/src/duckdb/src/common/gzip_file_system.cpp +69 -5
- package/src/duckdb/src/common/hive_partitioning.cpp +150 -19
- package/src/duckdb/src/common/local_file_system.cpp +82 -14
- package/src/duckdb/src/common/multi_file_reader.cpp +373 -0
- package/src/duckdb/src/common/operator/cast_operators.cpp +1 -1
- package/src/duckdb/src/common/pipe_file_system.cpp +2 -1
- package/src/duckdb/src/common/preserved_error.cpp +7 -5
- package/src/duckdb/src/common/progress_bar/progress_bar.cpp +8 -1
- package/src/duckdb/src/common/radix_partitioning.cpp +102 -370
- package/src/duckdb/src/common/random_engine.cpp +1 -1
- package/src/duckdb/src/common/re2_regex.cpp +4 -4
- package/src/duckdb/src/common/row_operations/row_aggregate.cpp +22 -17
- package/src/duckdb/src/common/row_operations/row_external.cpp +1 -1
- package/src/duckdb/src/common/row_operations/row_gather.cpp +5 -3
- package/src/duckdb/src/common/row_operations/row_match.cpp +117 -22
- package/src/duckdb/src/common/row_operations/row_scatter.cpp +6 -4
- package/src/duckdb/src/common/serializer/buffered_deserializer.cpp +4 -0
- package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +21 -3
- package/src/duckdb/src/common/serializer/enum_serializer.cpp +1180 -0
- package/src/duckdb/src/common/sort/comparators.cpp +14 -5
- package/src/duckdb/src/common/sort/merge_sorter.cpp +3 -3
- package/src/duckdb/src/common/sort/partition_state.cpp +644 -0
- package/src/duckdb/src/common/sort/sort_state.cpp +18 -19
- package/src/duckdb/src/common/sort/sorted_block.cpp +23 -18
- package/src/duckdb/src/common/string_util.cpp +43 -3
- package/src/duckdb/src/common/tree_renderer.cpp +7 -9
- package/src/duckdb/src/common/types/batched_data_collection.cpp +5 -4
- package/src/duckdb/src/common/types/bit.cpp +89 -47
- package/src/duckdb/src/common/types/blob.cpp +3 -3
- package/src/duckdb/src/common/types/chunk_collection.cpp +4 -4
- package/src/duckdb/src/common/types/{column_data_allocator.cpp → column/column_data_allocator.cpp} +3 -2
- package/src/duckdb/src/common/types/{column_data_collection.cpp → column/column_data_collection.cpp} +67 -7
- package/src/duckdb/src/common/types/{column_data_collection_segment.cpp → column/column_data_collection_segment.cpp} +14 -11
- package/src/duckdb/src/common/types/{column_data_consumer.cpp → column/column_data_consumer.cpp} +1 -1
- package/src/duckdb/src/common/types/{partitioned_column_data.cpp → column/partitioned_column_data.cpp} +14 -12
- package/src/duckdb/src/common/types/conflict_manager.cpp +5 -4
- package/src/duckdb/src/common/types/data_chunk.cpp +1 -1
- package/src/duckdb/src/common/types/hyperloglog.cpp +2 -2
- package/src/duckdb/src/common/types/interval.cpp +0 -41
- package/src/duckdb/src/common/types/list_segment.cpp +658 -0
- package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +316 -0
- package/src/duckdb/src/common/types/{row_data_collection.cpp → row/row_data_collection.cpp} +2 -2
- package/src/duckdb/src/common/types/{row_data_collection_scanner.cpp → row/row_data_collection_scanner.cpp} +3 -3
- package/src/duckdb/src/common/types/{row_layout.cpp → row/row_layout.cpp} +1 -1
- package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +465 -0
- package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +511 -0
- package/src/duckdb/src/common/types/row/tuple_data_iterator.cpp +96 -0
- package/src/duckdb/src/common/types/row/tuple_data_layout.cpp +119 -0
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +1200 -0
- package/src/duckdb/src/common/types/row/tuple_data_segment.cpp +170 -0
- package/src/duckdb/src/common/types/string_heap.cpp +1 -1
- package/src/duckdb/src/common/types/string_type.cpp +1 -1
- package/src/duckdb/src/common/types/time.cpp +13 -0
- package/src/duckdb/src/common/types/validity_mask.cpp +24 -7
- package/src/duckdb/src/common/types/value.cpp +184 -101
- package/src/duckdb/src/common/types/vector.cpp +205 -144
- package/src/duckdb/src/common/types/vector_buffer.cpp +3 -3
- package/src/duckdb/src/common/types/vector_cache.cpp +4 -4
- package/src/duckdb/src/common/types.cpp +314 -152
- package/src/duckdb/src/common/value_operations/comparison_operations.cpp +14 -22
- package/src/duckdb/src/common/vector.cpp +12 -0
- package/src/duckdb/src/common/vector_operations/comparison_operators.cpp +10 -10
- package/src/duckdb/src/common/vector_operations/is_distinct_from.cpp +11 -10
- package/src/duckdb/src/common/vector_operations/vector_cast.cpp +2 -1
- package/src/duckdb/src/common/vector_operations/vector_copy.cpp +14 -11
- package/src/duckdb/src/common/virtual_file_system.cpp +1 -1
- package/src/duckdb/src/execution/adaptive_filter.cpp +1 -1
- package/src/duckdb/src/execution/aggregate_hashtable.cpp +331 -339
- package/src/duckdb/src/execution/column_binding_resolver.cpp +27 -11
- package/src/duckdb/src/execution/expression_executor/execute_between.cpp +1 -1
- package/src/duckdb/src/execution/expression_executor/execute_case.cpp +1 -1
- package/src/duckdb/src/execution/expression_executor/execute_cast.cpp +3 -2
- package/src/duckdb/src/execution/expression_executor/execute_comparison.cpp +3 -3
- package/src/duckdb/src/execution/expression_executor/execute_conjunction.cpp +6 -6
- package/src/duckdb/src/execution/expression_executor/execute_constant.cpp +1 -1
- package/src/duckdb/src/execution/expression_executor/execute_function.cpp +1 -1
- package/src/duckdb/src/execution/expression_executor/execute_operator.cpp +1 -1
- package/src/duckdb/src/execution/expression_executor/execute_parameter.cpp +1 -1
- package/src/duckdb/src/execution/expression_executor/execute_reference.cpp +1 -1
- package/src/duckdb/src/execution/expression_executor.cpp +5 -4
- package/src/duckdb/src/execution/expression_executor_state.cpp +3 -4
- package/src/duckdb/src/execution/index/art/art.cpp +27 -15
- package/src/duckdb/src/execution/join_hashtable.cpp +203 -337
- package/src/duckdb/src/execution/operator/aggregate/aggregate_object.cpp +12 -3
- package/src/duckdb/src/execution/operator/aggregate/distinct_aggregate_data.cpp +12 -12
- package/src/duckdb/src/execution/operator/aggregate/grouped_aggregate_data.cpp +2 -2
- package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +44 -44
- package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +22 -23
- package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +13 -9
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +43 -29
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +237 -917
- package/src/duckdb/src/execution/operator/filter/physical_filter.cpp +4 -4
- package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +9 -9
- package/src/duckdb/src/execution/operator/helper/physical_execute.cpp +3 -8
- package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +4 -4
- package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +11 -8
- package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +8 -9
- package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +14 -10
- package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +5 -5
- package/src/duckdb/src/execution/operator/helper/physical_result_collector.cpp +8 -14
- package/src/duckdb/src/execution/operator/helper/physical_streaming_limit.cpp +6 -6
- package/src/duckdb/src/execution/operator/helper/physical_streaming_sample.cpp +3 -3
- package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +13 -11
- package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +37 -22
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +78 -31
- package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +7 -7
- package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +18 -17
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +193 -169
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +42 -38
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +29 -19
- package/src/duckdb/src/execution/operator/join/physical_join.cpp +9 -20
- package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +21 -21
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +28 -33
- package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +6 -7
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +4 -2
- package/src/duckdb/src/execution/operator/order/physical_order.cpp +17 -17
- package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +14 -14
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +54 -46
- package/src/duckdb/src/execution/operator/persistent/buffered_csv_reader.cpp +96 -43
- package/src/duckdb/src/execution/operator/persistent/csv_buffer.cpp +17 -13
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +12 -19
- package/src/duckdb/src/execution/operator/persistent/parallel_csv_reader.cpp +134 -30
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +41 -36
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +31 -29
- package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +11 -12
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +30 -29
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +51 -49
- package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +15 -14
- package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +81 -0
- package/src/duckdb/src/execution/operator/projection/physical_projection.cpp +37 -3
- package/src/duckdb/src/execution/operator/projection/physical_tableinout_function.cpp +7 -7
- package/src/duckdb/src/execution/operator/projection/physical_unnest.cpp +5 -6
- package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +14 -8
- package/src/duckdb/src/execution/operator/scan/physical_dummy_scan.cpp +1 -1
- package/src/duckdb/src/execution/operator/scan/physical_expression_scan.cpp +1 -1
- package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +26 -11
- package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +27 -15
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +17 -16
- package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +4 -4
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +26 -46
- package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +2 -2
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +2 -2
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +19 -23
- package/src/duckdb/src/execution/operator/set/physical_union.cpp +15 -4
- package/src/duckdb/src/execution/partitionable_hashtable.cpp +30 -43
- package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +35 -39
- package/src/duckdb/src/execution/physical_operator.cpp +22 -37
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +34 -28
- package/src/duckdb/src/execution/physical_plan/plan_any_join.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_asof_join.cpp +97 -0
- package/src/duckdb/src/execution/physical_plan/plan_column_data_get.cpp +2 -4
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +119 -70
- package/src/duckdb/src/execution/physical_plan/plan_copy_to_file.cpp +3 -3
- package/src/duckdb/src/execution/physical_plan/plan_create.cpp +9 -9
- package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +16 -16
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +6 -6
- package/src/duckdb/src/execution/physical_plan/plan_cross_product.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +4 -4
- package/src/duckdb/src/execution/physical_plan/plan_delim_get.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +12 -13
- package/src/duckdb/src/execution/physical_plan/plan_distinct.cpp +15 -16
- package/src/duckdb/src/execution/physical_plan/plan_dummy_scan.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_empty_result.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_execute.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_explain.cpp +9 -12
- package/src/duckdb/src/execution/physical_plan/plan_export.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_expression_get.cpp +6 -6
- package/src/duckdb/src/execution/physical_plan/plan_filter.cpp +3 -3
- package/src/duckdb/src/execution/physical_plan/plan_get.cpp +12 -13
- package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +28 -8
- package/src/duckdb/src/execution/physical_plan/plan_limit.cpp +6 -7
- package/src/duckdb/src/execution/physical_plan/plan_limit_percent.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_order.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_pivot.cpp +14 -0
- package/src/duckdb/src/execution/physical_plan/plan_positional_join.cpp +14 -5
- package/src/duckdb/src/execution/physical_plan/plan_pragma.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_prepare.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_projection.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_recursive_cte.cpp +7 -7
- package/src/duckdb/src/execution/physical_plan/plan_reset.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_sample.cpp +4 -4
- package/src/duckdb/src/execution/physical_plan/plan_set.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_set_operation.cpp +5 -5
- package/src/duckdb/src/execution/physical_plan/plan_show_select.cpp +3 -5
- package/src/duckdb/src/execution/physical_plan/plan_simple.cpp +14 -14
- package/src/duckdb/src/execution/physical_plan/plan_top_n.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_unnest.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +3 -3
- package/src/duckdb/src/execution/physical_plan/plan_window.cpp +13 -13
- package/src/duckdb/src/execution/physical_plan_generator.cpp +53 -43
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +84 -54
- package/src/duckdb/src/execution/reservoir_sample.cpp +3 -3
- package/src/duckdb/src/execution/window_segment_tree.cpp +196 -26
- package/src/duckdb/src/function/aggregate/algebraic/avg.cpp +4 -4
- package/src/duckdb/src/function/aggregate/distributive/approx_count.cpp +1 -1
- package/src/duckdb/src/function/aggregate/distributive/arg_min_max.cpp +1 -1
- package/src/duckdb/src/function/aggregate/distributive/bitagg.cpp +1 -1
- package/src/duckdb/src/function/aggregate/distributive/bitstring_agg.cpp +33 -25
- package/src/duckdb/src/function/aggregate/distributive/bool.cpp +2 -0
- package/src/duckdb/src/function/aggregate/distributive/count.cpp +3 -4
- package/src/duckdb/src/function/aggregate/distributive/entropy.cpp +1 -1
- package/src/duckdb/src/function/aggregate/distributive/first.cpp +10 -8
- package/src/duckdb/src/function/aggregate/distributive/minmax.cpp +23 -23
- package/src/duckdb/src/function/aggregate/distributive/string_agg.cpp +8 -8
- package/src/duckdb/src/function/aggregate/distributive/sum.cpp +19 -13
- package/src/duckdb/src/function/aggregate/holistic/approximate_quantile.cpp +10 -7
- package/src/duckdb/src/function/aggregate/holistic/mode.cpp +2 -2
- package/src/duckdb/src/function/aggregate/holistic/quantile.cpp +25 -10
- package/src/duckdb/src/function/aggregate/holistic/reservoir_quantile.cpp +6 -6
- package/src/duckdb/src/function/aggregate/nested/histogram.cpp +2 -2
- package/src/duckdb/src/function/aggregate/nested/list.cpp +42 -804
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +289 -98
- package/src/duckdb/src/function/cast/cast_function_set.cpp +3 -2
- package/src/duckdb/src/function/cast/enum_casts.cpp +28 -6
- package/src/duckdb/src/function/cast/list_casts.cpp +19 -6
- package/src/duckdb/src/function/cast/map_cast.cpp +6 -3
- package/src/duckdb/src/function/cast/string_cast.cpp +39 -13
- package/src/duckdb/src/function/cast/struct_cast.cpp +27 -7
- package/src/duckdb/src/function/cast/time_casts.cpp +2 -2
- package/src/duckdb/src/function/cast/union_casts.cpp +40 -14
- package/src/duckdb/src/function/cast/vector_cast_helpers.cpp +2 -3
- package/src/duckdb/src/function/cast_rules.cpp +9 -4
- package/src/duckdb/src/function/compression_config.cpp +9 -9
- package/src/duckdb/src/function/function.cpp +4 -4
- package/src/duckdb/src/function/function_binder.cpp +8 -14
- package/src/duckdb/src/function/macro_function.cpp +3 -3
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +25 -2
- package/src/duckdb/src/function/pragma_function.cpp +1 -1
- package/src/duckdb/src/function/scalar/bit/bitstring.cpp +4 -3
- package/src/duckdb/src/function/scalar/date/current.cpp +0 -2
- package/src/duckdb/src/function/scalar/date/date_diff.cpp +0 -1
- package/src/duckdb/src/function/scalar/date/date_part.cpp +22 -30
- package/src/duckdb/src/function/scalar/date/date_sub.cpp +0 -1
- package/src/duckdb/src/function/scalar/date/date_trunc.cpp +10 -14
- package/src/duckdb/src/function/scalar/date/strftime.cpp +133 -36
- package/src/duckdb/src/function/scalar/generic/alias.cpp +1 -1
- package/src/duckdb/src/function/scalar/generic/constant_or_null.cpp +6 -6
- package/src/duckdb/src/function/scalar/generic/current_setting.cpp +4 -4
- package/src/duckdb/src/function/scalar/generic/error.cpp +21 -0
- package/src/duckdb/src/function/scalar/generic/stats.cpp +6 -8
- package/src/duckdb/src/function/scalar/generic_functions.cpp +1 -0
- package/src/duckdb/src/function/scalar/list/array_slice.cpp +1 -1
- package/src/duckdb/src/function/scalar/list/contains_or_position.cpp +5 -147
- package/src/duckdb/src/function/scalar/list/flatten.cpp +7 -14
- package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +12 -11
- package/src/duckdb/src/function/scalar/list/list_concat.cpp +9 -13
- package/src/duckdb/src/function/scalar/list/list_extract.cpp +6 -13
- package/src/duckdb/src/function/scalar/list/list_lambdas.cpp +13 -9
- package/src/duckdb/src/function/scalar/list/list_sort.cpp +32 -25
- package/src/duckdb/src/function/scalar/list/list_value.cpp +7 -11
- package/src/duckdb/src/function/scalar/map/cardinality.cpp +1 -1
- package/src/duckdb/src/function/scalar/map/map.cpp +48 -2
- package/src/duckdb/src/function/scalar/map/map_entries.cpp +2 -2
- package/src/duckdb/src/function/scalar/map/map_extract.cpp +69 -27
- package/src/duckdb/src/function/scalar/map/map_from_entries.cpp +1 -1
- package/src/duckdb/src/function/scalar/map/map_keys_values.cpp +1 -1
- package/src/duckdb/src/function/scalar/math/numeric.cpp +163 -22
- package/src/duckdb/src/function/scalar/math/random.cpp +3 -3
- package/src/duckdb/src/function/scalar/math/setseed.cpp +4 -4
- package/src/duckdb/src/function/scalar/math_functions.cpp +4 -0
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +50 -51
- package/src/duckdb/src/function/scalar/operators/multiply.cpp +5 -0
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +35 -35
- package/src/duckdb/src/function/scalar/string/caseconvert.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/damerau_levenshtein.cpp +106 -0
- package/src/duckdb/src/function/scalar/string/hex.cpp +384 -0
- package/src/duckdb/src/function/scalar/string/instr.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/length.cpp +2 -6
- package/src/duckdb/src/function/scalar/string/levenshtein.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/like.cpp +6 -10
- package/src/duckdb/src/function/scalar/string/printf.cpp +4 -4
- package/src/duckdb/src/function/scalar/string/regexp/regexp_extract_all.cpp +243 -0
- package/src/duckdb/src/function/scalar/string/regexp/regexp_util.cpp +79 -0
- package/src/duckdb/src/function/scalar/string/regexp.cpp +183 -125
- package/src/duckdb/src/function/scalar/string/string_split.cpp +3 -3
- package/src/duckdb/src/function/scalar/string/substring.cpp +2 -6
- package/src/duckdb/src/function/scalar/string_functions.cpp +2 -0
- package/src/duckdb/src/function/scalar/struct/struct_extract.cpp +9 -14
- package/src/duckdb/src/function/scalar/struct/struct_insert.cpp +12 -15
- package/src/duckdb/src/function/scalar/struct/struct_pack.cpp +9 -10
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +12 -12
- package/src/duckdb/src/function/scalar/union/union_extract.cpp +4 -4
- package/src/duckdb/src/function/scalar/union/union_value.cpp +2 -2
- package/src/duckdb/src/function/scalar_macro_function.cpp +4 -4
- package/src/duckdb/src/function/table/arrow.cpp +17 -14
- package/src/duckdb/src/function/table/arrow_conversion.cpp +28 -4
- package/src/duckdb/src/function/table/checkpoint.cpp +12 -8
- package/src/duckdb/src/function/table/copy_csv.cpp +22 -18
- package/src/duckdb/src/function/table/glob.cpp +7 -12
- package/src/duckdb/src/function/table/pragma_detailed_profiling_output.cpp +15 -14
- package/src/duckdb/src/function/table/pragma_last_profiling_output.cpp +13 -11
- package/src/duckdb/src/function/table/range.cpp +10 -10
- package/src/duckdb/src/function/table/read_csv.cpp +318 -278
- package/src/duckdb/src/function/table/repeat.cpp +4 -4
- package/src/duckdb/src/function/table/summary.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +25 -25
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +21 -20
- package/src/duckdb/src/function/table/system/duckdb_databases.cpp +4 -4
- package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +13 -13
- package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +4 -4
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +3 -3
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +3 -3
- package/src/duckdb/src/function/table/system/duckdb_keywords.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_schemas.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +3 -3
- package/src/duckdb/src/function/table/system/duckdb_settings.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +4 -4
- package/src/duckdb/src/function/table/system/duckdb_temporary_files.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_types.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_views.cpp +2 -2
- package/src/duckdb/src/function/table/system/pragma_collations.cpp +2 -2
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +3 -3
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +9 -7
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +22 -23
- package/src/duckdb/src/function/table/system/test_all_types.cpp +6 -6
- package/src/duckdb/src/function/table/system/test_vector_types.cpp +6 -6
- package/src/duckdb/src/function/table/table_scan.cpp +55 -62
- package/src/duckdb/src/function/table/unnest.cpp +10 -10
- package/src/duckdb/src/function/table/version/pragma_version.cpp +6 -4
- package/src/duckdb/src/function/table_function.cpp +11 -11
- package/src/duckdb/src/function/table_macro_function.cpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +31 -12
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +3 -4
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +5 -5
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +3 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +3 -4
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +14 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry_map.hpp +38 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +5 -5
- package/src/duckdb/src/include/duckdb/catalog/catalog_transaction.hpp +4 -3
- package/src/duckdb/src/include/duckdb/catalog/default/default_functions.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/default/default_types.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/default/default_views.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/dependency.hpp +4 -5
- package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +6 -4
- package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +10 -9
- package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/adbc/adbc-init.hpp +37 -0
- package/src/duckdb/src/include/duckdb/common/adbc/adbc.h +1088 -0
- package/src/duckdb/src/include/duckdb/common/adbc/adbc.hpp +85 -0
- package/src/duckdb/src/include/duckdb/common/adbc/driver_manager.h +84 -0
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/bit_utils.hpp +147 -0
- package/src/duckdb/src/include/duckdb/common/box_renderer.hpp +8 -2
- package/src/duckdb/src/include/duckdb/common/case_insensitive_map.hpp +2 -3
- package/src/duckdb/src/include/duckdb/common/common.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/compressed_file_system.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/constants.hpp +9 -29
- package/src/duckdb/src/include/duckdb/common/enums/aggregate_handling.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/expression_type.hpp +2 -3
- package/src/duckdb/src/include/duckdb/common/enums/file_glob_options.hpp +20 -0
- package/src/duckdb/src/include/duckdb/common/enums/joinref_type.hpp +7 -4
- package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/order_preservation_type.hpp +24 -0
- package/src/duckdb/src/include/duckdb/common/enums/order_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/set_operation_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/exception.hpp +77 -5
- package/src/duckdb/src/include/duckdb/common/exception_format_value.hpp +6 -2
- package/src/duckdb/src/include/duckdb/common/fast_mem.hpp +528 -0
- package/src/duckdb/src/include/duckdb/common/field_writer.hpp +12 -4
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/filename_pattern.hpp +34 -0
- package/src/duckdb/src/include/duckdb/common/gzip_file_system.hpp +4 -1
- package/src/duckdb/src/include/duckdb/common/helper.hpp +70 -9
- package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +16 -6
- package/src/duckdb/src/include/duckdb/common/{http_stats.hpp → http_state.hpp} +18 -4
- package/src/duckdb/src/include/duckdb/common/hugeint.hpp +63 -0
- package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +199 -0
- package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +28 -0
- package/src/duckdb/src/include/duckdb/common/operator/comparison_operators.hpp +45 -149
- package/src/duckdb/src/include/duckdb/common/operator/multiply.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +76 -0
- package/src/duckdb/src/include/duckdb/common/perfect_map_set.hpp +34 -0
- package/src/duckdb/src/include/duckdb/common/preserved_error.hpp +6 -1
- package/src/duckdb/src/include/duckdb/common/progress_bar/progress_bar.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +80 -27
- package/src/duckdb/src/include/duckdb/common/re2_regex.hpp +3 -3
- package/src/duckdb/src/include/duckdb/common/reference_map.hpp +38 -0
- package/src/duckdb/src/include/duckdb/common/row_operations/row_operations.hpp +21 -9
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_deserializer.hpp +4 -2
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +9 -2
- package/src/duckdb/src/include/duckdb/common/serializer/enum_serializer.hpp +113 -0
- package/src/duckdb/src/include/duckdb/common/serializer/format_deserializer.hpp +373 -0
- package/src/duckdb/src/include/duckdb/common/serializer/format_serializer.hpp +248 -0
- package/src/duckdb/src/include/duckdb/common/serializer/serialization_traits.hpp +109 -0
- package/src/duckdb/src/include/duckdb/common/serializer.hpp +13 -0
- package/src/duckdb/src/include/duckdb/common/shared_ptr.hpp +11 -0
- package/src/duckdb/src/include/duckdb/common/sort/comparators.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/sort/partition_state.hpp +247 -0
- package/src/duckdb/src/include/duckdb/common/sort/sort.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/sort/sorted_block.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +39 -0
- package/src/duckdb/src/include/duckdb/common/typedefs.hpp +31 -0
- package/src/duckdb/src/include/duckdb/common/types/batched_data_collection.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/bit.hpp +7 -6
- package/src/duckdb/src/include/duckdb/common/types/{column_data_allocator.hpp → column/column_data_allocator.hpp} +4 -4
- package/src/duckdb/src/include/duckdb/common/types/{column_data_collection.hpp → column/column_data_collection.hpp} +4 -4
- package/src/duckdb/src/include/duckdb/common/types/{column_data_collection_iterators.hpp → column/column_data_collection_iterators.hpp} +2 -2
- package/src/duckdb/src/include/duckdb/common/types/{column_data_collection_segment.hpp → column/column_data_collection_segment.hpp} +3 -3
- package/src/duckdb/src/include/duckdb/common/types/{column_data_consumer.hpp → column/column_data_consumer.hpp} +8 -4
- package/src/duckdb/src/include/duckdb/common/types/{column_data_scan_states.hpp → column/column_data_scan_states.hpp} +1 -1
- package/src/duckdb/src/include/duckdb/common/types/{partitioned_column_data.hpp → column/partitioned_column_data.hpp} +16 -8
- package/src/duckdb/src/include/duckdb/common/types/conflict_manager.hpp +3 -2
- package/src/duckdb/src/include/duckdb/common/types/interval.hpp +39 -3
- package/src/duckdb/src/include/duckdb/common/types/list_segment.hpp +62 -0
- package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +140 -0
- package/src/duckdb/src/include/duckdb/common/types/{row_data_collection.hpp → row/row_data_collection.hpp} +4 -3
- package/src/duckdb/src/include/duckdb/common/types/{row_data_collection_scanner.hpp → row/row_data_collection_scanner.hpp} +2 -2
- package/src/duckdb/src/include/duckdb/common/types/{row_layout.hpp → row/row_layout.hpp} +3 -1
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_allocator.hpp +116 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +239 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_iterator.hpp +64 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_layout.hpp +113 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_segment.hpp +124 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_states.hpp +74 -0
- package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +73 -3
- package/src/duckdb/src/include/duckdb/common/types/time.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +7 -1
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +20 -53
- package/src/duckdb/src/include/duckdb/common/types/value_map.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/vector.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/types.hpp +43 -59
- package/src/duckdb/src/include/duckdb/common/union_by_name.hpp +17 -66
- package/src/duckdb/src/include/duckdb/common/unique_ptr.hpp +61 -0
- package/src/duckdb/src/include/duckdb/common/vector.hpp +45 -2
- package/src/duckdb/src/include/duckdb/common/vector_operations/aggregate_executor.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/vector_operations/unary_executor.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +69 -47
- package/src/duckdb/src/include/duckdb/execution/base_aggregate_hashtable.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/execution_context.hpp +3 -2
- package/src/duckdb/src/include/duckdb/execution/executor.hpp +7 -7
- package/src/duckdb/src/include/duckdb/execution/expression_executor.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/expression_executor_state.hpp +1 -3
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +4 -15
- package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +41 -67
- package/src/duckdb/src/include/duckdb/execution/nested_loop_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/aggregate_object.hpp +15 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +12 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +12 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_streaming_window.hpp +5 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +9 -0
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +9 -3
- package/src/duckdb/src/include/duckdb/execution/operator/filter/physical_filter.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_execute.hpp +6 -4
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +8 -1
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit_percent.hpp +8 -1
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_load.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +1 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_pragma.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_prepare.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +4 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reset.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_result_collector.hpp +6 -3
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_streaming_limit.hpp +4 -1
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_streaming_sample.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_transaction.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/outer_join_marker.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/perfect_hash_join_executor.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +13 -7
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +10 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +3 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_index_join.hpp +9 -7
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_join.hpp +11 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_nested_loop_join.hpp +3 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +5 -2
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +11 -1
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +10 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +15 -10
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/buffered_csv_reader.hpp +4 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_buffer.hpp +8 -3
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_file_handle.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +19 -15
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/parallel_csv_reader.hpp +5 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +11 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +12 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_delete.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +8 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +18 -7
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_pivot.hpp +38 -0
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_projection.hpp +8 -0
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_tableinout_function.hpp +4 -2
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_unnest.hpp +3 -1
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +11 -5
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_dummy_scan.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_empty_result.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_expression_scan.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_positional_scan.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +6 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_alter.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_function.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_schema.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_sequence.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +9 -2
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_view.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_drop.hpp +7 -0
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +9 -2
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_union.hpp +5 -1
- package/src/duckdb/src/include/duckdb/execution/partitionable_hashtable.hpp +7 -3
- package/src/duckdb/src/include/duckdb/execution/perfect_aggregate_hashtable.hpp +4 -0
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +37 -70
- package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +150 -0
- package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +2 -3
- package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +55 -5
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +21 -9
- package/src/duckdb/src/include/duckdb/function/cast/bound_cast_data.hpp +84 -0
- package/src/duckdb/src/include/duckdb/function/cast/cast_function_set.hpp +3 -3
- package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +42 -65
- package/src/duckdb/src/include/duckdb/function/cast/vector_cast_helpers.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/copy_function.hpp +22 -0
- package/src/duckdb/src/include/duckdb/function/function.hpp +22 -4
- package/src/duckdb/src/include/duckdb/function/function_binder.hpp +3 -6
- package/src/duckdb/src/include/duckdb/function/macro_function.hpp +3 -3
- package/src/duckdb/src/include/duckdb/function/pragma_function.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar/generic_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/function/scalar/list/contains_or_position.hpp +138 -0
- package/src/duckdb/src/include/duckdb/function/scalar/math_functions.hpp +12 -0
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +50 -3
- package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +81 -1
- package/src/duckdb/src/include/duckdb/function/scalar/strftime.hpp +4 -0
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +8 -0
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +13 -2
- package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +13 -2
- package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +41 -6
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +30 -0
- package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +3 -3
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +10 -2
- package/src/duckdb/src/include/duckdb/main/client_data.hpp +6 -3
- package/src/duckdb/src/include/duckdb/main/config.hpp +4 -6
- package/src/duckdb/src/include/duckdb/main/connection_manager.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +4 -3
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +5 -0
- package/src/duckdb/src/include/duckdb/main/materialized_query_result.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/prepared_statement.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/query_profiler.hpp +10 -9
- package/src/duckdb/src/include/duckdb/main/query_result.hpp +18 -4
- package/src/duckdb/src/include/duckdb/main/relation/explain_relation.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/relation.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/settings.hpp +29 -0
- package/src/duckdb/src/include/duckdb/optimizer/expression_rewriter.hpp +3 -3
- package/src/duckdb/src/include/duckdb/optimizer/filter_combiner.hpp +9 -9
- package/src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp +2 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +16 -16
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_node.hpp +8 -8
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_order_optimizer.hpp +23 -15
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +9 -10
- package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph.hpp +18 -11
- package/src/duckdb/src/include/duckdb/optimizer/matcher/expression_matcher.hpp +11 -11
- package/src/duckdb/src/include/duckdb/optimizer/matcher/set_matcher.hpp +8 -8
- package/src/duckdb/src/include/duckdb/optimizer/rule/arithmetic_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/case_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/comparison_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/conjunction_simplification.hpp +2 -2
- package/src/duckdb/src/include/duckdb/optimizer/rule/constant_folding.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/date_part_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/distributivity.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/empty_needle_removal.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/enum_comparison.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/equal_or_null_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/in_clause_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/like_optimizations.hpp +2 -2
- package/src/duckdb/src/include/duckdb/optimizer/rule/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/optimizer/rule/move_constants.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/ordered_aggregate_optimizer.hpp +24 -0
- package/src/duckdb/src/include/duckdb/optimizer/rule/regex_optimizations.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parallel/concurrentqueue.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +5 -5
- package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +19 -18
- package/src/duckdb/src/include/duckdb/parallel/pipeline_executor.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/base_expression.hpp +19 -1
- package/src/duckdb/src/include/duckdb/parser/common_table_expression_info.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/constraint.hpp +18 -0
- package/src/duckdb/src/include/duckdb/parser/constraints/check_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/constraints/foreign_key_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/constraints/not_null_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/constraints/unique_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +6 -0
- package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/case_expression.hpp +8 -0
- package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +6 -0
- package/src/duckdb/src/include/duckdb/parser/expression/default_expression.hpp +4 -0
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +7 -2
- package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/parameter_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +7 -2
- package/src/duckdb/src/include/duckdb/parser/expression/subquery_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +10 -0
- package/src/duckdb/src/include/duckdb/parser/expression_map.hpp +19 -6
- package/src/duckdb/src/include/duckdb/parser/expression_util.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_info.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +6 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/copy_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_database_info.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_schema_info.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_sequence_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_type_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/detach_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/drop_info.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +6 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/load_info.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/parsed_data/pragma_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/sample_options.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/show_select_info.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +4 -3
- package/src/duckdb/src/include/duckdb/parser/parsed_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/parser.hpp +1 -7
- package/src/duckdb/src/include/duckdb/parser/parser_options.hpp +23 -0
- package/src/duckdb/src/include/duckdb/parser/query_error_context.hpp +4 -2
- package/src/duckdb/src/include/duckdb/parser/query_node/list.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/recursive_cte_node.hpp +6 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/select_node.hpp +8 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/set_operation_node.hpp +6 -0
- package/src/duckdb/src/include/duckdb/parser/query_node.hpp +29 -1
- package/src/duckdb/src/include/duckdb/parser/result_modifier.hpp +24 -1
- package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +20 -1
- package/src/duckdb/src/include/duckdb/parser/statement/alter_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/attach_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/call_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/copy_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/create_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/delete_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/detach_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/drop_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/execute_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/explain_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/export_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/extension_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/statement/load_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/logical_plan_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/multi_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/pragma_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/prepare_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/relation_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/select_statement.hpp +9 -1
- package/src/duckdb/src/include/duckdb/parser/statement/set_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/show_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/transaction_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/update_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/vacuum_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +7 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/expressionlistref.hpp +6 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/joinref.hpp +6 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +27 -2
- package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +6 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/table_function_ref.hpp +6 -0
- package/src/duckdb/src/include/duckdb/parser/tableref.hpp +20 -1
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +24 -41
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +17 -16
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +38 -32
- package/src/duckdb/src/include/duckdb/planner/bound_constraint.hpp +19 -1
- package/src/duckdb/src/include/duckdb/planner/bound_query_node.hpp +17 -0
- package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +8 -1
- package/src/duckdb/src/include/duckdb/planner/bound_tableref.hpp +17 -0
- package/src/duckdb/src/include/duckdb/planner/bound_tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/constraints/bound_check_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/constraints/bound_foreign_key_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/constraints/bound_not_null_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/constraints/bound_unique_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_aggregate_expression.hpp +7 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_between_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_case_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_cast_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_comparison_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_conjunction_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_constant_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_default_expression.hpp +4 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_function_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_lambda_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_lambdaref_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_operator_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_reference_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_subquery_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_unnest_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_window_expression.hpp +4 -1
- package/src/duckdb/src/include/duckdb/planner/expression.hpp +5 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +64 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/having_binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/index_binder.hpp +4 -4
- package/src/duckdb/src/include/duckdb/planner/expression_binder/order_binder.hpp +7 -4
- package/src/duckdb/src/include/duckdb/planner/expression_binder/qualify_binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/select_binder.hpp +9 -38
- package/src/duckdb/src/include/duckdb/planner/expression_binder/table_function_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/where_binder.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +6 -4
- package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +17 -0
- package/src/duckdb/src/include/duckdb/planner/logical_tokens.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/operator/list.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_any_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_asof_join.hpp +27 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +4 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +8 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +6 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create.hpp +6 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create_index.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create_table.hpp +5 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cross_product.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +5 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_distinct.hpp +15 -4
- package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_empty_result.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_export.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_extension_operator.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_filter.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +5 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_limit.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_limit_percent.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_order.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +36 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_positional_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_pragma.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_prepare.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +9 -5
- package/src/duckdb/src/include/duckdb/planner/operator/logical_reset.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_sample.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_set.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_simple.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_top_n.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_unconditional_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +5 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator_extension.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_function_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/planner/parsed_data/bound_create_table_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/planner/pragma_handler.hpp +3 -2
- package/src/duckdb/src/include/duckdb/planner/query_node/bound_recursive_cte_node.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/query_node/bound_select_node.hpp +11 -2
- package/src/duckdb/src/include/duckdb/planner/query_node/bound_set_operation_node.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/query_node/list.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/table_binding.hpp +6 -5
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_basetableref.hpp +5 -2
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_cteref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_dummytableref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_expressionlistref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_joinref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_pivotref.hpp +43 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_pos_join_ref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_subqueryref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_table_function.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +7 -0
- package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +16 -9
- package/src/duckdb/src/include/duckdb/storage/buffer/buffer_pool.hpp +80 -0
- package/src/duckdb/src/include/duckdb/storage/buffer/temporary_file_information.hpp +12 -0
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +49 -182
- package/src/duckdb/src/include/duckdb/storage/checkpoint/table_data_writer.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/chimp128.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/algorithm/chimp_utils.hpp +0 -97
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_analyze.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_compress.hpp +6 -10
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_fetch.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_scan.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/compression/patas/algorithm/patas.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_analyze.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_compress.hpp +6 -10
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_fetch.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_scan.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/data_pointer.hpp +4 -3
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +7 -5
- package/src/duckdb/src/include/duckdb/storage/index.hpp +20 -6
- package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +7 -0
- package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +159 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +93 -31
- package/src/duckdb/src/include/duckdb/storage/statistics/column_statistics.hpp +22 -3
- package/src/duckdb/src/include/duckdb/storage/statistics/distinct_statistics.hpp +8 -6
- package/src/duckdb/src/include/duckdb/storage/statistics/list_stats.hpp +41 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/node_statistics.hpp +3 -3
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats.hpp +114 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats_union.hpp +62 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/segment_statistics.hpp +2 -7
- package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +74 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/struct_stats.hpp +42 -0
- package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +3 -4
- package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +21 -7
- package/src/duckdb/src/include/duckdb/storage/table/column_data_checkpointer.hpp +5 -3
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +7 -7
- package/src/duckdb/src/include/duckdb/storage/table/column_segment_tree.hpp +18 -0
- package/src/duckdb/src/include/duckdb/storage/table/persistent_table_data.hpp +6 -3
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +42 -46
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +24 -8
- package/src/duckdb/src/include/duckdb/storage/table/row_group_segment_tree.hpp +35 -0
- package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +19 -29
- package/src/duckdb/src/include/duckdb/storage/table/segment_base.hpp +6 -6
- package/src/duckdb/src/include/duckdb/storage/table/segment_tree.hpp +281 -26
- package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +0 -4
- package/src/duckdb/src/include/duckdb/storage/table/table_index_list.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/table/table_statistics.hpp +5 -0
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +4 -5
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +21 -21
- package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +3 -3
- package/src/duckdb/src/include/duckdb/transaction/commit_state.hpp +6 -6
- package/src/duckdb/src/include/duckdb/transaction/duck_transaction.hpp +3 -3
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +37 -33
- package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +6 -5
- package/src/duckdb/src/include/duckdb/transaction/transaction_data.hpp +2 -1
- package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +1 -1
- package/src/duckdb/src/include/duckdb.h +22 -1
- package/src/duckdb/src/main/appender.cpp +9 -9
- package/src/duckdb/src/main/attached_database.cpp +6 -7
- package/src/duckdb/src/main/capi/appender-c.cpp +1 -1
- package/src/duckdb/src/main/capi/duckdb-c.cpp +1 -1
- package/src/duckdb/src/main/capi/pending-c.cpp +4 -4
- package/src/duckdb/src/main/capi/replacement_scan-c.cpp +4 -4
- package/src/duckdb/src/main/capi/result-c.cpp +1 -1
- package/src/duckdb/src/main/capi/table_function-c.cpp +38 -15
- package/src/duckdb/src/main/capi/threading-c.cpp +1 -1
- package/src/duckdb/src/main/client_context.cpp +84 -85
- package/src/duckdb/src/main/client_data.cpp +11 -10
- package/src/duckdb/src/main/client_verify.cpp +2 -2
- package/src/duckdb/src/main/config.cpp +73 -1
- package/src/duckdb/src/main/connection.cpp +3 -3
- package/src/duckdb/src/main/database.cpp +29 -19
- package/src/duckdb/src/main/database_manager.cpp +6 -6
- package/src/duckdb/src/main/extension/extension_helper.cpp +18 -3
- package/src/duckdb/src/main/extension/extension_install.cpp +18 -2
- package/src/duckdb/src/main/extension/extension_load.cpp +30 -4
- package/src/duckdb/src/main/materialized_query_result.cpp +2 -2
- package/src/duckdb/src/main/pending_query_result.cpp +1 -1
- package/src/duckdb/src/main/prepared_statement.cpp +5 -1
- package/src/duckdb/src/main/query_profiler.cpp +48 -44
- package/src/duckdb/src/main/query_result.cpp +13 -0
- package/src/duckdb/src/main/relation/aggregate_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/create_table_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/create_view_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/cross_product_relation.cpp +3 -3
- package/src/duckdb/src/main/relation/delete_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/explain_relation.cpp +4 -4
- package/src/duckdb/src/main/relation/filter_relation.cpp +4 -4
- package/src/duckdb/src/main/relation/insert_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/join_relation.cpp +3 -3
- package/src/duckdb/src/main/relation/limit_relation.cpp +3 -3
- package/src/duckdb/src/main/relation/order_relation.cpp +3 -3
- package/src/duckdb/src/main/relation/projection_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/query_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/read_csv_relation.cpp +4 -2
- package/src/duckdb/src/main/relation/setop_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/table_function_relation.cpp +11 -11
- package/src/duckdb/src/main/relation/table_relation.cpp +3 -3
- package/src/duckdb/src/main/relation/update_relation.cpp +2 -2
- package/src/duckdb/src/main/relation/value_relation.cpp +4 -4
- package/src/duckdb/src/main/relation/view_relation.cpp +3 -3
- package/src/duckdb/src/main/relation/write_csv_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/write_parquet_relation.cpp +1 -1
- package/src/duckdb/src/main/relation.cpp +8 -7
- package/src/duckdb/src/main/settings/settings.cpp +78 -15
- package/src/duckdb/src/main/stream_query_result.cpp +5 -5
- package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +4 -3
- package/src/duckdb/src/optimizer/common_aggregate_optimizer.cpp +3 -3
- package/src/duckdb/src/optimizer/cse_optimizer.cpp +9 -9
- package/src/duckdb/src/optimizer/deliminator.cpp +28 -27
- package/src/duckdb/src/optimizer/expression_heuristics.cpp +11 -11
- package/src/duckdb/src/optimizer/expression_rewriter.cpp +10 -10
- package/src/duckdb/src/optimizer/filter_combiner.cpp +139 -138
- package/src/duckdb/src/optimizer/filter_pullup.cpp +6 -4
- package/src/duckdb/src/optimizer/filter_pushdown.cpp +17 -11
- package/src/duckdb/src/optimizer/in_clause_rewriter.cpp +12 -12
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +102 -111
- package/src/duckdb/src/optimizer/join_order/join_node.cpp +8 -11
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +224 -213
- package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +30 -30
- package/src/duckdb/src/optimizer/join_order/query_graph.cpp +37 -38
- package/src/duckdb/src/optimizer/matcher/expression_matcher.cpp +28 -26
- package/src/duckdb/src/optimizer/optimizer.cpp +15 -14
- package/src/duckdb/src/optimizer/pullup/pullup_filter.cpp +1 -1
- package/src/duckdb/src/optimizer/pullup/pullup_from_left.cpp +2 -2
- package/src/duckdb/src/optimizer/pullup/pullup_projection.cpp +3 -3
- package/src/duckdb/src/optimizer/pullup/pullup_set_operation.cpp +3 -3
- package/src/duckdb/src/optimizer/pushdown/pushdown_aggregate.cpp +36 -8
- package/src/duckdb/src/optimizer/pushdown/pushdown_cross_product.cpp +1 -1
- package/src/duckdb/src/optimizer/pushdown/pushdown_filter.cpp +2 -2
- package/src/duckdb/src/optimizer/pushdown/pushdown_get.cpp +2 -2
- package/src/duckdb/src/optimizer/pushdown/pushdown_inner_join.cpp +9 -6
- package/src/duckdb/src/optimizer/pushdown/pushdown_left_join.cpp +11 -18
- package/src/duckdb/src/optimizer/pushdown/pushdown_limit.cpp +2 -2
- package/src/duckdb/src/optimizer/pushdown/pushdown_mark_join.cpp +5 -5
- package/src/duckdb/src/optimizer/pushdown/pushdown_projection.cpp +4 -4
- package/src/duckdb/src/optimizer/pushdown/pushdown_set_operation.cpp +8 -8
- package/src/duckdb/src/optimizer/pushdown/pushdown_single_join.cpp +2 -2
- package/src/duckdb/src/optimizer/regex_range_filter.cpp +9 -9
- package/src/duckdb/src/optimizer/remove_unused_columns.cpp +17 -12
- package/src/duckdb/src/optimizer/rule/arithmetic_simplification.cpp +31 -30
- package/src/duckdb/src/optimizer/rule/case_simplification.cpp +10 -10
- package/src/duckdb/src/optimizer/rule/comparison_simplification.cpp +22 -23
- package/src/duckdb/src/optimizer/rule/conjunction_simplification.cpp +17 -16
- package/src/duckdb/src/optimizer/rule/constant_folding.cpp +9 -9
- package/src/duckdb/src/optimizer/rule/date_part_simplification.cpp +8 -8
- package/src/duckdb/src/optimizer/rule/distributivity.cpp +23 -23
- package/src/duckdb/src/optimizer/rule/empty_needle_removal.cpp +14 -15
- package/src/duckdb/src/optimizer/rule/enum_comparison.cpp +15 -16
- package/src/duckdb/src/optimizer/rule/equal_or_null_simplification.cpp +35 -38
- package/src/duckdb/src/optimizer/rule/in_clause_simplification_rule.cpp +16 -17
- package/src/duckdb/src/optimizer/rule/like_optimizations.cpp +22 -22
- package/src/duckdb/src/optimizer/rule/move_constants.cpp +46 -40
- package/src/duckdb/src/optimizer/rule/ordered_aggregate_optimizer.cpp +30 -0
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +25 -17
- package/src/duckdb/src/optimizer/statistics/expression/propagate_aggregate.cpp +9 -3
- package/src/duckdb/src/optimizer/statistics/expression/propagate_and_compress.cpp +9 -10
- package/src/duckdb/src/optimizer/statistics/expression/propagate_between.cpp +6 -6
- package/src/duckdb/src/optimizer/statistics/expression/propagate_cast.cpp +14 -11
- package/src/duckdb/src/optimizer/statistics/expression/propagate_columnref.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics/expression/propagate_comparison.cpp +15 -17
- package/src/duckdb/src/optimizer/statistics/expression/propagate_conjunction.cpp +2 -3
- package/src/duckdb/src/optimizer/statistics/expression/propagate_constant.cpp +3 -75
- package/src/duckdb/src/optimizer/statistics/expression/propagate_function.cpp +7 -2
- package/src/duckdb/src/optimizer/statistics/expression/propagate_operator.cpp +12 -2
- package/src/duckdb/src/optimizer/statistics/operator/propagate_aggregate.cpp +2 -3
- package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +40 -42
- package/src/duckdb/src/optimizer/statistics/operator/propagate_get.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +9 -9
- package/src/duckdb/src/optimizer/statistics/operator/propagate_limit.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics/operator/propagate_set_operation.cpp +3 -3
- package/src/duckdb/src/optimizer/statistics_propagator.cpp +34 -22
- package/src/duckdb/src/optimizer/topn_optimizer.cpp +3 -3
- package/src/duckdb/src/optimizer/unnest_rewriter.cpp +16 -16
- package/src/duckdb/src/parallel/executor.cpp +59 -53
- package/src/duckdb/src/parallel/meta_pipeline.cpp +8 -15
- package/src/duckdb/src/parallel/pipeline.cpp +67 -35
- package/src/duckdb/src/parallel/pipeline_executor.cpp +23 -23
- package/src/duckdb/src/parallel/pipeline_initialize_event.cpp +1 -1
- package/src/duckdb/src/parallel/task_scheduler.cpp +6 -6
- package/src/duckdb/src/parser/column_definition.cpp +6 -6
- package/src/duckdb/src/parser/common_table_expression_info.cpp +19 -0
- package/src/duckdb/src/parser/constraints/check_constraint.cpp +2 -2
- package/src/duckdb/src/parser/constraints/foreign_key_constraint.cpp +2 -2
- package/src/duckdb/src/parser/constraints/not_null_constraint.cpp +2 -2
- package/src/duckdb/src/parser/constraints/unique_constraint.cpp +4 -4
- package/src/duckdb/src/parser/expression/between_expression.cpp +19 -2
- package/src/duckdb/src/parser/expression/case_expression.cpp +30 -2
- package/src/duckdb/src/parser/expression/cast_expression.cpp +19 -2
- package/src/duckdb/src/parser/expression/collate_expression.cpp +18 -2
- package/src/duckdb/src/parser/expression/columnref_expression.cpp +19 -7
- package/src/duckdb/src/parser/expression/comparison_expression.cpp +18 -2
- package/src/duckdb/src/parser/expression/conjunction_expression.cpp +20 -3
- package/src/duckdb/src/parser/expression/constant_expression.cpp +17 -3
- package/src/duckdb/src/parser/expression/default_expression.cpp +9 -2
- package/src/duckdb/src/parser/expression/function_expression.cpp +42 -6
- package/src/duckdb/src/parser/expression/lambda_expression.cpp +18 -2
- package/src/duckdb/src/parser/expression/operator_expression.cpp +17 -2
- package/src/duckdb/src/parser/expression/parameter_expression.cpp +17 -2
- package/src/duckdb/src/parser/expression/positional_reference_expression.cpp +16 -2
- package/src/duckdb/src/parser/expression/star_expression.cpp +30 -8
- package/src/duckdb/src/parser/expression/subquery_expression.cpp +22 -2
- package/src/duckdb/src/parser/expression/window_expression.cpp +72 -2
- package/src/duckdb/src/parser/expression_util.cpp +6 -6
- package/src/duckdb/src/parser/parsed_data/alter_scalar_function_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/alter_table_function_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +27 -28
- package/src/duckdb/src/parser/parsed_data/create_aggregate_function_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/create_collation_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/create_copy_function_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_pragma_function_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/create_scalar_function_info.cpp +3 -3
- package/src/duckdb/src/parser/parsed_data/create_table_function_info.cpp +3 -3
- package/src/duckdb/src/parser/parsed_data/create_table_info.cpp +2 -2
- package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +3 -3
- package/src/duckdb/src/parser/parsed_data/sample_options.cpp +24 -12
- package/src/duckdb/src/parser/parsed_expression.cpp +72 -0
- package/src/duckdb/src/parser/parsed_expression_iterator.cpp +26 -20
- package/src/duckdb/src/parser/parser.cpp +12 -12
- package/src/duckdb/src/parser/query_node/recursive_cte_node.cpp +27 -6
- package/src/duckdb/src/parser/query_node/select_node.cpp +43 -12
- package/src/duckdb/src/parser/query_node/set_operation_node.cpp +23 -6
- package/src/duckdb/src/parser/query_node.cpp +54 -4
- package/src/duckdb/src/parser/result_modifier.cpp +97 -8
- package/src/duckdb/src/parser/statement/copy_statement.cpp +1 -1
- package/src/duckdb/src/parser/statement/drop_statement.cpp +1 -1
- package/src/duckdb/src/parser/statement/extension_statement.cpp +1 -1
- package/src/duckdb/src/parser/statement/insert_statement.cpp +1 -1
- package/src/duckdb/src/parser/statement/pragma_statement.cpp +1 -1
- package/src/duckdb/src/parser/statement/select_statement.cpp +59 -3
- package/src/duckdb/src/parser/statement/show_statement.cpp +1 -1
- package/src/duckdb/src/parser/statement/transaction_statement.cpp +2 -2
- package/src/duckdb/src/parser/statement/vacuum_statement.cpp +1 -1
- package/src/duckdb/src/parser/tableref/basetableref.cpp +23 -2
- package/src/duckdb/src/parser/tableref/emptytableref.cpp +6 -2
- package/src/duckdb/src/parser/tableref/expressionlistref.cpp +19 -2
- package/src/duckdb/src/parser/tableref/joinref.cpp +31 -2
- package/src/duckdb/src/parser/tableref/pivotref.cpp +88 -11
- package/src/duckdb/src/parser/tableref/subqueryref.cpp +17 -2
- package/src/duckdb/src/parser/tableref/table_function.cpp +19 -2
- package/src/duckdb/src/parser/tableref.cpp +46 -0
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +7 -7
- package/src/duckdb/src/parser/transform/expression/transform_array_access.cpp +16 -5
- package/src/duckdb/src/parser/transform/expression/transform_bool_expr.cpp +6 -6
- package/src/duckdb/src/parser/transform/expression/transform_boolean_test.cpp +39 -0
- package/src/duckdb/src/parser/transform/expression/transform_case.cpp +3 -3
- package/src/duckdb/src/parser/transform/expression/transform_cast.cpp +2 -2
- package/src/duckdb/src/parser/transform/expression/transform_coalesce.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +19 -4
- package/src/duckdb/src/parser/transform/expression/transform_constant.cpp +7 -7
- package/src/duckdb/src/parser/transform/expression/transform_expression.cpp +5 -2
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +96 -119
- package/src/duckdb/src/parser/transform/expression/transform_grouping_function.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_interval.cpp +5 -5
- package/src/duckdb/src/parser/transform/expression/transform_lambda.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +29 -25
- package/src/duckdb/src/parser/transform/expression/transform_param_ref.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_positional_reference.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_subquery.cpp +11 -11
- package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +5 -5
- package/src/duckdb/src/parser/transform/helpers/transform_groupby.cpp +11 -4
- package/src/duckdb/src/parser/transform/helpers/transform_orderby.cpp +0 -7
- package/src/duckdb/src/parser/transform/helpers/transform_sample.cpp +1 -1
- package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +3 -2
- package/src/duckdb/src/parser/transform/statement/transform_alter_sequence.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +10 -10
- package/src/duckdb/src/parser/transform/statement/transform_attach.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_call.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_checkpoint.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_create_database.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +4 -4
- package/src/duckdb/src/parser/transform/statement/transform_create_index.cpp +4 -4
- package/src/duckdb/src/parser/transform/statement/transform_create_schema.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_create_sequence.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_create_table.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_create_table_as.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +2 -3
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_delete.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_detach.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_drop.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_explain.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_export.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_import.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_load.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +57 -25
- package/src/duckdb/src/parser/transform/statement/transform_pragma.cpp +7 -7
- package/src/duckdb/src/parser/transform/statement/transform_prepare.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_rename.cpp +7 -8
- package/src/duckdb/src/parser/transform/statement/transform_select.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +27 -28
- package/src/duckdb/src/parser/transform/statement/transform_set.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_show.cpp +5 -5
- package/src/duckdb/src/parser/transform/statement/transform_show_select.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_transaction.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_update.cpp +2 -2
- package/src/duckdb/src/parser/transform/statement/transform_upsert.cpp +3 -3
- package/src/duckdb/src/parser/transform/statement/transform_use.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_vacuum.cpp +1 -1
- package/src/duckdb/src/parser/transform/tableref/transform_base_tableref.cpp +1 -1
- package/src/duckdb/src/parser/transform/tableref/transform_from.cpp +3 -3
- package/src/duckdb/src/parser/transform/tableref/transform_join.cpp +13 -2
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +23 -7
- package/src/duckdb/src/parser/transform/tableref/transform_subquery.cpp +2 -2
- package/src/duckdb/src/parser/transform/tableref/transform_table_function.cpp +1 -1
- package/src/duckdb/src/parser/transformer.cpp +54 -12
- package/src/duckdb/src/planner/bind_context.cpp +96 -96
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +14 -12
- package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +8 -8
- package/src/duckdb/src/planner/binder/expression/bind_case_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +59 -15
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_conjunction_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_constant_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +32 -22
- package/src/duckdb/src/planner/binder/expression/bind_lambda.cpp +12 -11
- package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +4 -4
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +15 -2
- package/src/duckdb/src/planner/binder/expression/bind_parameter_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +176 -0
- package/src/duckdb/src/planner/binder/expression/bind_subquery_expression.cpp +8 -4
- package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +163 -24
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +6 -6
- package/src/duckdb/src/planner/binder/query_node/bind_recursive_cte_node.cpp +1 -1
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +134 -133
- package/src/duckdb/src/planner/binder/query_node/bind_setop_node.cpp +18 -18
- package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +2 -2
- package/src/duckdb/src/planner/binder/query_node/plan_query_node.cpp +17 -6
- package/src/duckdb/src/planner/binder/query_node/plan_recursive_cte_node.cpp +4 -5
- package/src/duckdb/src/planner/binder/query_node/plan_select_node.cpp +20 -17
- package/src/duckdb/src/planner/binder/query_node/plan_setop.cpp +6 -7
- package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +29 -31
- package/src/duckdb/src/planner/binder/statement/bind_attach.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_call.cpp +3 -2
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +28 -16
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +49 -50
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +31 -23
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +9 -9
- package/src/duckdb/src/planner/binder/statement/bind_detach.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_execute.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_explain.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +25 -26
- package/src/duckdb/src/planner/binder/statement/bind_extension.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +39 -36
- package/src/duckdb/src/planner/binder/statement/bind_load.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_pragma.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_prepare.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_set.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_show.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_summarize.cpp +28 -28
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +27 -25
- package/src/duckdb/src/planner/binder/statement/bind_vacuum.cpp +10 -9
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +37 -34
- package/src/duckdb/src/planner/binder/tableref/bind_emptytableref.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_expressionlistref.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +45 -27
- package/src/duckdb/src/planner/binder/tableref/bind_named_parameters.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +324 -98
- package/src/duckdb/src/planner/binder/tableref/bind_subqueryref.cpp +7 -7
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +37 -18
- package/src/duckdb/src/planner/binder/tableref/plan_cteref.cpp +2 -1
- package/src/duckdb/src/planner/binder/tableref/plan_dummytableref.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/plan_expressionlistref.cpp +2 -2
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +74 -26
- package/src/duckdb/src/planner/binder/tableref/plan_pivotref.cpp +13 -0
- package/src/duckdb/src/planner/binder.cpp +85 -94
- package/src/duckdb/src/planner/bound_result_modifier.cpp +27 -1
- package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +20 -13
- package/src/duckdb/src/planner/expression/bound_between_expression.cpp +9 -9
- package/src/duckdb/src/planner/expression/bound_case_expression.cpp +3 -3
- package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +8 -9
- package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +4 -4
- package/src/duckdb/src/planner/expression/bound_comparison_expression.cpp +5 -6
- package/src/duckdb/src/planner/expression/bound_conjunction_expression.cpp +4 -4
- package/src/duckdb/src/planner/expression/bound_constant_expression.cpp +4 -4
- package/src/duckdb/src/planner/expression/bound_expression.cpp +4 -0
- package/src/duckdb/src/planner/expression/bound_function_expression.cpp +8 -8
- package/src/duckdb/src/planner/expression/bound_lambda_expression.cpp +5 -5
- package/src/duckdb/src/planner/expression/bound_lambdaref_expression.cpp +5 -5
- package/src/duckdb/src/planner/expression/bound_operator_expression.cpp +4 -4
- package/src/duckdb/src/planner/expression/bound_parameter_expression.cpp +5 -5
- package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +4 -4
- package/src/duckdb/src/planner/expression/bound_unnest_expression.cpp +4 -4
- package/src/duckdb/src/planner/expression/bound_window_expression.cpp +21 -22
- package/src/duckdb/src/planner/expression_binder/alter_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +146 -0
- package/src/duckdb/src/planner/expression_binder/check_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/constant_binder.cpp +11 -1
- package/src/duckdb/src/planner/expression_binder/group_binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/having_binder.cpp +7 -4
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +4 -3
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/order_binder.cpp +8 -8
- package/src/duckdb/src/planner/expression_binder/qualify_binder.cpp +5 -4
- package/src/duckdb/src/planner/expression_binder/select_binder.cpp +1 -132
- package/src/duckdb/src/planner/expression_binder/table_function_binder.cpp +8 -4
- package/src/duckdb/src/planner/expression_binder/where_binder.cpp +3 -2
- package/src/duckdb/src/planner/expression_binder.cpp +41 -42
- package/src/duckdb/src/planner/expression_iterator.cpp +34 -27
- package/src/duckdb/src/planner/filter/conjunction_filter.cpp +2 -2
- package/src/duckdb/src/planner/filter/constant_filter.cpp +5 -7
- package/src/duckdb/src/planner/filter/null_filter.cpp +2 -2
- package/src/duckdb/src/planner/joinside.cpp +5 -5
- package/src/duckdb/src/planner/logical_operator.cpp +10 -2
- package/src/duckdb/src/planner/logical_operator_visitor.cpp +32 -26
- package/src/duckdb/src/planner/operator/logical_aggregate.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_any_join.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_asof_join.cpp +14 -0
- package/src/duckdb/src/planner/operator/logical_column_data_get.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +3 -3
- package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +4 -4
- package/src/duckdb/src/planner/operator/logical_create.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_create_index.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_create_table.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_cross_product.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_cteref.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_delete.cpp +5 -5
- package/src/duckdb/src/planner/operator/logical_delim_get.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_delim_join.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_distinct.cpp +6 -1
- package/src/duckdb/src/planner/operator/logical_dummy_scan.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_expression_get.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_filter.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_get.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_insert.cpp +6 -7
- package/src/duckdb/src/planner/operator/logical_join.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_limit.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_limit_percent.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_order.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_pivot.cpp +35 -0
- package/src/duckdb/src/planner/operator/logical_positional_join.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_projection.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_reset.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_sample.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_set.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_simple.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_top_n.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_unnest.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_update.cpp +6 -7
- package/src/duckdb/src/planner/operator/logical_window.cpp +1 -1
- package/src/duckdb/src/planner/parsed_data/bound_create_table_info.cpp +4 -5
- package/src/duckdb/src/planner/planner.cpp +2 -1
- package/src/duckdb/src/planner/pragma_handler.cpp +9 -7
- package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +64 -60
- package/src/duckdb/src/planner/subquery/rewrite_correlated_expressions.cpp +5 -6
- package/src/duckdb/src/planner/table_binding.cpp +18 -17
- package/src/duckdb/src/planner/table_filter.cpp +2 -2
- package/src/duckdb/src/storage/arena_allocator.cpp +34 -2
- package/src/duckdb/src/storage/buffer/block_handle.cpp +129 -0
- package/src/duckdb/src/storage/buffer/block_manager.cpp +83 -0
- package/src/duckdb/src/storage/buffer/buffer_handle.cpp +1 -0
- package/src/duckdb/src/storage/buffer/buffer_pool.cpp +136 -0
- package/src/duckdb/src/storage/buffer/buffer_pool_reservation.cpp +35 -0
- package/src/duckdb/src/storage/buffer_manager.cpp +35 -1077
- package/src/duckdb/src/storage/checkpoint/row_group_writer.cpp +1 -1
- package/src/duckdb/src/storage/checkpoint/table_data_reader.cpp +5 -16
- package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +13 -7
- package/src/duckdb/src/storage/checkpoint_manager.cpp +38 -32
- package/src/duckdb/src/storage/compression/bitpacking.cpp +12 -13
- package/src/duckdb/src/storage/compression/dictionary_compression.cpp +11 -12
- package/src/duckdb/src/storage/compression/fixed_size_uncompressed.cpp +9 -8
- package/src/duckdb/src/storage/compression/fsst.cpp +12 -14
- package/src/duckdb/src/storage/compression/numeric_constant.cpp +10 -11
- package/src/duckdb/src/storage/compression/patas.cpp +1 -1
- package/src/duckdb/src/storage/compression/rle.cpp +10 -11
- package/src/duckdb/src/storage/compression/string_uncompressed.cpp +6 -6
- package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +9 -9
- package/src/duckdb/src/storage/data_table.cpp +50 -50
- package/src/duckdb/src/storage/index.cpp +17 -7
- package/src/duckdb/src/storage/local_storage.cpp +98 -91
- package/src/duckdb/src/storage/meta_block_reader.cpp +23 -0
- package/src/duckdb/src/storage/single_file_block_manager.cpp +2 -2
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +801 -0
- package/src/duckdb/src/storage/statistics/base_statistics.cpp +373 -128
- package/src/duckdb/src/storage/statistics/column_statistics.cpp +57 -3
- package/src/duckdb/src/storage/statistics/distinct_statistics.cpp +10 -11
- package/src/duckdb/src/storage/statistics/list_stats.cpp +121 -0
- package/src/duckdb/src/storage/statistics/numeric_stats.cpp +591 -0
- package/src/duckdb/src/storage/statistics/numeric_stats_union.cpp +65 -0
- package/src/duckdb/src/storage/statistics/segment_statistics.cpp +2 -11
- package/src/duckdb/src/storage/statistics/string_stats.cpp +273 -0
- package/src/duckdb/src/storage/statistics/struct_stats.cpp +133 -0
- package/src/duckdb/src/storage/storage_info.cpp +2 -2
- package/src/duckdb/src/storage/storage_lock.cpp +2 -2
- package/src/duckdb/src/storage/storage_manager.cpp +20 -21
- package/src/duckdb/src/storage/table/chunk_info.cpp +2 -2
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +7 -13
- package/src/duckdb/src/storage/table/column_data.cpp +123 -70
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +28 -15
- package/src/duckdb/src/storage/table/column_segment.cpp +55 -71
- package/src/duckdb/src/storage/table/list_column_data.cpp +21 -27
- package/src/duckdb/src/storage/table/persistent_table_data.cpp +2 -1
- package/src/duckdb/src/storage/table/row_group.cpp +222 -152
- package/src/duckdb/src/storage/table/row_group_collection.cpp +154 -108
- package/src/duckdb/src/storage/table/scan_state.cpp +46 -34
- package/src/duckdb/src/storage/table/standard_column_data.cpp +13 -14
- package/src/duckdb/src/storage/table/struct_column_data.cpp +30 -37
- package/src/duckdb/src/storage/table/table_statistics.cpp +28 -8
- package/src/duckdb/src/storage/table/update_segment.cpp +41 -36
- package/src/duckdb/src/storage/table_index_list.cpp +3 -3
- package/src/duckdb/src/storage/wal_replay.cpp +11 -8
- package/src/duckdb/src/storage/write_ahead_log.cpp +47 -47
- package/src/duckdb/src/transaction/cleanup_state.cpp +10 -10
- package/src/duckdb/src/transaction/commit_state.cpp +66 -62
- package/src/duckdb/src/transaction/duck_transaction.cpp +9 -9
- package/src/duckdb/src/transaction/duck_transaction_manager.cpp +4 -4
- package/src/duckdb/src/transaction/meta_transaction.cpp +13 -13
- package/src/duckdb/src/transaction/rollback_state.cpp +2 -2
- package/src/duckdb/src/transaction/transaction.cpp +1 -1
- package/src/duckdb/src/transaction/transaction_context.cpp +2 -2
- package/src/duckdb/src/transaction/undo_buffer.cpp +2 -1
- package/src/duckdb/src/verification/copied_statement_verifier.cpp +1 -1
- package/src/duckdb/src/verification/deserialized_statement_verifier.cpp +2 -3
- package/src/duckdb/src/verification/external_statement_verifier.cpp +1 -1
- package/src/duckdb/src/verification/parsed_statement_verifier.cpp +1 -1
- package/src/duckdb/src/verification/prepared_statement_verifier.cpp +7 -7
- package/src/duckdb/src/verification/statement_verifier.cpp +3 -3
- package/src/duckdb/src/verification/unoptimized_statement_verifier.cpp +1 -1
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +32 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +2 -1
- package/src/duckdb/third_party/libpg_query/include/nodes/primnodes.hpp +3 -3
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +949 -961
- package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +4 -11
- package/src/duckdb/third_party/libpg_query/include/postgres_parser.hpp +3 -2
- package/src/duckdb/third_party/libpg_query/postgres_parser.cpp +5 -6
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +18328 -17747
- package/src/duckdb/third_party/libpg_query/src_backend_parser_scan.cpp +503 -493
- package/src/duckdb/third_party/parquet/parquet_types.cpp +32 -32
- package/src/duckdb/third_party/parquet/parquet_types.h +34 -32
- package/src/duckdb/third_party/re2/re2/re2.cc +9 -0
- package/src/duckdb/third_party/re2/re2/re2.h +2 -0
- package/src/duckdb/third_party/thrift/thrift/TToString.h +3 -3
- package/src/duckdb/third_party/thrift/thrift/protocol/TProtocol.h +1 -1
- package/src/duckdb/third_party/thrift/thrift/protocol/TProtocolDecorator.h +2 -1
- package/src/duckdb/third_party/thrift/thrift/protocol/TVirtualProtocol.h +5 -4
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +5 -5
- package/src/duckdb/ub_extension_json_json_functions.cpp +2 -0
- package/src/duckdb/ub_src_common.cpp +6 -0
- package/src/duckdb/ub_src_common_adbc.cpp +4 -0
- package/src/duckdb/ub_src_common_serializer.cpp +2 -0
- package/src/duckdb/ub_src_common_sort.cpp +2 -0
- package/src/duckdb/ub_src_common_types.cpp +1 -15
- package/src/duckdb/ub_src_common_types_column.cpp +10 -0
- package/src/duckdb/ub_src_common_types_row.cpp +20 -0
- package/src/duckdb/ub_src_execution_operator_projection.cpp +2 -0
- package/src/duckdb/ub_src_execution_physical_plan.cpp +4 -0
- package/src/duckdb/ub_src_function_scalar_generic.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_string.cpp +4 -0
- package/src/duckdb/ub_src_function_scalar_string_regexp.cpp +4 -0
- package/src/duckdb/ub_src_optimizer_rule.cpp +2 -0
- package/src/duckdb/ub_src_parser.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_expression.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_expression.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_tableref.cpp +2 -0
- package/src/duckdb/ub_src_planner_expression_binder.cpp +2 -0
- package/src/duckdb/ub_src_planner_operator.cpp +4 -0
- package/src/duckdb/ub_src_storage.cpp +2 -0
- package/src/duckdb/ub_src_storage_buffer.cpp +8 -0
- package/src/duckdb/ub_src_storage_statistics.cpp +6 -6
- package/src/duckdb/ub_src_storage_table.cpp +0 -2
- package/src/duckdb_node.hpp +15 -10
- package/src/statement.cpp +28 -24
- package/src/utils.cpp +27 -2
- package/test/extension.test.ts +44 -26
- package/test/syntax_error.test.ts +3 -1
- package/test/udf.test.ts +9 -0
- package/filelist.cache +0 -0
- package/src/duckdb/extension/parquet/include/generated_column_reader.hpp +0 -65
- package/src/duckdb/src/include/duckdb/common/single_thread_ptr.hpp +0 -183
- package/src/duckdb/src/include/duckdb/storage/statistics/list_statistics.hpp +0 -36
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_statistics.hpp +0 -75
- package/src/duckdb/src/include/duckdb/storage/statistics/string_statistics.hpp +0 -49
- package/src/duckdb/src/include/duckdb/storage/statistics/struct_statistics.hpp +0 -36
- package/src/duckdb/src/include/duckdb/storage/statistics/validity_statistics.hpp +0 -45
- package/src/duckdb/src/storage/statistics/list_statistics.cpp +0 -94
- package/src/duckdb/src/storage/statistics/numeric_statistics.cpp +0 -307
- package/src/duckdb/src/storage/statistics/string_statistics.cpp +0 -220
- package/src/duckdb/src/storage/statistics/struct_statistics.cpp +0 -108
- package/src/duckdb/src/storage/statistics/validity_statistics.cpp +0 -91
- package/src/duckdb/src/storage/table/segment_tree.cpp +0 -179
@@ -2,11 +2,13 @@
|
|
2
2
|
|
3
3
|
#include "duckdb/common/operator/cast_operators.hpp"
|
4
4
|
#include "duckdb/common/operator/comparison_operators.hpp"
|
5
|
+
#include "duckdb/common/optional_ptr.hpp"
|
6
|
+
#include "duckdb/common/radix_partitioning.hpp"
|
5
7
|
#include "duckdb/common/row_operations/row_operations.hpp"
|
6
|
-
#include "duckdb/common/sort/
|
8
|
+
#include "duckdb/common/sort/partition_state.hpp"
|
7
9
|
#include "duckdb/common/types/chunk_collection.hpp"
|
8
|
-
#include "duckdb/common/types/column_data_consumer.hpp"
|
9
|
-
#include "duckdb/common/types/row_data_collection_scanner.hpp"
|
10
|
+
#include "duckdb/common/types/column/column_data_consumer.hpp"
|
11
|
+
#include "duckdb/common/types/row/row_data_collection_scanner.hpp"
|
10
12
|
#include "duckdb/common/vector_operations/vector_operations.hpp"
|
11
13
|
#include "duckdb/common/windows_undefs.hpp"
|
12
14
|
#include "duckdb/execution/expression_executor.hpp"
|
@@ -17,7 +19,6 @@
|
|
17
19
|
#include "duckdb/parallel/base_pipeline_event.hpp"
|
18
20
|
#include "duckdb/planner/expression/bound_reference_expression.hpp"
|
19
21
|
#include "duckdb/planner/expression/bound_window_expression.hpp"
|
20
|
-
#include "duckdb/common/radix_partitioning.hpp"
|
21
22
|
|
22
23
|
#include <algorithm>
|
23
24
|
#include <cmath>
|
@@ -25,427 +26,41 @@
|
|
25
26
|
|
26
27
|
namespace duckdb {
|
27
28
|
|
28
|
-
class WindowGlobalHashGroup {
|
29
|
-
public:
|
30
|
-
using GlobalSortStatePtr = unique_ptr<GlobalSortState>;
|
31
|
-
using LocalSortStatePtr = unique_ptr<LocalSortState>;
|
32
|
-
using Orders = vector<BoundOrderByNode>;
|
33
|
-
using Types = vector<LogicalType>;
|
34
|
-
|
35
|
-
WindowGlobalHashGroup(BufferManager &buffer_manager, const Orders &partitions, const Orders &orders,
|
36
|
-
const Types &payload_types, bool external)
|
37
|
-
: count(0) {
|
38
|
-
|
39
|
-
RowLayout payload_layout;
|
40
|
-
payload_layout.Initialize(payload_types);
|
41
|
-
global_sort = make_unique<GlobalSortState>(buffer_manager, orders, payload_layout);
|
42
|
-
global_sort->external = external;
|
43
|
-
|
44
|
-
partition_layout = global_sort->sort_layout.GetPrefixComparisonLayout(partitions.size());
|
45
|
-
}
|
46
|
-
|
47
|
-
void ComputeMasks(ValidityMask &partition_mask, ValidityMask &order_mask);
|
48
|
-
|
49
|
-
GlobalSortStatePtr global_sort;
|
50
|
-
atomic<idx_t> count;
|
51
|
-
|
52
|
-
// Mask computation
|
53
|
-
SortLayout partition_layout;
|
54
|
-
};
|
55
|
-
|
56
|
-
void WindowGlobalHashGroup::ComputeMasks(ValidityMask &partition_mask, ValidityMask &order_mask) {
|
57
|
-
D_ASSERT(count > 0);
|
58
|
-
|
59
|
-
// Set up a comparator for the partition subset
|
60
|
-
const auto partition_size = partition_layout.comparison_size;
|
61
|
-
|
62
|
-
SBIterator prev(*global_sort, ExpressionType::COMPARE_LESSTHAN);
|
63
|
-
SBIterator curr(*global_sort, ExpressionType::COMPARE_LESSTHAN);
|
64
|
-
|
65
|
-
partition_mask.SetValidUnsafe(0);
|
66
|
-
order_mask.SetValidUnsafe(0);
|
67
|
-
for (++curr; curr.GetIndex() < count; ++curr) {
|
68
|
-
// Compare the partition subset first because if that differs, then so does the full ordering
|
69
|
-
int part_cmp = 0;
|
70
|
-
if (partition_layout.all_constant) {
|
71
|
-
part_cmp = FastMemcmp(prev.entry_ptr, curr.entry_ptr, partition_size);
|
72
|
-
} else {
|
73
|
-
part_cmp = Comparators::CompareTuple(prev.scan, curr.scan, prev.entry_ptr, curr.entry_ptr, partition_layout,
|
74
|
-
prev.external);
|
75
|
-
}
|
76
|
-
|
77
|
-
if (part_cmp) {
|
78
|
-
partition_mask.SetValidUnsafe(curr.GetIndex());
|
79
|
-
order_mask.SetValidUnsafe(curr.GetIndex());
|
80
|
-
} else if (prev.Compare(curr)) {
|
81
|
-
order_mask.SetValidUnsafe(curr.GetIndex());
|
82
|
-
}
|
83
|
-
++prev;
|
84
|
-
}
|
85
|
-
}
|
86
|
-
|
87
29
|
// Global sink state
|
88
30
|
class WindowGlobalSinkState : public GlobalSinkState {
|
89
31
|
public:
|
90
|
-
|
91
|
-
|
92
|
-
using Types = vector<LogicalType>;
|
93
|
-
|
94
|
-
using GroupingPartition = unique_ptr<PartitionedColumnData>;
|
95
|
-
using GroupingAppend = unique_ptr<PartitionedColumnDataAppendState>;
|
96
|
-
|
97
|
-
WindowGlobalSinkState(const PhysicalWindow &op_p, ClientContext &context)
|
98
|
-
: op(op_p), context(context), buffer_manager(BufferManager::GetBufferManager(context)),
|
99
|
-
allocator(Allocator::Get(context)), payload_types(op.children[0]->types), memory_per_thread(0), count(0),
|
100
|
-
mode(DBConfig::GetConfig(context).options.window_mode) {
|
32
|
+
WindowGlobalSinkState(const PhysicalWindow &op, ClientContext &context)
|
33
|
+
: mode(DBConfig::GetConfig(context).options.window_mode) {
|
101
34
|
|
102
35
|
D_ASSERT(op.select_list[0]->GetExpressionClass() == ExpressionClass::BOUND_WINDOW);
|
103
|
-
auto wexpr =
|
104
|
-
|
105
|
-
// we sort by both 1) partition by expression list and 2) order by expressions
|
106
|
-
const auto partition_cols = wexpr->partitions.size();
|
107
|
-
for (idx_t prt_idx = 0; prt_idx < partition_cols; prt_idx++) {
|
108
|
-
auto &pexpr = wexpr->partitions[prt_idx];
|
36
|
+
auto &wexpr = op.select_list[0]->Cast<BoundWindowExpression>();
|
109
37
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
orders.emplace_back(OrderType::ASCENDING, OrderByNullType::NULLS_FIRST, pexpr->Copy(),
|
114
|
-
wexpr->partitions_stats[prt_idx]->Copy());
|
115
|
-
}
|
116
|
-
partitions.emplace_back(orders.back().Copy());
|
117
|
-
}
|
118
|
-
|
119
|
-
for (const auto &order : wexpr->orders) {
|
120
|
-
orders.emplace_back(order.Copy());
|
121
|
-
}
|
122
|
-
|
123
|
-
memory_per_thread = op.GetMaxThreadMemory(context);
|
124
|
-
external = ClientConfig::GetConfig(context).force_external;
|
125
|
-
|
126
|
-
if (!orders.empty()) {
|
127
|
-
grouping_types = payload_types;
|
128
|
-
grouping_types.push_back(LogicalType::HASH);
|
129
|
-
|
130
|
-
ResizeGroupingData(op.estimated_cardinality);
|
131
|
-
}
|
38
|
+
global_partition =
|
39
|
+
make_uniq<PartitionGlobalSinkState>(context, wexpr.partitions, wexpr.orders, op.children[0]->types,
|
40
|
+
wexpr.partitions_stats, op.estimated_cardinality);
|
132
41
|
}
|
133
42
|
|
134
|
-
|
135
|
-
void CombineLocalPartition(GroupingPartition &local_partition, GroupingAppend &local_append);
|
136
|
-
|
137
|
-
void BuildSortState(ColumnDataCollection &group_data, WindowGlobalHashGroup &global_sort);
|
138
|
-
|
139
|
-
const PhysicalWindow &op;
|
140
|
-
ClientContext &context;
|
141
|
-
BufferManager &buffer_manager;
|
142
|
-
Allocator &allocator;
|
143
|
-
mutex lock;
|
144
|
-
|
145
|
-
// OVER(PARTITION BY...) (hash grouping)
|
146
|
-
unique_ptr<RadixPartitionedColumnData> grouping_data;
|
147
|
-
//! Payload plus hash column
|
148
|
-
Types grouping_types;
|
149
|
-
|
150
|
-
// OVER(...) (sorting)
|
151
|
-
Orders partitions;
|
152
|
-
Orders orders;
|
153
|
-
const Types payload_types;
|
154
|
-
vector<HashGroupPtr> hash_groups;
|
155
|
-
bool external;
|
156
|
-
|
157
|
-
// OVER() (no sorting)
|
158
|
-
unique_ptr<RowDataCollection> rows;
|
159
|
-
unique_ptr<RowDataCollection> strings;
|
160
|
-
|
161
|
-
// Threading
|
162
|
-
idx_t memory_per_thread;
|
163
|
-
atomic<idx_t> count;
|
43
|
+
unique_ptr<PartitionGlobalSinkState> global_partition;
|
164
44
|
WindowAggregationMode mode;
|
165
|
-
|
166
|
-
private:
|
167
|
-
void ResizeGroupingData(idx_t cardinality);
|
168
|
-
void SyncLocalPartition(GroupingPartition &local_partition, GroupingAppend &local_append);
|
169
45
|
};
|
170
46
|
|
171
|
-
void WindowGlobalSinkState::ResizeGroupingData(idx_t cardinality) {
|
172
|
-
// Have we started to combine? Then just live with it.
|
173
|
-
if (grouping_data && !grouping_data->GetPartitions().empty()) {
|
174
|
-
return;
|
175
|
-
}
|
176
|
-
// Is the average partition size too large?
|
177
|
-
const idx_t partition_size = STANDARD_ROW_GROUPS_SIZE;
|
178
|
-
const auto bits = grouping_data ? grouping_data->GetRadixBits() : 0;
|
179
|
-
auto new_bits = bits ? bits : 4;
|
180
|
-
while (new_bits < 10 && (cardinality / RadixPartitioning::NumberOfPartitions(new_bits)) > partition_size) {
|
181
|
-
++new_bits;
|
182
|
-
}
|
183
|
-
|
184
|
-
// Repartition the grouping data
|
185
|
-
if (new_bits != bits) {
|
186
|
-
const auto hash_col_idx = payload_types.size();
|
187
|
-
grouping_data = make_unique<RadixPartitionedColumnData>(context, grouping_types, new_bits, hash_col_idx);
|
188
|
-
}
|
189
|
-
}
|
190
|
-
|
191
|
-
void WindowGlobalSinkState::SyncLocalPartition(GroupingPartition &local_partition, GroupingAppend &local_append) {
|
192
|
-
// We are done if the local_partition is right sized.
|
193
|
-
auto local_radix = (RadixPartitionedColumnData *)local_partition.get();
|
194
|
-
if (local_radix->GetRadixBits() == grouping_data->GetRadixBits()) {
|
195
|
-
return;
|
196
|
-
}
|
197
|
-
|
198
|
-
// If the local partition is now too small, flush it and reallocate
|
199
|
-
auto new_partition = grouping_data->CreateShared();
|
200
|
-
auto new_append = make_unique<PartitionedColumnDataAppendState>();
|
201
|
-
new_partition->InitializeAppendState(*new_append);
|
202
|
-
|
203
|
-
local_partition->FlushAppendState(*local_append);
|
204
|
-
auto &local_groups = local_partition->GetPartitions();
|
205
|
-
for (auto &local_group : local_groups) {
|
206
|
-
ColumnDataScanState scanner;
|
207
|
-
local_group->InitializeScan(scanner);
|
208
|
-
|
209
|
-
DataChunk scan_chunk;
|
210
|
-
local_group->InitializeScanChunk(scan_chunk);
|
211
|
-
for (scan_chunk.Reset(); local_group->Scan(scanner, scan_chunk); scan_chunk.Reset()) {
|
212
|
-
new_partition->Append(*new_append, scan_chunk);
|
213
|
-
}
|
214
|
-
}
|
215
|
-
|
216
|
-
// The append state has stale pointers to the old local partition, so nuke it from orbit.
|
217
|
-
new_partition->FlushAppendState(*new_append);
|
218
|
-
|
219
|
-
local_partition = std::move(new_partition);
|
220
|
-
local_append = make_unique<PartitionedColumnDataAppendState>();
|
221
|
-
local_partition->InitializeAppendState(*local_append);
|
222
|
-
}
|
223
|
-
|
224
|
-
void WindowGlobalSinkState::UpdateLocalPartition(GroupingPartition &local_partition, GroupingAppend &local_append) {
|
225
|
-
// Make sure grouping_data doesn't change under us.
|
226
|
-
lock_guard<mutex> guard(lock);
|
227
|
-
|
228
|
-
if (!local_partition) {
|
229
|
-
local_partition = grouping_data->CreateShared();
|
230
|
-
local_append = make_unique<PartitionedColumnDataAppendState>();
|
231
|
-
local_partition->InitializeAppendState(*local_append);
|
232
|
-
return;
|
233
|
-
}
|
234
|
-
|
235
|
-
// Grow the groups if they are too big
|
236
|
-
ResizeGroupingData(count);
|
237
|
-
|
238
|
-
// Sync local partition to have the same bit count
|
239
|
-
SyncLocalPartition(local_partition, local_append);
|
240
|
-
}
|
241
|
-
|
242
|
-
void WindowGlobalSinkState::CombineLocalPartition(GroupingPartition &local_partition, GroupingAppend &local_append) {
|
243
|
-
if (!local_partition) {
|
244
|
-
return;
|
245
|
-
}
|
246
|
-
local_partition->FlushAppendState(*local_append);
|
247
|
-
|
248
|
-
// Make sure grouping_data doesn't change under us.
|
249
|
-
// Combine has an internal mutex, so this is single-threaded anyway.
|
250
|
-
lock_guard<mutex> guard(lock);
|
251
|
-
SyncLocalPartition(local_partition, local_append);
|
252
|
-
grouping_data->Combine(*local_partition);
|
253
|
-
}
|
254
|
-
|
255
|
-
void WindowGlobalSinkState::BuildSortState(ColumnDataCollection &group_data, WindowGlobalHashGroup &hash_group) {
|
256
|
-
auto &global_sort = *hash_group.global_sort;
|
257
|
-
|
258
|
-
// Set up the sort expression computation.
|
259
|
-
vector<LogicalType> sort_types;
|
260
|
-
ExpressionExecutor executor(context);
|
261
|
-
for (auto &order : orders) {
|
262
|
-
auto &oexpr = order.expression;
|
263
|
-
sort_types.emplace_back(oexpr->return_type);
|
264
|
-
executor.AddExpression(*oexpr);
|
265
|
-
}
|
266
|
-
DataChunk sort_chunk;
|
267
|
-
sort_chunk.Initialize(allocator, sort_types);
|
268
|
-
|
269
|
-
// Copy the data from the group into the sort code.
|
270
|
-
LocalSortState local_sort;
|
271
|
-
local_sort.Initialize(global_sort, global_sort.buffer_manager);
|
272
|
-
|
273
|
-
// Strip hash column
|
274
|
-
DataChunk payload_chunk;
|
275
|
-
payload_chunk.Initialize(allocator, payload_types);
|
276
|
-
|
277
|
-
vector<column_t> column_ids;
|
278
|
-
column_ids.reserve(payload_types.size());
|
279
|
-
for (column_t i = 0; i < payload_types.size(); ++i) {
|
280
|
-
column_ids.emplace_back(i);
|
281
|
-
}
|
282
|
-
ColumnDataConsumer scanner(group_data, column_ids);
|
283
|
-
ColumnDataConsumerScanState chunk_state;
|
284
|
-
chunk_state.current_chunk_state.properties = ColumnDataScanProperties::ALLOW_ZERO_COPY;
|
285
|
-
scanner.InitializeScan();
|
286
|
-
for (auto chunk_idx = scanner.ChunkCount(); chunk_idx-- > 0;) {
|
287
|
-
if (!scanner.AssignChunk(chunk_state)) {
|
288
|
-
break;
|
289
|
-
}
|
290
|
-
scanner.ScanChunk(chunk_state, payload_chunk);
|
291
|
-
|
292
|
-
sort_chunk.Reset();
|
293
|
-
executor.Execute(payload_chunk, sort_chunk);
|
294
|
-
|
295
|
-
local_sort.SinkChunk(sort_chunk, payload_chunk);
|
296
|
-
if (local_sort.SizeInBytes() > memory_per_thread) {
|
297
|
-
local_sort.Sort(global_sort, true);
|
298
|
-
}
|
299
|
-
scanner.FinishChunk(chunk_state);
|
300
|
-
}
|
301
|
-
|
302
|
-
global_sort.AddLocalState(local_sort);
|
303
|
-
|
304
|
-
hash_group.count += group_data.Count();
|
305
|
-
}
|
306
|
-
|
307
47
|
// Per-thread sink state
|
308
48
|
class WindowLocalSinkState : public LocalSinkState {
|
309
49
|
public:
|
310
|
-
WindowLocalSinkState(ClientContext &context, const
|
311
|
-
:
|
312
|
-
D_ASSERT(op.select_list[0]->GetExpressionClass() == ExpressionClass::BOUND_WINDOW);
|
313
|
-
auto wexpr = reinterpret_cast<BoundWindowExpression *>(op.select_list[0].get());
|
314
|
-
|
315
|
-
vector<LogicalType> group_types;
|
316
|
-
for (idx_t prt_idx = 0; prt_idx < wexpr->partitions.size(); prt_idx++) {
|
317
|
-
auto &pexpr = wexpr->partitions[prt_idx];
|
318
|
-
group_types.push_back(pexpr->return_type);
|
319
|
-
executor.AddExpression(*pexpr);
|
320
|
-
}
|
321
|
-
sort_cols = wexpr->orders.size() + group_types.size();
|
322
|
-
|
323
|
-
if (sort_cols) {
|
324
|
-
if (!group_types.empty()) {
|
325
|
-
// OVER(PARTITION BY...)
|
326
|
-
group_chunk.Initialize(allocator, group_types);
|
327
|
-
}
|
328
|
-
// OVER(...)
|
329
|
-
auto payload_types = op.children[0]->types;
|
330
|
-
payload_types.emplace_back(LogicalType::HASH);
|
331
|
-
payload_chunk.Initialize(allocator, payload_types);
|
332
|
-
} else {
|
333
|
-
// OVER()
|
334
|
-
payload_layout.Initialize(op.children[0]->types);
|
335
|
-
}
|
50
|
+
WindowLocalSinkState(ClientContext &context, const WindowGlobalSinkState &gstate)
|
51
|
+
: local_partition(context, *gstate.global_partition) {
|
336
52
|
}
|
337
53
|
|
338
|
-
|
339
|
-
|
340
|
-
Allocator &allocator;
|
341
|
-
|
342
|
-
// OVER(PARTITION BY...) (hash grouping)
|
343
|
-
ExpressionExecutor executor;
|
344
|
-
DataChunk group_chunk;
|
345
|
-
DataChunk payload_chunk;
|
346
|
-
unique_ptr<PartitionedColumnData> local_partition;
|
347
|
-
unique_ptr<PartitionedColumnDataAppendState> local_append;
|
348
|
-
|
349
|
-
// OVER(...) (sorting)
|
350
|
-
size_t sort_cols;
|
351
|
-
|
352
|
-
// OVER() (no sorting)
|
353
|
-
RowLayout payload_layout;
|
354
|
-
unique_ptr<RowDataCollection> rows;
|
355
|
-
unique_ptr<RowDataCollection> strings;
|
356
|
-
|
357
|
-
//! Compute the hash values
|
358
|
-
void Hash(DataChunk &input_chunk, Vector &hash_vector);
|
359
|
-
//! Sink an input chunk
|
360
|
-
void Sink(DataChunk &input_chunk, WindowGlobalSinkState &gstate);
|
361
|
-
//! Merge the state into the global state.
|
362
|
-
void Combine(WindowGlobalSinkState &gstate);
|
363
|
-
};
|
364
|
-
|
365
|
-
void WindowLocalSinkState::Hash(DataChunk &input_chunk, Vector &hash_vector) {
|
366
|
-
const auto count = input_chunk.size();
|
367
|
-
if (group_chunk.ColumnCount() > 0) {
|
368
|
-
// OVER(PARTITION BY...) (hash grouping)
|
369
|
-
group_chunk.Reset();
|
370
|
-
executor.Execute(input_chunk, group_chunk);
|
371
|
-
VectorOperations::Hash(group_chunk.data[0], hash_vector, count);
|
372
|
-
for (idx_t prt_idx = 1; prt_idx < group_chunk.ColumnCount(); ++prt_idx) {
|
373
|
-
VectorOperations::CombineHash(hash_vector, group_chunk.data[prt_idx], count);
|
374
|
-
}
|
375
|
-
} else {
|
376
|
-
// OVER(...) (sorting)
|
377
|
-
// Single partition => single hash value
|
378
|
-
hash_vector.SetVectorType(VectorType::CONSTANT_VECTOR);
|
379
|
-
auto hashes = ConstantVector::GetData<hash_t>(hash_vector);
|
380
|
-
hashes[0] = 0;
|
54
|
+
void Sink(DataChunk &input_chunk) {
|
55
|
+
local_partition.Sink(input_chunk);
|
381
56
|
}
|
382
|
-
}
|
383
57
|
|
384
|
-
void
|
385
|
-
|
386
|
-
|
387
|
-
// OVER()
|
388
|
-
if (sort_cols == 0) {
|
389
|
-
// No sorts, so build paged row chunks
|
390
|
-
if (!rows) {
|
391
|
-
const auto entry_size = payload_layout.GetRowWidth();
|
392
|
-
const auto capacity = MaxValue<idx_t>(STANDARD_VECTOR_SIZE, (Storage::BLOCK_SIZE / entry_size) + 1);
|
393
|
-
rows = make_unique<RowDataCollection>(gstate.buffer_manager, capacity, entry_size);
|
394
|
-
strings = make_unique<RowDataCollection>(gstate.buffer_manager, (idx_t)Storage::BLOCK_SIZE, 1, true);
|
395
|
-
}
|
396
|
-
const auto row_count = input_chunk.size();
|
397
|
-
const auto row_sel = FlatVector::IncrementalSelectionVector();
|
398
|
-
Vector addresses(LogicalType::POINTER);
|
399
|
-
auto key_locations = FlatVector::GetData<data_ptr_t>(addresses);
|
400
|
-
const auto prev_rows_blocks = rows->blocks.size();
|
401
|
-
auto handles = rows->Build(row_count, key_locations, nullptr, row_sel);
|
402
|
-
auto input_data = input_chunk.ToUnifiedFormat();
|
403
|
-
RowOperations::Scatter(input_chunk, input_data.get(), payload_layout, addresses, *strings, *row_sel, row_count);
|
404
|
-
// Mark that row blocks contain pointers (heap blocks are pinned)
|
405
|
-
if (!payload_layout.AllConstant()) {
|
406
|
-
D_ASSERT(strings->keep_pinned);
|
407
|
-
for (size_t i = prev_rows_blocks; i < rows->blocks.size(); ++i) {
|
408
|
-
rows->blocks[i]->block->SetSwizzling("WindowLocalSinkState::Sink");
|
409
|
-
}
|
410
|
-
}
|
411
|
-
return;
|
412
|
-
}
|
413
|
-
|
414
|
-
// OVER(...)
|
415
|
-
payload_chunk.Reset();
|
416
|
-
auto &hash_vector = payload_chunk.data.back();
|
417
|
-
Hash(input_chunk, hash_vector);
|
418
|
-
for (idx_t col_idx = 0; col_idx < input_chunk.ColumnCount(); ++col_idx) {
|
419
|
-
payload_chunk.data[col_idx].Reference(input_chunk.data[col_idx]);
|
420
|
-
}
|
421
|
-
payload_chunk.SetCardinality(input_chunk);
|
422
|
-
|
423
|
-
gstate.UpdateLocalPartition(local_partition, local_append);
|
424
|
-
local_partition->Append(*local_append, payload_chunk);
|
425
|
-
}
|
426
|
-
|
427
|
-
void WindowLocalSinkState::Combine(WindowGlobalSinkState &gstate) {
|
428
|
-
// OVER()
|
429
|
-
if (sort_cols == 0) {
|
430
|
-
// Only one partition again, so need a global lock.
|
431
|
-
lock_guard<mutex> glock(gstate.lock);
|
432
|
-
if (gstate.rows) {
|
433
|
-
if (rows) {
|
434
|
-
gstate.rows->Merge(*rows);
|
435
|
-
gstate.strings->Merge(*strings);
|
436
|
-
rows.reset();
|
437
|
-
strings.reset();
|
438
|
-
}
|
439
|
-
} else {
|
440
|
-
gstate.rows = std::move(rows);
|
441
|
-
gstate.strings = std::move(strings);
|
442
|
-
}
|
443
|
-
return;
|
58
|
+
void Combine() {
|
59
|
+
local_partition.Combine();
|
444
60
|
}
|
445
61
|
|
446
|
-
|
447
|
-
|
448
|
-
}
|
62
|
+
PartitionLocalSinkState local_partition;
|
63
|
+
};
|
449
64
|
|
450
65
|
// this implements a sorted window functions variant
|
451
66
|
PhysicalWindow::PhysicalWindow(vector<LogicalType> types, vector<unique_ptr<Expression>> select_list_p,
|
@@ -454,7 +69,7 @@ PhysicalWindow::PhysicalWindow(vector<LogicalType> types, vector<unique_ptr<Expr
|
|
454
69
|
is_order_dependent = false;
|
455
70
|
for (auto &expr : select_list) {
|
456
71
|
D_ASSERT(expr->expression_class == ExpressionClass::BOUND_WINDOW);
|
457
|
-
auto &bound_window = (
|
72
|
+
auto &bound_window = expr->Cast<BoundWindowExpression>();
|
458
73
|
if (bound_window.partitions.empty() && bound_window.orders.empty()) {
|
459
74
|
is_order_dependent = true;
|
460
75
|
}
|
@@ -526,14 +141,14 @@ static idx_t FindPrevStart(const ValidityMask &mask, const idx_t l, idx_t r, idx
|
|
526
141
|
return l;
|
527
142
|
}
|
528
143
|
|
529
|
-
static void PrepareInputExpressions(Expression
|
144
|
+
static void PrepareInputExpressions(vector<unique_ptr<Expression>> &exprs, ExpressionExecutor &executor,
|
530
145
|
DataChunk &chunk) {
|
531
|
-
if (
|
146
|
+
if (exprs.empty()) {
|
532
147
|
return;
|
533
148
|
}
|
534
149
|
|
535
150
|
vector<LogicalType> types;
|
536
|
-
for (idx_t expr_idx = 0; expr_idx <
|
151
|
+
for (idx_t expr_idx = 0; expr_idx < exprs.size(); ++expr_idx) {
|
537
152
|
types.push_back(exprs[expr_idx]->return_type);
|
538
153
|
executor.AddExpression(*exprs[expr_idx]);
|
539
154
|
}
|
@@ -544,15 +159,20 @@ static void PrepareInputExpressions(Expression **exprs, idx_t expr_count, Expres
|
|
544
159
|
}
|
545
160
|
}
|
546
161
|
|
547
|
-
static void PrepareInputExpression(Expression
|
548
|
-
|
162
|
+
static void PrepareInputExpression(Expression &expr, ExpressionExecutor &executor, DataChunk &chunk) {
|
163
|
+
vector<LogicalType> types;
|
164
|
+
types.push_back(expr.return_type);
|
165
|
+
executor.AddExpression(expr);
|
166
|
+
|
167
|
+
auto &allocator = executor.GetAllocator();
|
168
|
+
chunk.Initialize(allocator, types);
|
549
169
|
}
|
550
170
|
|
551
171
|
struct WindowInputExpression {
|
552
|
-
WindowInputExpression(Expression
|
172
|
+
WindowInputExpression(optional_ptr<Expression> expr_p, ClientContext &context)
|
553
173
|
: expr(expr_p), ptype(PhysicalType::INVALID), scalar(true), executor(context) {
|
554
174
|
if (expr) {
|
555
|
-
PrepareInputExpression(expr, executor, chunk);
|
175
|
+
PrepareInputExpression(*expr, executor, chunk);
|
556
176
|
ptype = expr->return_type.InternalType();
|
557
177
|
scalar = expr->IsScalar();
|
558
178
|
}
|
@@ -588,7 +208,7 @@ struct WindowInputExpression {
|
|
588
208
|
VectorOperations::Copy(source, target, source_offset + 1, source_offset, target_offset);
|
589
209
|
}
|
590
210
|
|
591
|
-
Expression
|
211
|
+
optional_ptr<Expression> expr;
|
592
212
|
PhysicalType ptype;
|
593
213
|
bool scalar;
|
594
214
|
ExpressionExecutor executor;
|
@@ -599,7 +219,7 @@ struct WindowInputColumn {
|
|
599
219
|
WindowInputColumn(Expression *expr_p, ClientContext &context, idx_t capacity_p)
|
600
220
|
: input_expr(expr_p, context), count(0), capacity(capacity_p) {
|
601
221
|
if (input_expr.expr) {
|
602
|
-
target =
|
222
|
+
target = make_uniq<Vector>(input_expr.chunk.data[0].GetType(), capacity);
|
603
223
|
}
|
604
224
|
}
|
605
225
|
|
@@ -621,7 +241,7 @@ struct WindowInputColumn {
|
|
621
241
|
}
|
622
242
|
|
623
243
|
template <typename T>
|
624
|
-
inline T GetCell(idx_t i) {
|
244
|
+
inline T GetCell(idx_t i) const {
|
625
245
|
D_ASSERT(target);
|
626
246
|
D_ASSERT(i < count);
|
627
247
|
const auto data = FlatVector::GetData<T>(*target);
|
@@ -652,15 +272,15 @@ struct WindowBoundariesState {
|
|
652
272
|
return expr ? expr->IsScalar() : true;
|
653
273
|
}
|
654
274
|
|
655
|
-
WindowBoundariesState(BoundWindowExpression
|
656
|
-
: type(wexpr
|
657
|
-
partition_count(wexpr
|
658
|
-
range_sense(wexpr
|
659
|
-
has_preceding_range(wexpr
|
660
|
-
wexpr
|
661
|
-
has_following_range(wexpr
|
662
|
-
wexpr
|
663
|
-
needs_peer(BoundaryNeedsPeer(wexpr
|
275
|
+
WindowBoundariesState(BoundWindowExpression &wexpr, const idx_t input_size)
|
276
|
+
: type(wexpr.type), input_size(input_size), start_boundary(wexpr.start), end_boundary(wexpr.end),
|
277
|
+
partition_count(wexpr.partitions.size()), order_count(wexpr.orders.size()),
|
278
|
+
range_sense(wexpr.orders.empty() ? OrderType::INVALID : wexpr.orders[0].type),
|
279
|
+
has_preceding_range(wexpr.start == WindowBoundary::EXPR_PRECEDING_RANGE ||
|
280
|
+
wexpr.end == WindowBoundary::EXPR_PRECEDING_RANGE),
|
281
|
+
has_following_range(wexpr.start == WindowBoundary::EXPR_FOLLOWING_RANGE ||
|
282
|
+
wexpr.end == WindowBoundary::EXPR_FOLLOWING_RANGE),
|
283
|
+
needs_peer(BoundaryNeedsPeer(wexpr.end) || wexpr.type == ExpressionType::WINDOW_CUME_DIST) {
|
664
284
|
}
|
665
285
|
|
666
286
|
void Update(const idx_t row_idx, WindowInputColumn &range_collection, const idx_t source_offset,
|
@@ -691,9 +311,9 @@ struct WindowBoundariesState {
|
|
691
311
|
bool is_peer = false;
|
692
312
|
};
|
693
313
|
|
694
|
-
static bool WindowNeedsRank(BoundWindowExpression
|
695
|
-
return wexpr
|
696
|
-
wexpr
|
314
|
+
static bool WindowNeedsRank(const BoundWindowExpression &wexpr) {
|
315
|
+
return wexpr.type == ExpressionType::WINDOW_PERCENT_RANK || wexpr.type == ExpressionType::WINDOW_RANK ||
|
316
|
+
wexpr.type == ExpressionType::WINDOW_RANK_DENSE || wexpr.type == ExpressionType::WINDOW_CUME_DIST;
|
697
317
|
}
|
698
318
|
|
699
319
|
template <typename T>
|
@@ -753,7 +373,7 @@ struct WindowColumnIterator {
|
|
753
373
|
}
|
754
374
|
|
755
375
|
private:
|
756
|
-
WindowInputColumn
|
376
|
+
optional_ptr<WindowInputColumn> coll;
|
757
377
|
pointer pos;
|
758
378
|
};
|
759
379
|
|
@@ -994,7 +614,10 @@ void WindowBoundariesState::Update(const idx_t row_idx, WindowInputColumn &range
|
|
994
614
|
}
|
995
615
|
|
996
616
|
struct WindowExecutor {
|
997
|
-
|
617
|
+
static bool IsConstantAggregate(const BoundWindowExpression &wexpr);
|
618
|
+
|
619
|
+
WindowExecutor(BoundWindowExpression &wexpr, ClientContext &context, const ValidityMask &partition_mask,
|
620
|
+
const idx_t count);
|
998
621
|
|
999
622
|
void Sink(DataChunk &input_chunk, const idx_t input_idx, const idx_t total_count);
|
1000
623
|
void Finalize(WindowAggregationMode mode);
|
@@ -1003,7 +626,7 @@ struct WindowExecutor {
|
|
1003
626
|
const ValidityMask &order_mask);
|
1004
627
|
|
1005
628
|
// The function
|
1006
|
-
BoundWindowExpression
|
629
|
+
BoundWindowExpression &wexpr;
|
1007
630
|
|
1008
631
|
// Frame management
|
1009
632
|
WindowBoundariesState bounds;
|
@@ -1038,36 +661,95 @@ struct WindowExecutor {
|
|
1038
661
|
// build a segment tree for frame-adhering aggregates
|
1039
662
|
// see http://www.vldb.org/pvldb/vol8/p1058-leis.pdf
|
1040
663
|
unique_ptr<WindowSegmentTree> segment_tree = nullptr;
|
664
|
+
|
665
|
+
// all aggregate values are the same for each partition
|
666
|
+
unique_ptr<WindowConstantAggregate> constant_aggregate = nullptr;
|
1041
667
|
};
|
1042
668
|
|
1043
|
-
WindowExecutor::
|
669
|
+
bool WindowExecutor::IsConstantAggregate(const BoundWindowExpression &wexpr) {
|
670
|
+
if (!wexpr.aggregate) {
|
671
|
+
return false;
|
672
|
+
}
|
673
|
+
|
674
|
+
// COUNT(*) is already handled efficiently by segment trees.
|
675
|
+
if (wexpr.children.empty()) {
|
676
|
+
return false;
|
677
|
+
}
|
678
|
+
|
679
|
+
/*
|
680
|
+
The default framing option is RANGE UNBOUNDED PRECEDING, which
|
681
|
+
is the same as RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT
|
682
|
+
ROW; it sets the frame to be all rows from the partition start
|
683
|
+
up through the current row's last peer (a row that the window's
|
684
|
+
ORDER BY clause considers equivalent to the current row; all
|
685
|
+
rows are peers if there is no ORDER BY). In general, UNBOUNDED
|
686
|
+
PRECEDING means that the frame starts with the first row of the
|
687
|
+
partition, and similarly UNBOUNDED FOLLOWING means that the
|
688
|
+
frame ends with the last row of the partition, regardless of
|
689
|
+
RANGE, ROWS or GROUPS mode. In ROWS mode, CURRENT ROW means that
|
690
|
+
the frame starts or ends with the current row; but in RANGE or
|
691
|
+
GROUPS mode it means that the frame starts or ends with the
|
692
|
+
current row's first or last peer in the ORDER BY ordering. The
|
693
|
+
offset PRECEDING and offset FOLLOWING options vary in meaning
|
694
|
+
depending on the frame mode.
|
695
|
+
*/
|
696
|
+
switch (wexpr.start) {
|
697
|
+
case WindowBoundary::UNBOUNDED_PRECEDING:
|
698
|
+
break;
|
699
|
+
case WindowBoundary::CURRENT_ROW_RANGE:
|
700
|
+
if (!wexpr.orders.empty()) {
|
701
|
+
return false;
|
702
|
+
}
|
703
|
+
break;
|
704
|
+
default:
|
705
|
+
return false;
|
706
|
+
}
|
707
|
+
|
708
|
+
switch (wexpr.end) {
|
709
|
+
case WindowBoundary::UNBOUNDED_FOLLOWING:
|
710
|
+
break;
|
711
|
+
case WindowBoundary::CURRENT_ROW_RANGE:
|
712
|
+
if (!wexpr.orders.empty()) {
|
713
|
+
return false;
|
714
|
+
}
|
715
|
+
break;
|
716
|
+
default:
|
717
|
+
return false;
|
718
|
+
}
|
719
|
+
|
720
|
+
return true;
|
721
|
+
}
|
722
|
+
|
723
|
+
WindowExecutor::WindowExecutor(BoundWindowExpression &wexpr, ClientContext &context, const ValidityMask &partition_mask,
|
724
|
+
const idx_t count)
|
1044
725
|
: wexpr(wexpr), bounds(wexpr, count), payload_collection(), payload_executor(context), filter_executor(context),
|
1045
|
-
leadlag_offset(wexpr
|
1046
|
-
boundary_start(wexpr
|
1047
|
-
range((bounds.has_preceding_range || bounds.has_following_range) ? wexpr
|
726
|
+
leadlag_offset(wexpr.offset_expr.get(), context), leadlag_default(wexpr.default_expr.get(), context),
|
727
|
+
boundary_start(wexpr.start_expr.get(), context), boundary_end(wexpr.end_expr.get(), context),
|
728
|
+
range((bounds.has_preceding_range || bounds.has_following_range) ? wexpr.orders[0].expression.get() : nullptr,
|
1048
729
|
context, count)
|
1049
730
|
|
1050
731
|
{
|
1051
732
|
// TODO we could evaluate those expressions in parallel
|
1052
733
|
|
734
|
+
// Check for constant aggregate
|
735
|
+
if (IsConstantAggregate(wexpr)) {
|
736
|
+
constant_aggregate =
|
737
|
+
make_uniq<WindowConstantAggregate>(AggregateObject(wexpr), wexpr.return_type, partition_mask, count);
|
738
|
+
}
|
739
|
+
|
1053
740
|
// evaluate the FILTER clause and stuff it into a large mask for compactness and reuse
|
1054
|
-
if (wexpr
|
741
|
+
if (wexpr.filter_expr) {
|
1055
742
|
// Start with all invalid and set the ones that pass
|
1056
743
|
filter_bits.resize(ValidityMask::ValidityMaskSize(count), 0);
|
1057
744
|
filter_mask.Initialize(filter_bits.data());
|
1058
|
-
filter_executor.AddExpression(*wexpr
|
745
|
+
filter_executor.AddExpression(*wexpr.filter_expr);
|
1059
746
|
filter_sel.Initialize(STANDARD_VECTOR_SIZE);
|
1060
747
|
}
|
1061
748
|
|
1062
749
|
// TODO: child may be a scalar, don't need to materialize the whole collection then
|
1063
750
|
|
1064
751
|
// evaluate inner expressions of window functions, could be more complex
|
1065
|
-
|
1066
|
-
exprs.reserve(wexpr->children.size());
|
1067
|
-
for (auto &child : wexpr->children) {
|
1068
|
-
exprs.push_back(child.get());
|
1069
|
-
}
|
1070
|
-
PrepareInputExpressions(exprs.data(), exprs.size(), payload_executor, payload_chunk);
|
752
|
+
PrepareInputExpressions(wexpr.children, payload_executor, payload_chunk);
|
1071
753
|
|
1072
754
|
auto types = payload_chunk.GetTypes();
|
1073
755
|
if (!types.empty()) {
|
@@ -1081,8 +763,8 @@ void WindowExecutor::Sink(DataChunk &input_chunk, const idx_t input_idx, const i
|
|
1081
763
|
|
1082
764
|
// Set up a validity mask for IGNORE NULLS
|
1083
765
|
bool check_nulls = false;
|
1084
|
-
if (wexpr
|
1085
|
-
switch (wexpr
|
766
|
+
if (wexpr.ignore_nulls) {
|
767
|
+
switch (wexpr.type) {
|
1086
768
|
case ExpressionType::WINDOW_LEAD:
|
1087
769
|
case ExpressionType::WINDOW_LAG:
|
1088
770
|
case ExpressionType::WINDOW_FIRST_VALUE:
|
@@ -1097,11 +779,25 @@ void WindowExecutor::Sink(DataChunk &input_chunk, const idx_t input_idx, const i
|
|
1097
779
|
|
1098
780
|
const auto count = input_chunk.size();
|
1099
781
|
|
1100
|
-
|
782
|
+
idx_t filtered = 0;
|
783
|
+
SelectionVector *filtering = nullptr;
|
784
|
+
if (wexpr.filter_expr) {
|
785
|
+
filtering = &filter_sel;
|
786
|
+
filtered = filter_executor.SelectExpression(input_chunk, filter_sel);
|
787
|
+
for (idx_t f = 0; f < filtered; ++f) {
|
788
|
+
filter_mask.SetValid(input_idx + filter_sel[f]);
|
789
|
+
}
|
790
|
+
}
|
791
|
+
|
792
|
+
if (!wexpr.children.empty()) {
|
1101
793
|
payload_chunk.Reset();
|
1102
794
|
payload_executor.Execute(input_chunk, payload_chunk);
|
1103
795
|
payload_chunk.Verify();
|
1104
|
-
|
796
|
+
if (constant_aggregate) {
|
797
|
+
constant_aggregate->Sink(payload_chunk, filtering, filtered);
|
798
|
+
} else {
|
799
|
+
payload_collection.Append(payload_chunk, true);
|
800
|
+
}
|
1105
801
|
|
1106
802
|
// process payload chunks while they are still piping hot
|
1107
803
|
if (check_nulls) {
|
@@ -1130,23 +826,17 @@ void WindowExecutor::Sink(DataChunk &input_chunk, const idx_t input_idx, const i
|
|
1130
826
|
}
|
1131
827
|
}
|
1132
828
|
|
1133
|
-
if (wexpr->filter_expr) {
|
1134
|
-
const auto filtered = filter_executor.SelectExpression(input_chunk, filter_sel);
|
1135
|
-
for (idx_t f = 0; f < filtered; ++f) {
|
1136
|
-
filter_mask.SetValid(input_idx + filter_sel[f]);
|
1137
|
-
}
|
1138
|
-
}
|
1139
|
-
|
1140
829
|
range.Append(input_chunk);
|
1141
830
|
}
|
1142
831
|
|
1143
832
|
void WindowExecutor::Finalize(WindowAggregationMode mode) {
|
1144
833
|
// build a segment tree for frame-adhering aggregates
|
1145
834
|
// see http://www.vldb.org/pvldb/vol8/p1058-leis.pdf
|
1146
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
835
|
+
if (constant_aggregate) {
|
836
|
+
constant_aggregate->Finalize();
|
837
|
+
} else if (wexpr.aggregate) {
|
838
|
+
segment_tree = make_uniq<WindowSegmentTree>(AggregateObject(wexpr), wexpr.return_type, &payload_collection,
|
839
|
+
filter_mask, mode);
|
1150
840
|
}
|
1151
841
|
}
|
1152
842
|
|
@@ -1182,9 +872,13 @@ void WindowExecutor::Evaluate(idx_t row_idx, DataChunk &input_chunk, Vector &res
|
|
1182
872
|
continue;
|
1183
873
|
}
|
1184
874
|
|
1185
|
-
switch (wexpr
|
875
|
+
switch (wexpr.type) {
|
1186
876
|
case ExpressionType::WINDOW_AGGREGATE: {
|
1187
|
-
|
877
|
+
if (constant_aggregate) {
|
878
|
+
constant_aggregate->Compute(result, output_offset, bounds.window_start, bounds.window_end);
|
879
|
+
} else {
|
880
|
+
segment_tree->Compute(result, output_offset, bounds.window_start, bounds.window_end);
|
881
|
+
}
|
1188
882
|
break;
|
1189
883
|
}
|
1190
884
|
case ExpressionType::WINDOW_ROW_NUMBER: {
|
@@ -1258,11 +952,11 @@ void WindowExecutor::Evaluate(idx_t row_idx, DataChunk &input_chunk, Vector &res
|
|
1258
952
|
case ExpressionType::WINDOW_LEAD:
|
1259
953
|
case ExpressionType::WINDOW_LAG: {
|
1260
954
|
int64_t offset = 1;
|
1261
|
-
if (wexpr
|
955
|
+
if (wexpr.offset_expr) {
|
1262
956
|
offset = leadlag_offset.GetCell<int64_t>(output_offset);
|
1263
957
|
}
|
1264
958
|
int64_t val_idx = (int64_t)row_idx;
|
1265
|
-
if (wexpr
|
959
|
+
if (wexpr.type == ExpressionType::WINDOW_LEAD) {
|
1266
960
|
val_idx += offset;
|
1267
961
|
} else {
|
1268
962
|
val_idx -= offset;
|
@@ -1281,7 +975,7 @@ void WindowExecutor::Evaluate(idx_t row_idx, DataChunk &input_chunk, Vector &res
|
|
1281
975
|
|
1282
976
|
if (!delta) {
|
1283
977
|
CopyCell(payload_collection, 0, val_idx, result, output_offset);
|
1284
|
-
} else if (wexpr
|
978
|
+
} else if (wexpr.default_expr) {
|
1285
979
|
leadlag_default.CopyCell(result, output_offset);
|
1286
980
|
} else {
|
1287
981
|
FlatVector::SetNull(result, output_offset, true);
|
@@ -1289,15 +983,24 @@ void WindowExecutor::Evaluate(idx_t row_idx, DataChunk &input_chunk, Vector &res
|
|
1289
983
|
break;
|
1290
984
|
}
|
1291
985
|
case ExpressionType::WINDOW_FIRST_VALUE: {
|
986
|
+
// Same as NTH_VALUE(..., 1)
|
1292
987
|
idx_t n = 1;
|
1293
988
|
const auto first_idx = FindNextStart(ignore_nulls, bounds.window_start, bounds.window_end, n);
|
1294
|
-
|
989
|
+
if (!n) {
|
990
|
+
CopyCell(payload_collection, 0, first_idx, result, output_offset);
|
991
|
+
} else {
|
992
|
+
FlatVector::SetNull(result, output_offset, true);
|
993
|
+
}
|
1295
994
|
break;
|
1296
995
|
}
|
1297
996
|
case ExpressionType::WINDOW_LAST_VALUE: {
|
1298
997
|
idx_t n = 1;
|
1299
|
-
|
1300
|
-
|
998
|
+
const auto last_idx = FindPrevStart(ignore_nulls, bounds.window_start, bounds.window_end, n);
|
999
|
+
if (!n) {
|
1000
|
+
CopyCell(payload_collection, 0, last_idx, result, output_offset);
|
1001
|
+
} else {
|
1002
|
+
FlatVector::SetNull(result, output_offset, true);
|
1003
|
+
}
|
1301
1004
|
break;
|
1302
1005
|
}
|
1303
1006
|
case ExpressionType::WINDOW_NTH_VALUE: {
|
@@ -1323,7 +1026,7 @@ void WindowExecutor::Evaluate(idx_t row_idx, DataChunk &input_chunk, Vector &res
|
|
1323
1026
|
break;
|
1324
1027
|
}
|
1325
1028
|
default:
|
1326
|
-
throw InternalException("Window aggregate type %s", ExpressionTypeToString(wexpr
|
1029
|
+
throw InternalException("Window aggregate type %s", ExpressionTypeToString(wexpr.type));
|
1327
1030
|
}
|
1328
1031
|
}
|
1329
1032
|
|
@@ -1335,322 +1038,51 @@ void WindowExecutor::Evaluate(idx_t row_idx, DataChunk &input_chunk, Vector &res
|
|
1335
1038
|
//===--------------------------------------------------------------------===//
|
1336
1039
|
SinkResultType PhysicalWindow::Sink(ExecutionContext &context, GlobalSinkState &gstate_p, LocalSinkState &lstate_p,
|
1337
1040
|
DataChunk &input) const {
|
1338
|
-
auto &
|
1339
|
-
auto &lstate = (WindowLocalSinkState &)lstate_p;
|
1041
|
+
auto &lstate = lstate_p.Cast<WindowLocalSinkState>();
|
1340
1042
|
|
1341
|
-
lstate.Sink(input
|
1043
|
+
lstate.Sink(input);
|
1342
1044
|
|
1343
1045
|
return SinkResultType::NEED_MORE_INPUT;
|
1344
1046
|
}
|
1345
1047
|
|
1346
1048
|
void PhysicalWindow::Combine(ExecutionContext &context, GlobalSinkState &gstate_p, LocalSinkState &lstate_p) const {
|
1347
|
-
auto &
|
1348
|
-
|
1349
|
-
lstate.Combine(gstate);
|
1049
|
+
auto &lstate = lstate_p.Cast<WindowLocalSinkState>();
|
1050
|
+
lstate.Combine();
|
1350
1051
|
}
|
1351
1052
|
|
1352
1053
|
unique_ptr<LocalSinkState> PhysicalWindow::GetLocalSinkState(ExecutionContext &context) const {
|
1353
|
-
|
1054
|
+
auto &gstate = sink_state->Cast<WindowGlobalSinkState>();
|
1055
|
+
return make_uniq<WindowLocalSinkState>(context.client, gstate);
|
1354
1056
|
}
|
1355
1057
|
|
1356
1058
|
unique_ptr<GlobalSinkState> PhysicalWindow::GetGlobalSinkState(ClientContext &context) const {
|
1357
|
-
return
|
1059
|
+
return make_uniq<WindowGlobalSinkState>(*this, context);
|
1358
1060
|
}
|
1359
1061
|
|
1360
|
-
enum class WindowSortStage : uint8_t { INIT, PREPARE, MERGE, SORTED };
|
1361
|
-
|
1362
|
-
class WindowGlobalMergeState;
|
1363
|
-
|
1364
|
-
class WindowLocalMergeState {
|
1365
|
-
public:
|
1366
|
-
WindowLocalMergeState() : merge_state(nullptr), stage(WindowSortStage::INIT) {
|
1367
|
-
finished = true;
|
1368
|
-
}
|
1369
|
-
|
1370
|
-
bool TaskFinished() {
|
1371
|
-
return finished;
|
1372
|
-
}
|
1373
|
-
|
1374
|
-
void Prepare();
|
1375
|
-
void Merge();
|
1376
|
-
|
1377
|
-
void ExecuteTask();
|
1378
|
-
|
1379
|
-
WindowGlobalMergeState *merge_state;
|
1380
|
-
WindowSortStage stage;
|
1381
|
-
atomic<bool> finished;
|
1382
|
-
};
|
1383
|
-
|
1384
|
-
class WindowGlobalMergeState {
|
1385
|
-
public:
|
1386
|
-
using GroupDataPtr = unique_ptr<ColumnDataCollection>;
|
1387
|
-
|
1388
|
-
explicit WindowGlobalMergeState(WindowGlobalSinkState &sink, GroupDataPtr group_data)
|
1389
|
-
: sink(sink), group_data(std::move(group_data)), stage(WindowSortStage::INIT), total_tasks(0),
|
1390
|
-
tasks_assigned(0), tasks_completed(0) {
|
1391
|
-
|
1392
|
-
const auto group_idx = sink.hash_groups.size();
|
1393
|
-
auto new_group = make_unique<WindowGlobalHashGroup>(sink.buffer_manager, sink.partitions, sink.orders,
|
1394
|
-
sink.payload_types, sink.external);
|
1395
|
-
sink.hash_groups.emplace_back(std::move(new_group));
|
1396
|
-
|
1397
|
-
hash_group = sink.hash_groups[group_idx].get();
|
1398
|
-
global_sort = sink.hash_groups[group_idx]->global_sort.get();
|
1399
|
-
}
|
1400
|
-
|
1401
|
-
bool IsSorted() const {
|
1402
|
-
lock_guard<mutex> guard(lock);
|
1403
|
-
return stage == WindowSortStage::SORTED;
|
1404
|
-
}
|
1405
|
-
|
1406
|
-
bool AssignTask(WindowLocalMergeState &local_state);
|
1407
|
-
bool TryPrepareNextStage();
|
1408
|
-
void CompleteTask();
|
1409
|
-
|
1410
|
-
WindowGlobalSinkState &sink;
|
1411
|
-
GroupDataPtr group_data;
|
1412
|
-
WindowGlobalHashGroup *hash_group;
|
1413
|
-
GlobalSortState *global_sort;
|
1414
|
-
|
1415
|
-
private:
|
1416
|
-
mutable mutex lock;
|
1417
|
-
WindowSortStage stage;
|
1418
|
-
idx_t total_tasks;
|
1419
|
-
idx_t tasks_assigned;
|
1420
|
-
idx_t tasks_completed;
|
1421
|
-
};
|
1422
|
-
|
1423
|
-
void WindowLocalMergeState::Prepare() {
|
1424
|
-
auto &global_sort = *merge_state->global_sort;
|
1425
|
-
merge_state->sink.BuildSortState(*merge_state->group_data, *merge_state->hash_group);
|
1426
|
-
merge_state->group_data.reset();
|
1427
|
-
|
1428
|
-
global_sort.PrepareMergePhase();
|
1429
|
-
}
|
1430
|
-
|
1431
|
-
void WindowLocalMergeState::Merge() {
|
1432
|
-
auto &global_sort = *merge_state->global_sort;
|
1433
|
-
MergeSorter merge_sorter(global_sort, global_sort.buffer_manager);
|
1434
|
-
merge_sorter.PerformInMergeRound();
|
1435
|
-
}
|
1436
|
-
|
1437
|
-
void WindowLocalMergeState::ExecuteTask() {
|
1438
|
-
switch (stage) {
|
1439
|
-
case WindowSortStage::PREPARE:
|
1440
|
-
Prepare();
|
1441
|
-
break;
|
1442
|
-
case WindowSortStage::MERGE:
|
1443
|
-
Merge();
|
1444
|
-
break;
|
1445
|
-
default:
|
1446
|
-
throw InternalException("Unexpected WindowGlobalMergeState in ExecuteTask!");
|
1447
|
-
}
|
1448
|
-
|
1449
|
-
merge_state->CompleteTask();
|
1450
|
-
finished = true;
|
1451
|
-
}
|
1452
|
-
|
1453
|
-
bool WindowGlobalMergeState::AssignTask(WindowLocalMergeState &local_state) {
|
1454
|
-
lock_guard<mutex> guard(lock);
|
1455
|
-
|
1456
|
-
if (tasks_assigned >= total_tasks) {
|
1457
|
-
return false;
|
1458
|
-
}
|
1459
|
-
|
1460
|
-
local_state.merge_state = this;
|
1461
|
-
local_state.stage = stage;
|
1462
|
-
local_state.finished = false;
|
1463
|
-
tasks_assigned++;
|
1464
|
-
|
1465
|
-
return true;
|
1466
|
-
}
|
1467
|
-
|
1468
|
-
void WindowGlobalMergeState::CompleteTask() {
|
1469
|
-
lock_guard<mutex> guard(lock);
|
1470
|
-
|
1471
|
-
++tasks_completed;
|
1472
|
-
}
|
1473
|
-
|
1474
|
-
bool WindowGlobalMergeState::TryPrepareNextStage() {
|
1475
|
-
lock_guard<mutex> guard(lock);
|
1476
|
-
|
1477
|
-
if (tasks_completed < total_tasks) {
|
1478
|
-
return false;
|
1479
|
-
}
|
1480
|
-
|
1481
|
-
tasks_assigned = tasks_completed = 0;
|
1482
|
-
|
1483
|
-
switch (stage) {
|
1484
|
-
case WindowSortStage::INIT:
|
1485
|
-
total_tasks = 1;
|
1486
|
-
stage = WindowSortStage::PREPARE;
|
1487
|
-
return true;
|
1488
|
-
|
1489
|
-
case WindowSortStage::PREPARE:
|
1490
|
-
total_tasks = global_sort->sorted_blocks.size() / 2;
|
1491
|
-
if (!total_tasks) {
|
1492
|
-
break;
|
1493
|
-
}
|
1494
|
-
stage = WindowSortStage::MERGE;
|
1495
|
-
global_sort->InitializeMergeRound();
|
1496
|
-
return true;
|
1497
|
-
|
1498
|
-
case WindowSortStage::MERGE:
|
1499
|
-
global_sort->CompleteMergeRound(true);
|
1500
|
-
total_tasks = global_sort->sorted_blocks.size() / 2;
|
1501
|
-
if (!total_tasks) {
|
1502
|
-
break;
|
1503
|
-
}
|
1504
|
-
global_sort->InitializeMergeRound();
|
1505
|
-
return true;
|
1506
|
-
|
1507
|
-
case WindowSortStage::SORTED:
|
1508
|
-
break;
|
1509
|
-
}
|
1510
|
-
|
1511
|
-
stage = WindowSortStage::SORTED;
|
1512
|
-
|
1513
|
-
return false;
|
1514
|
-
}
|
1515
|
-
|
1516
|
-
class WindowGlobalMergeStates {
|
1517
|
-
public:
|
1518
|
-
using WindowGlobalMergeStatePtr = unique_ptr<WindowGlobalMergeState>;
|
1519
|
-
|
1520
|
-
explicit WindowGlobalMergeStates(WindowGlobalSinkState &sink) {
|
1521
|
-
// Schedule all the sorts for maximum thread utilisation
|
1522
|
-
for (auto &group_data : sink.grouping_data->GetPartitions()) {
|
1523
|
-
// Prepare for merge sort phase
|
1524
|
-
if (group_data->Count()) {
|
1525
|
-
auto state = make_unique<WindowGlobalMergeState>(sink, std::move(group_data));
|
1526
|
-
states.emplace_back(std::move(state));
|
1527
|
-
}
|
1528
|
-
}
|
1529
|
-
}
|
1530
|
-
|
1531
|
-
vector<WindowGlobalMergeStatePtr> states;
|
1532
|
-
};
|
1533
|
-
|
1534
|
-
class WindowMergeTask : public ExecutorTask {
|
1535
|
-
public:
|
1536
|
-
WindowMergeTask(shared_ptr<Event> event_p, ClientContext &context_p, WindowGlobalMergeStates &hash_groups_p)
|
1537
|
-
: ExecutorTask(context_p), event(std::move(event_p)), hash_groups(hash_groups_p) {
|
1538
|
-
}
|
1539
|
-
|
1540
|
-
TaskExecutionResult ExecuteTask(TaskExecutionMode mode) override;
|
1541
|
-
|
1542
|
-
private:
|
1543
|
-
shared_ptr<Event> event;
|
1544
|
-
WindowLocalMergeState local_state;
|
1545
|
-
WindowGlobalMergeStates &hash_groups;
|
1546
|
-
};
|
1547
|
-
|
1548
|
-
TaskExecutionResult WindowMergeTask::ExecuteTask(TaskExecutionMode mode) {
|
1549
|
-
// Loop until all hash groups are done
|
1550
|
-
size_t sorted = 0;
|
1551
|
-
while (sorted < hash_groups.states.size()) {
|
1552
|
-
// First check if there is an unfinished task for this thread
|
1553
|
-
if (!local_state.TaskFinished()) {
|
1554
|
-
local_state.ExecuteTask();
|
1555
|
-
continue;
|
1556
|
-
}
|
1557
|
-
|
1558
|
-
// Thread is done with its assigned task, try to fetch new work
|
1559
|
-
for (auto group = sorted; group < hash_groups.states.size(); ++group) {
|
1560
|
-
auto &global_state = hash_groups.states[group];
|
1561
|
-
if (global_state->IsSorted()) {
|
1562
|
-
// This hash group is done
|
1563
|
-
// Update the high water mark of densely completed groups
|
1564
|
-
if (sorted == group) {
|
1565
|
-
++sorted;
|
1566
|
-
}
|
1567
|
-
continue;
|
1568
|
-
}
|
1569
|
-
|
1570
|
-
// Try to assign work for this hash group to this thread
|
1571
|
-
if (global_state->AssignTask(local_state)) {
|
1572
|
-
// We assigned a task to this thread!
|
1573
|
-
// Break out of this loop to re-enter the top-level loop and execute the task
|
1574
|
-
break;
|
1575
|
-
}
|
1576
|
-
|
1577
|
-
// Hash group global state couldn't assign a task to this thread
|
1578
|
-
// Try to prepare the next stage
|
1579
|
-
if (!global_state->TryPrepareNextStage()) {
|
1580
|
-
// This current hash group is not yet done
|
1581
|
-
// But we were not able to assign a task for it to this thread
|
1582
|
-
// See if the next hash group is better
|
1583
|
-
continue;
|
1584
|
-
}
|
1585
|
-
|
1586
|
-
// We were able to prepare the next stage for this hash group!
|
1587
|
-
// Try to assign a task once more
|
1588
|
-
if (global_state->AssignTask(local_state)) {
|
1589
|
-
// We assigned a task to this thread!
|
1590
|
-
// Break out of this loop to re-enter the top-level loop and execute the task
|
1591
|
-
break;
|
1592
|
-
}
|
1593
|
-
|
1594
|
-
// We were able to prepare the next merge round,
|
1595
|
-
// but we were not able to assign a task for it to this thread
|
1596
|
-
// The tasks were assigned to other threads while this thread waited for the lock
|
1597
|
-
// Go to the next iteration to see if another hash group has a task
|
1598
|
-
}
|
1599
|
-
}
|
1600
|
-
|
1601
|
-
event->FinishTask();
|
1602
|
-
return TaskExecutionResult::TASK_FINISHED;
|
1603
|
-
}
|
1604
|
-
|
1605
|
-
class WindowMergeEvent : public BasePipelineEvent {
|
1606
|
-
public:
|
1607
|
-
WindowMergeEvent(WindowGlobalSinkState &gstate_p, Pipeline &pipeline_p)
|
1608
|
-
: BasePipelineEvent(pipeline_p), gstate(gstate_p), merge_states(gstate_p) {
|
1609
|
-
}
|
1610
|
-
|
1611
|
-
WindowGlobalSinkState &gstate;
|
1612
|
-
WindowGlobalMergeStates merge_states;
|
1613
|
-
|
1614
|
-
public:
|
1615
|
-
void Schedule() override {
|
1616
|
-
auto &context = pipeline->GetClientContext();
|
1617
|
-
|
1618
|
-
// Schedule tasks equal to the number of threads, which will each merge multiple partitions
|
1619
|
-
auto &ts = TaskScheduler::GetScheduler(context);
|
1620
|
-
idx_t num_threads = ts.NumberOfThreads();
|
1621
|
-
|
1622
|
-
vector<unique_ptr<Task>> merge_tasks;
|
1623
|
-
for (idx_t tnum = 0; tnum < num_threads; tnum++) {
|
1624
|
-
merge_tasks.push_back(make_unique<WindowMergeTask>(shared_from_this(), context, merge_states));
|
1625
|
-
}
|
1626
|
-
SetTasks(std::move(merge_tasks));
|
1627
|
-
}
|
1628
|
-
};
|
1629
|
-
|
1630
1062
|
SinkFinalizeType PhysicalWindow::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
|
1631
1063
|
GlobalSinkState &gstate_p) const {
|
1632
|
-
auto &state = (
|
1064
|
+
auto &state = gstate_p.Cast<WindowGlobalSinkState>();
|
1633
1065
|
|
1634
1066
|
// Did we get any data?
|
1635
|
-
if (!state.count) {
|
1067
|
+
if (!state.global_partition->count) {
|
1636
1068
|
return SinkFinalizeType::NO_OUTPUT_POSSIBLE;
|
1637
1069
|
}
|
1638
1070
|
|
1639
1071
|
// Do we have any sorting to schedule?
|
1640
|
-
if (state.rows) {
|
1641
|
-
D_ASSERT(!state.grouping_data);
|
1642
|
-
return state.rows->count ? SinkFinalizeType::READY : SinkFinalizeType::NO_OUTPUT_POSSIBLE;
|
1072
|
+
if (state.global_partition->rows) {
|
1073
|
+
D_ASSERT(!state.global_partition->grouping_data);
|
1074
|
+
return state.global_partition->rows->count ? SinkFinalizeType::READY : SinkFinalizeType::NO_OUTPUT_POSSIBLE;
|
1643
1075
|
}
|
1644
1076
|
|
1645
1077
|
// Find the first group to sort
|
1646
|
-
auto &groups = state.grouping_data->GetPartitions();
|
1078
|
+
auto &groups = state.global_partition->grouping_data->GetPartitions();
|
1647
1079
|
if (groups.empty()) {
|
1648
1080
|
// Empty input!
|
1649
1081
|
return SinkFinalizeType::NO_OUTPUT_POSSIBLE;
|
1650
1082
|
}
|
1651
1083
|
|
1652
1084
|
// Schedule all the sorts for maximum thread utilisation
|
1653
|
-
auto new_event = make_shared<
|
1085
|
+
auto new_event = make_shared<PartitionMergeEvent>(*state.global_partition, pipeline);
|
1654
1086
|
event.InsertEvent(std::move(new_event));
|
1655
1087
|
|
1656
1088
|
return SinkFinalizeType::READY;
|
@@ -1661,199 +1093,80 @@ SinkFinalizeType PhysicalWindow::Finalize(Pipeline &pipeline, Event &event, Clie
|
|
1661
1093
|
//===--------------------------------------------------------------------===//
|
1662
1094
|
class WindowGlobalSourceState : public GlobalSourceState {
|
1663
1095
|
public:
|
1664
|
-
explicit WindowGlobalSourceState(
|
1096
|
+
explicit WindowGlobalSourceState(WindowGlobalSinkState &gsink) : partition_source(*gsink.global_partition) {
|
1665
1097
|
}
|
1666
1098
|
|
1667
|
-
|
1668
|
-
//! The output read position.
|
1669
|
-
atomic<idx_t> next_bin;
|
1099
|
+
PartitionGlobalSourceState partition_source;
|
1670
1100
|
|
1671
1101
|
public:
|
1672
1102
|
idx_t MaxThreads() override {
|
1673
|
-
|
1674
|
-
|
1675
|
-
// If there is only one partition, we have to process it on one thread.
|
1676
|
-
if (!state.grouping_data) {
|
1677
|
-
return 1;
|
1678
|
-
}
|
1679
|
-
|
1680
|
-
// If there is not a lot of data, process serially.
|
1681
|
-
if (state.count < STANDARD_ROW_GROUPS_SIZE) {
|
1682
|
-
return 1;
|
1683
|
-
}
|
1684
|
-
|
1685
|
-
return state.hash_groups.size();
|
1103
|
+
return partition_source.MaxThreads();
|
1686
1104
|
}
|
1687
1105
|
};
|
1688
1106
|
|
1689
1107
|
// Per-thread read state
|
1690
1108
|
class WindowLocalSourceState : public LocalSourceState {
|
1691
1109
|
public:
|
1692
|
-
using HashGroupPtr = unique_ptr<
|
1110
|
+
using HashGroupPtr = unique_ptr<PartitionGlobalHashGroup>;
|
1693
1111
|
using WindowExecutorPtr = unique_ptr<WindowExecutor>;
|
1694
1112
|
using WindowExecutors = vector<WindowExecutorPtr>;
|
1695
1113
|
|
1696
|
-
WindowLocalSourceState(const PhysicalWindow &
|
1697
|
-
:
|
1114
|
+
WindowLocalSourceState(const PhysicalWindow &op_p, ExecutionContext &context, WindowGlobalSourceState &gsource)
|
1115
|
+
: partition_source(gsource.partition_source.gsink), context(context.client), op(op_p) {
|
1116
|
+
|
1698
1117
|
vector<LogicalType> output_types;
|
1699
1118
|
for (idx_t expr_idx = 0; expr_idx < op.select_list.size(); ++expr_idx) {
|
1700
1119
|
D_ASSERT(op.select_list[expr_idx]->GetExpressionClass() == ExpressionClass::BOUND_WINDOW);
|
1701
|
-
auto wexpr =
|
1702
|
-
output_types.emplace_back(wexpr
|
1120
|
+
auto &wexpr = op.select_list[expr_idx]->Cast<BoundWindowExpression>();
|
1121
|
+
output_types.emplace_back(wexpr.return_type);
|
1703
1122
|
}
|
1704
|
-
output_chunk.Initialize(
|
1705
|
-
|
1706
|
-
const auto &input_types = op.children[0]->types;
|
1707
|
-
layout.Initialize(input_types);
|
1708
|
-
input_chunk.Initialize(allocator, input_types);
|
1123
|
+
output_chunk.Initialize(Allocator::Get(context.client), output_types);
|
1709
1124
|
}
|
1710
1125
|
|
1711
|
-
void MaterializeSortedData();
|
1712
1126
|
void GeneratePartition(WindowGlobalSinkState &gstate, const idx_t hash_bin);
|
1713
1127
|
void Scan(DataChunk &chunk);
|
1714
1128
|
|
1715
|
-
|
1129
|
+
PartitionLocalSourceState partition_source;
|
1716
1130
|
ClientContext &context;
|
1717
|
-
|
1718
|
-
|
1719
|
-
//! The generated input chunks
|
1720
|
-
unique_ptr<RowDataCollection> rows;
|
1721
|
-
unique_ptr<RowDataCollection> heap;
|
1722
|
-
RowLayout layout;
|
1723
|
-
//! The partition boundary mask
|
1724
|
-
vector<validity_t> partition_bits;
|
1725
|
-
ValidityMask partition_mask;
|
1726
|
-
//! The order boundary mask
|
1727
|
-
vector<validity_t> order_bits;
|
1728
|
-
ValidityMask order_mask;
|
1131
|
+
const PhysicalWindow &op;
|
1132
|
+
|
1729
1133
|
//! The current execution functions
|
1730
1134
|
WindowExecutors window_execs;
|
1731
|
-
|
1732
|
-
//! The read partition
|
1733
|
-
idx_t hash_bin;
|
1734
|
-
//! The read cursor
|
1735
|
-
unique_ptr<RowDataCollectionScanner> scanner;
|
1736
|
-
//! Buffer for the inputs
|
1737
|
-
DataChunk input_chunk;
|
1738
1135
|
//! Buffer for window results
|
1739
1136
|
DataChunk output_chunk;
|
1740
1137
|
};
|
1741
1138
|
|
1742
|
-
void WindowLocalSourceState::MaterializeSortedData() {
|
1743
|
-
auto &global_sort_state = *hash_group->global_sort;
|
1744
|
-
if (global_sort_state.sorted_blocks.empty()) {
|
1745
|
-
return;
|
1746
|
-
}
|
1747
|
-
|
1748
|
-
// scan the sorted row data
|
1749
|
-
D_ASSERT(global_sort_state.sorted_blocks.size() == 1);
|
1750
|
-
auto &sb = *global_sort_state.sorted_blocks[0];
|
1751
|
-
|
1752
|
-
// Free up some memory before allocating more
|
1753
|
-
sb.radix_sorting_data.clear();
|
1754
|
-
sb.blob_sorting_data = nullptr;
|
1755
|
-
|
1756
|
-
// Move the sorting row blocks into our RDCs
|
1757
|
-
auto &buffer_manager = global_sort_state.buffer_manager;
|
1758
|
-
auto &sd = *sb.payload_data;
|
1759
|
-
|
1760
|
-
// Data blocks are required
|
1761
|
-
D_ASSERT(!sd.data_blocks.empty());
|
1762
|
-
auto &block = sd.data_blocks[0];
|
1763
|
-
rows = make_unique<RowDataCollection>(buffer_manager, block->capacity, block->entry_size);
|
1764
|
-
rows->blocks = std::move(sd.data_blocks);
|
1765
|
-
rows->count = std::accumulate(rows->blocks.begin(), rows->blocks.end(), idx_t(0),
|
1766
|
-
[&](idx_t c, const unique_ptr<RowDataBlock> &b) { return c + b->count; });
|
1767
|
-
|
1768
|
-
// Heap blocks are optional, but we want both for iteration.
|
1769
|
-
if (!sd.heap_blocks.empty()) {
|
1770
|
-
auto &block = sd.heap_blocks[0];
|
1771
|
-
heap = make_unique<RowDataCollection>(buffer_manager, block->capacity, block->entry_size);
|
1772
|
-
heap->blocks = std::move(sd.heap_blocks);
|
1773
|
-
hash_group.reset();
|
1774
|
-
} else {
|
1775
|
-
heap = make_unique<RowDataCollection>(buffer_manager, (idx_t)Storage::BLOCK_SIZE, 1, true);
|
1776
|
-
}
|
1777
|
-
heap->count = std::accumulate(heap->blocks.begin(), heap->blocks.end(), idx_t(0),
|
1778
|
-
[&](idx_t c, const unique_ptr<RowDataBlock> &b) { return c + b->count; });
|
1779
|
-
}
|
1780
|
-
|
1781
1139
|
void WindowLocalSourceState::GeneratePartition(WindowGlobalSinkState &gstate, const idx_t hash_bin_p) {
|
1782
|
-
auto
|
1783
|
-
|
1784
|
-
// Get rid of any stale data
|
1785
|
-
hash_bin = hash_bin_p;
|
1786
|
-
|
1787
|
-
// There are three types of partitions:
|
1788
|
-
// 1. No partition (no sorting)
|
1789
|
-
// 2. One partition (sorting, but no hashing)
|
1790
|
-
// 3. Multiple partitions (sorting and hashing)
|
1791
|
-
|
1792
|
-
// How big is the partition?
|
1793
|
-
idx_t count = 0;
|
1794
|
-
if (hash_bin < gstate.hash_groups.size() && gstate.hash_groups[hash_bin]) {
|
1795
|
-
count = gstate.hash_groups[hash_bin]->count;
|
1796
|
-
} else if (gstate.rows && !hash_bin) {
|
1797
|
-
count = gstate.count;
|
1798
|
-
} else {
|
1140
|
+
const auto count = partition_source.GeneratePartition(hash_bin_p);
|
1141
|
+
if (!count) {
|
1799
1142
|
return;
|
1800
1143
|
}
|
1801
1144
|
|
1802
1145
|
// Create the executors for each function
|
1146
|
+
auto &partition_mask = partition_source.partition_mask;
|
1803
1147
|
window_execs.clear();
|
1804
1148
|
for (idx_t expr_idx = 0; expr_idx < op.select_list.size(); ++expr_idx) {
|
1805
1149
|
D_ASSERT(op.select_list[expr_idx]->GetExpressionClass() == ExpressionClass::BOUND_WINDOW);
|
1806
|
-
auto wexpr =
|
1807
|
-
auto wexec =
|
1150
|
+
auto &wexpr = op.select_list[expr_idx]->Cast<BoundWindowExpression>();
|
1151
|
+
auto wexec = make_uniq<WindowExecutor>(wexpr, context, partition_mask, count);
|
1808
1152
|
window_execs.emplace_back(std::move(wexec));
|
1809
1153
|
}
|
1810
1154
|
|
1811
|
-
// Initialise masks to false
|
1812
|
-
const auto bit_count = ValidityMask::ValidityMaskSize(count);
|
1813
|
-
partition_bits.clear();
|
1814
|
-
partition_bits.resize(bit_count, 0);
|
1815
|
-
partition_mask.Initialize(partition_bits.data());
|
1816
|
-
|
1817
|
-
order_bits.clear();
|
1818
|
-
order_bits.resize(bit_count, 0);
|
1819
|
-
order_mask.Initialize(order_bits.data());
|
1820
|
-
|
1821
|
-
// Scan the sorted data into new Collections
|
1822
|
-
auto external = gstate.external;
|
1823
|
-
if (gstate.rows && !hash_bin) {
|
1824
|
-
// Simple mask
|
1825
|
-
partition_mask.SetValidUnsafe(0);
|
1826
|
-
order_mask.SetValidUnsafe(0);
|
1827
|
-
// No partition - align the heap blocks with the row blocks
|
1828
|
-
rows = gstate.rows->CloneEmpty(gstate.rows->keep_pinned);
|
1829
|
-
heap = gstate.strings->CloneEmpty(gstate.strings->keep_pinned);
|
1830
|
-
RowDataCollectionScanner::AlignHeapBlocks(*rows, *heap, *gstate.rows, *gstate.strings, layout);
|
1831
|
-
external = true;
|
1832
|
-
} else if (hash_bin < gstate.hash_groups.size() && gstate.hash_groups[hash_bin]) {
|
1833
|
-
// Overwrite the collections with the sorted data
|
1834
|
-
hash_group = std::move(gstate.hash_groups[hash_bin]);
|
1835
|
-
hash_group->ComputeMasks(partition_mask, order_mask);
|
1836
|
-
MaterializeSortedData();
|
1837
|
-
} else {
|
1838
|
-
return;
|
1839
|
-
}
|
1840
|
-
|
1841
1155
|
// First pass over the input without flushing
|
1842
1156
|
// TODO: Factor out the constructor data as global state
|
1843
|
-
scanner = make_unique<RowDataCollectionScanner>(*rows, *heap, layout, external, false);
|
1844
1157
|
idx_t input_idx = 0;
|
1845
1158
|
while (true) {
|
1846
|
-
input_chunk.Reset();
|
1847
|
-
scanner->Scan(input_chunk);
|
1848
|
-
if (input_chunk.size() == 0) {
|
1159
|
+
partition_source.input_chunk.Reset();
|
1160
|
+
partition_source.scanner->Scan(partition_source.input_chunk);
|
1161
|
+
if (partition_source.input_chunk.size() == 0) {
|
1849
1162
|
break;
|
1850
1163
|
}
|
1851
1164
|
|
1852
1165
|
// TODO: Parallelization opportunity
|
1853
1166
|
for (auto &wexec : window_execs) {
|
1854
|
-
wexec->Sink(input_chunk, input_idx, scanner->Count());
|
1167
|
+
wexec->Sink(partition_source.input_chunk, input_idx, partition_source.scanner->Count());
|
1855
1168
|
}
|
1856
|
-
input_idx += input_chunk.size();
|
1169
|
+
input_idx += partition_source.input_chunk.size();
|
1857
1170
|
}
|
1858
1171
|
|
1859
1172
|
// TODO: Parallelization opportunity
|
@@ -1862,22 +1175,25 @@ void WindowLocalSourceState::GeneratePartition(WindowGlobalSinkState &gstate, co
|
|
1862
1175
|
}
|
1863
1176
|
|
1864
1177
|
// External scanning assumes all blocks are swizzled.
|
1865
|
-
scanner->ReSwizzle();
|
1178
|
+
partition_source.scanner->ReSwizzle();
|
1866
1179
|
|
1867
1180
|
// Second pass can flush
|
1868
|
-
scanner->Reset(true);
|
1181
|
+
partition_source.scanner->Reset(true);
|
1869
1182
|
}
|
1870
1183
|
|
1871
1184
|
void WindowLocalSourceState::Scan(DataChunk &result) {
|
1872
|
-
D_ASSERT(scanner);
|
1873
|
-
if (!scanner->Remaining()) {
|
1185
|
+
D_ASSERT(partition_source.scanner);
|
1186
|
+
if (!partition_source.scanner->Remaining()) {
|
1874
1187
|
return;
|
1875
1188
|
}
|
1876
1189
|
|
1877
|
-
const auto position = scanner->Scanned();
|
1190
|
+
const auto position = partition_source.scanner->Scanned();
|
1191
|
+
auto &input_chunk = partition_source.input_chunk;
|
1878
1192
|
input_chunk.Reset();
|
1879
|
-
scanner->Scan(input_chunk);
|
1193
|
+
partition_source.scanner->Scan(input_chunk);
|
1880
1194
|
|
1195
|
+
auto &partition_mask = partition_source.partition_mask;
|
1196
|
+
auto &order_mask = partition_source.order_mask;
|
1881
1197
|
output_chunk.Reset();
|
1882
1198
|
for (idx_t expr_idx = 0; expr_idx < window_execs.size(); ++expr_idx) {
|
1883
1199
|
auto &executor = *window_execs[expr_idx];
|
@@ -1899,43 +1215,47 @@ void WindowLocalSourceState::Scan(DataChunk &result) {
|
|
1899
1215
|
|
1900
1216
|
unique_ptr<LocalSourceState> PhysicalWindow::GetLocalSourceState(ExecutionContext &context,
|
1901
1217
|
GlobalSourceState &gstate_p) const {
|
1902
|
-
auto &gstate = (
|
1903
|
-
return
|
1218
|
+
auto &gstate = gstate_p.Cast<WindowGlobalSourceState>();
|
1219
|
+
return make_uniq<WindowLocalSourceState>(*this, context, gstate);
|
1904
1220
|
}
|
1905
1221
|
|
1906
1222
|
unique_ptr<GlobalSourceState> PhysicalWindow::GetGlobalSourceState(ClientContext &context) const {
|
1907
|
-
|
1223
|
+
auto &gsink = sink_state->Cast<WindowGlobalSinkState>();
|
1224
|
+
return make_uniq<WindowGlobalSourceState>(gsink);
|
1908
1225
|
}
|
1909
1226
|
|
1910
1227
|
void PhysicalWindow::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate_p,
|
1911
1228
|
LocalSourceState &lstate_p) const {
|
1912
|
-
auto &
|
1913
|
-
auto &
|
1914
|
-
auto &
|
1229
|
+
auto &lsource = lstate_p.Cast<WindowLocalSourceState>();
|
1230
|
+
auto &lpsource = lsource.partition_source;
|
1231
|
+
auto &gsource = gstate_p.Cast<WindowGlobalSourceState>();
|
1232
|
+
auto &gpsource = gsource.partition_source;
|
1233
|
+
auto &gsink = sink_state->Cast<WindowGlobalSinkState>();
|
1915
1234
|
|
1916
|
-
|
1235
|
+
auto &hash_groups = gsink.global_partition->hash_groups;
|
1236
|
+
const auto bin_count = hash_groups.empty() ? 1 : hash_groups.size();
|
1917
1237
|
|
1918
1238
|
while (chunk.size() == 0) {
|
1919
1239
|
// Move to the next bin if we are done.
|
1920
|
-
while (!
|
1921
|
-
|
1922
|
-
|
1923
|
-
|
1924
|
-
|
1925
|
-
auto hash_bin =
|
1240
|
+
while (!lpsource.scanner || !lpsource.scanner->Remaining()) {
|
1241
|
+
lpsource.scanner.reset();
|
1242
|
+
lpsource.rows.reset();
|
1243
|
+
lpsource.heap.reset();
|
1244
|
+
lpsource.hash_group.reset();
|
1245
|
+
auto hash_bin = gpsource.next_bin++;
|
1926
1246
|
if (hash_bin >= bin_count) {
|
1927
1247
|
return;
|
1928
1248
|
}
|
1929
1249
|
|
1930
|
-
for (; hash_bin <
|
1931
|
-
if (
|
1250
|
+
for (; hash_bin < hash_groups.size(); hash_bin = gpsource.next_bin++) {
|
1251
|
+
if (hash_groups[hash_bin]) {
|
1932
1252
|
break;
|
1933
1253
|
}
|
1934
1254
|
}
|
1935
|
-
|
1255
|
+
lsource.GeneratePartition(gsink, hash_bin);
|
1936
1256
|
}
|
1937
1257
|
|
1938
|
-
|
1258
|
+
lsource.Scan(chunk);
|
1939
1259
|
}
|
1940
1260
|
}
|
1941
1261
|
|