duckdb 0.8.2-dev157.0 → 0.8.2-dev1573.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 +15 -12
- package/binding.gyp.in +1 -1
- package/configure.py +1 -1
- package/duckdb_extension_config.cmake +10 -0
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-dateadd.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datefunc.cpp +1 -1
- package/src/duckdb/extension/icu/icu-datepart.cpp +2 -2
- 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-list-range.cpp +1 -1
- package/src/duckdb/extension/icu/icu-makedate.cpp +7 -0
- package/src/duckdb/extension/icu/icu-strptime.cpp +4 -4
- package/src/duckdb/extension/icu/icu-table-range.cpp +5 -5
- package/src/duckdb/extension/icu/icu-timebucket.cpp +16 -16
- package/src/duckdb/extension/icu/icu-timezone.cpp +8 -8
- package/src/duckdb/extension/icu/icu_extension.cpp +3 -3
- package/src/duckdb/extension/json/include/json_common.hpp +47 -231
- package/src/duckdb/extension/json/include/json_executors.hpp +49 -13
- package/src/duckdb/extension/json/include/json_functions.hpp +2 -1
- package/src/duckdb/extension/json/json_common.cpp +272 -40
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +17 -37
- package/src/duckdb/extension/json/json_functions/json_type.cpp +1 -1
- package/src/duckdb/extension/json/json_functions.cpp +24 -24
- package/src/duckdb/extension/json/json_scan.cpp +3 -6
- package/src/duckdb/extension/parquet/column_reader.cpp +19 -21
- package/src/duckdb/extension/parquet/column_writer.cpp +77 -61
- package/src/duckdb/extension/parquet/include/cast_column_reader.hpp +2 -2
- package/src/duckdb/extension/parquet/include/column_reader.hpp +14 -16
- package/src/duckdb/extension/parquet/include/column_writer.hpp +9 -7
- package/src/duckdb/extension/parquet/include/list_column_reader.hpp +2 -2
- 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_statistics.hpp +2 -2
- package/src/duckdb/extension/parquet/include/parquet_support.hpp +9 -11
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +24 -5
- package/src/duckdb/extension/parquet/include/string_column_reader.hpp +1 -1
- package/src/duckdb/extension/parquet/include/struct_column_reader.hpp +2 -3
- package/src/duckdb/extension/parquet/include/zstd_file_system.hpp +2 -2
- package/src/duckdb/extension/parquet/parquet_extension.cpp +192 -20
- package/src/duckdb/extension/parquet/parquet_reader.cpp +6 -6
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +7 -6
- package/src/duckdb/extension/parquet/parquet_writer.cpp +79 -16
- package/src/duckdb/extension/parquet/zstd_file_system.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_search_path.cpp +5 -4
- package/src/duckdb/src/catalog/default/default_functions.cpp +16 -0
- package/src/duckdb/src/common/adbc/adbc.cpp +75 -10
- package/src/duckdb/src/common/adbc/driver_manager.cpp +6 -11
- package/src/duckdb/src/common/allocator.cpp +14 -2
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +5 -11
- package/src/duckdb/src/common/assert.cpp +3 -0
- package/src/duckdb/src/common/enum_util.cpp +4619 -4446
- package/src/duckdb/src/common/enums/logical_operator_type.cpp +4 -0
- package/src/duckdb/src/common/enums/optimizer_type.cpp +2 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +4 -0
- package/src/duckdb/src/common/exception.cpp +2 -2
- package/src/duckdb/src/common/extra_type_info.cpp +506 -0
- package/src/duckdb/src/common/file_system.cpp +19 -0
- package/src/duckdb/src/common/hive_partitioning.cpp +10 -6
- package/src/duckdb/src/common/local_file_system.cpp +14 -14
- package/src/duckdb/src/common/multi_file_reader.cpp +184 -20
- package/src/duckdb/src/common/operator/cast_operators.cpp +35 -1
- package/src/duckdb/src/common/radix_partitioning.cpp +26 -8
- package/src/duckdb/src/common/re2_regex.cpp +1 -1
- package/src/duckdb/src/common/row_operations/row_external.cpp +1 -1
- package/src/duckdb/src/common/sort/merge_sorter.cpp +9 -16
- package/src/duckdb/src/common/sort/partition_state.cpp +44 -11
- package/src/duckdb/src/common/types/batched_data_collection.cpp +7 -2
- package/src/duckdb/src/common/types/bit.cpp +51 -0
- package/src/duckdb/src/common/types/column/column_data_allocator.cpp +9 -6
- package/src/duckdb/src/common/types/column/column_data_collection.cpp +17 -2
- package/src/duckdb/src/common/types/column/column_data_collection_segment.cpp +15 -6
- package/src/duckdb/src/common/types/column/partitioned_column_data.cpp +2 -2
- package/src/duckdb/src/common/types/data_chunk.cpp +2 -2
- package/src/duckdb/src/common/types/date.cpp +9 -0
- package/src/duckdb/src/common/types/list_segment.cpp +24 -74
- package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +3 -9
- package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +2 -0
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +2 -2
- package/src/duckdb/src/common/types/uuid.cpp +2 -2
- package/src/duckdb/src/common/types/validity_mask.cpp +33 -0
- package/src/duckdb/src/common/types.cpp +8 -655
- package/src/duckdb/src/common/virtual_file_system.cpp +138 -1
- package/src/duckdb/src/core_functions/aggregate/holistic/reservoir_quantile.cpp +2 -0
- package/src/duckdb/src/core_functions/aggregate/nested/list.cpp +2 -2
- package/src/duckdb/src/core_functions/aggregate/regression/regr_avg.cpp +4 -4
- package/src/duckdb/src/core_functions/aggregate/regression/regr_intercept.cpp +4 -4
- package/src/duckdb/src/core_functions/aggregate/regression/regr_r2.cpp +5 -4
- package/src/duckdb/src/core_functions/aggregate/regression/regr_sxx_syy.cpp +8 -8
- package/src/duckdb/src/core_functions/aggregate/regression/regr_sxy.cpp +4 -3
- package/src/duckdb/src/core_functions/function_list.cpp +4 -2
- package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +208 -42
- package/src/duckdb/src/core_functions/scalar/date/epoch.cpp +10 -24
- package/src/duckdb/src/core_functions/scalar/date/make_date.cpp +19 -4
- package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +4 -2
- package/src/duckdb/src/execution/aggregate_hashtable.cpp +34 -18
- package/src/duckdb/src/execution/expression_executor.cpp +1 -1
- package/src/duckdb/src/execution/index/art/art.cpp +149 -139
- package/src/duckdb/src/execution/index/art/fixed_size_allocator.cpp +1 -1
- package/src/duckdb/src/execution/index/art/iterator.cpp +129 -207
- package/src/duckdb/src/execution/index/art/leaf.cpp +8 -37
- package/src/duckdb/src/execution/index/art/node.cpp +113 -120
- package/src/duckdb/src/execution/index/art/node16.cpp +1 -10
- package/src/duckdb/src/execution/index/art/node256.cpp +1 -9
- package/src/duckdb/src/execution/index/art/node4.cpp +12 -13
- package/src/duckdb/src/execution/index/art/node48.cpp +1 -11
- package/src/duckdb/src/execution/index/art/prefix.cpp +228 -350
- package/src/duckdb/src/execution/join_hashtable.cpp +4 -4
- package/src/duckdb/src/execution/operator/aggregate/aggregate_object.cpp +1 -0
- package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +8 -3
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +32 -22
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +512 -300
- package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +4 -3
- package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +5 -5
- package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +444 -284
- package/src/duckdb/src/execution/operator/join/physical_comparison_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +21 -10
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +28 -12
- package/src/duckdb/src/execution/operator/join/physical_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +23 -4
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +41 -5
- package/src/duckdb/src/execution/operator/persistent/base_csv_reader.cpp +100 -13
- package/src/duckdb/src/execution/operator/persistent/csv_file_handle.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/csv_reader_options.cpp +20 -0
- package/src/duckdb/src/execution/operator/persistent/csv_rejects_table.cpp +48 -0
- package/src/duckdb/src/execution/operator/persistent/parallel_csv_reader.cpp +2 -3
- package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +6 -4
- package/src/duckdb/src/execution/operator/persistent/physical_fixed_batch_copy.cpp +3 -3
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +1 -1
- package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +2 -1
- package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +19 -0
- package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +7 -2
- package/src/duckdb/src/execution/operator/set/physical_cte.cpp +160 -0
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +15 -5
- package/src/duckdb/src/execution/partitionable_hashtable.cpp +41 -6
- package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +30 -5
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +43 -10
- package/src/duckdb/src/execution/physical_plan/plan_asof_join.cpp +56 -33
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +17 -13
- package/src/duckdb/src/execution/physical_plan/plan_cte.cpp +33 -0
- package/src/duckdb/src/execution/physical_plan/plan_get.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_recursive_cte.cpp +25 -4
- package/src/duckdb/src/execution/physical_plan_generator.cpp +4 -0
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +290 -43
- package/src/duckdb/src/execution/window_segment_tree.cpp +286 -129
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +2 -1
- package/src/duckdb/src/function/cast/bit_cast.cpp +34 -2
- package/src/duckdb/src/function/cast/blob_cast.cpp +3 -0
- package/src/duckdb/src/function/cast/numeric_casts.cpp +2 -0
- package/src/duckdb/src/function/function.cpp +3 -1
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +5 -0
- package/src/duckdb/src/function/scalar/compressed_materialization/compress_integral.cpp +212 -0
- package/src/duckdb/src/function/scalar/compressed_materialization/compress_string.cpp +249 -0
- package/src/duckdb/src/function/scalar/compressed_materialization_functions.cpp +29 -0
- package/src/duckdb/src/function/scalar/list/list_resize.cpp +162 -0
- package/src/duckdb/src/function/scalar/nested_functions.cpp +1 -0
- package/src/duckdb/src/function/scalar/string/like.cpp +12 -4
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +12 -5
- package/src/duckdb/src/function/table/copy_csv.cpp +8 -1
- package/src/duckdb/src/function/table/read_csv.cpp +100 -17
- package/src/duckdb/src/function/table/system_functions.cpp +1 -0
- package/src/duckdb/src/function/table/table_scan.cpp +9 -0
- package/src/duckdb/src/function/table/version/pragma_version.cpp +46 -2
- package/src/duckdb/src/include/duckdb/common/adbc/adbc.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/bswap.hpp +42 -0
- package/src/duckdb/src/include/duckdb/common/dl.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/enum_util.hpp +616 -584
- package/src/duckdb/src/include/duckdb/common/enums/cte_materialize.hpp +21 -0
- package/src/duckdb/src/include/duckdb/common/enums/joinref_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/enums/optimizer_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/extra_operator_info.hpp +27 -0
- package/src/duckdb/src/include/duckdb/common/extra_type_info.hpp +219 -0
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +6 -4
- package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +10 -42
- package/src/duckdb/src/include/duckdb/common/mutex.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/operator/cast_operators.hpp +43 -3
- package/src/duckdb/src/include/duckdb/common/operator/numeric_cast.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/radix.hpp +9 -20
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +6 -21
- package/src/duckdb/src/include/duckdb/common/row_operations/row_operations.hpp +3 -3
- package/src/duckdb/src/include/duckdb/common/sort/partition_state.hpp +13 -0
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +11 -0
- package/src/duckdb/src/include/duckdb/common/types/batched_data_collection.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/types/bit.hpp +81 -0
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_allocator.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection.hpp +6 -1
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_collection_segment.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_scan_states.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/date.hpp +7 -5
- package/src/duckdb/src/include/duckdb/common/types/list_segment.hpp +6 -8
- package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +0 -1
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_states.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +9 -0
- package/src/duckdb/src/include/duckdb/common/types.hpp +1 -15
- package/src/duckdb/src/include/duckdb/common/virtual_file_system.hpp +38 -97
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/corr.hpp +4 -4
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/covar.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/holistic_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/nested_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_count.hpp +1 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_slope.hpp +3 -3
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/bit_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/blob_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/date_functions.hpp +31 -11
- package/src/duckdb/src/include/duckdb/core_functions/scalar/enum_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/list_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/math_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/operators_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/random_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/struct_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/core_functions/scalar/union_functions.hpp +3 -1
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +21 -3
- package/src/duckdb/src/include/duckdb/execution/executor.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +4 -5
- package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +31 -27
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +6 -14
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +4 -10
- package/src/duckdb/src/include/duckdb/execution/index/art/node16.hpp +3 -6
- package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +3 -6
- package/src/duckdb/src/include/duckdb/execution/index/art/node4.hpp +5 -8
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +3 -6
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +63 -52
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_asof_join.hpp +3 -10
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_range_join.hpp +12 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/base_csv_reader.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_line_info.hpp +4 -3
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_reader_options.hpp +8 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/csv_rejects_table.hpp +36 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/parallel_csv_reader.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +10 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +5 -1
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_cte.hpp +62 -0
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +8 -2
- package/src/duckdb/src/include/duckdb/execution/partitionable_hashtable.hpp +5 -1
- package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/radix_partitioned_hashtable.hpp +10 -3
- package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +51 -40
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/aggregate_state.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/built_in_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/scalar/compressed_materialization_functions.hpp +49 -0
- package/src/duckdb/src/include/duckdb/function/scalar/list/contains_or_position.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +5 -0
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +2 -0
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +5 -0
- package/src/duckdb/src/include/duckdb/main/config.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/connection.hpp +1 -2
- package/src/duckdb/src/include/duckdb/main/relation/cross_product_relation.hpp +4 -1
- package/src/duckdb/src/include/duckdb/main/relation/join_relation.hpp +5 -2
- package/src/duckdb/src/include/duckdb/main/relation.hpp +4 -2
- package/src/duckdb/src/include/duckdb/main/settings.hpp +39 -1
- package/src/duckdb/src/include/duckdb/optimizer/column_binding_replacer.hpp +47 -0
- package/src/duckdb/src/include/duckdb/optimizer/compressed_materialization.hpp +132 -0
- package/src/duckdb/src/include/duckdb/optimizer/deliminator.hpp +13 -16
- package/src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp +3 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/join_order/estimated_properties.hpp +10 -1
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_order_optimizer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph.hpp +3 -0
- package/src/duckdb/src/include/duckdb/optimizer/matcher/set_matcher.hpp +13 -0
- package/src/duckdb/src/include/duckdb/optimizer/optimizer.hpp +3 -0
- package/src/duckdb/src/include/duckdb/optimizer/remove_duplicate_groups.hpp +40 -0
- package/src/duckdb/src/include/duckdb/optimizer/statistics_propagator.hpp +11 -3
- package/src/duckdb/src/include/duckdb/optimizer/topn_optimizer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/common_table_expression_info.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/default_expression.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/cte_node.hpp +54 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/query_node.hpp +2 -1
- package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/joinref.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +15 -8
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +12 -5
- package/src/duckdb/src/include/duckdb/planner/bound_tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/column_binding.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/constraints/bound_unique_constraint.hpp +3 -3
- package/src/duckdb/src/include/duckdb/planner/expression_binder/lateral_binder.hpp +0 -2
- package/src/duckdb/src/include/duckdb/planner/logical_tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/list.hpp +2 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +5 -5
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +7 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_dependent_join.hpp +43 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_materialized_cte.hpp +49 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +5 -4
- package/src/duckdb/src/include/duckdb/planner/query_node/bound_cte_node.hpp +44 -0
- package/src/duckdb/src/include/duckdb/planner/query_node/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/subquery/flatten_dependent_join.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/subquery/has_correlated_expressions.hpp +4 -1
- package/src/duckdb/src/include/duckdb/planner/subquery/recursive_dependent_join_planner.hpp +31 -0
- package/src/duckdb/src/include/duckdb/planner/subquery/rewrite_correlated_expressions.hpp +8 -2
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_cteref.hpp +5 -2
- package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/block_manager.hpp +3 -3
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/object_cache.hpp +22 -0
- package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +4 -0
- package/src/duckdb/src/include/duckdb/storage/table/chunk_info.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +1 -3
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +2 -3
- package/src/duckdb/src/include/duckdb.h +28 -0
- package/src/duckdb/src/main/capi/arrow-c.cpp +155 -1
- package/src/duckdb/src/main/capi/duckdb_value-c.cpp +1 -1
- package/src/duckdb/src/main/config.cpp +4 -0
- package/src/duckdb/src/main/database.cpp +1 -1
- package/src/duckdb/src/main/extension/extension_helper.cpp +96 -89
- package/src/duckdb/src/main/extension/extension_install.cpp +9 -0
- package/src/duckdb/src/main/extension/extension_load.cpp +10 -1
- package/src/duckdb/src/main/relation/cross_product_relation.cpp +4 -3
- package/src/duckdb/src/main/relation/join_relation.cpp +5 -5
- package/src/duckdb/src/main/relation.cpp +6 -5
- package/src/duckdb/src/main/settings/settings.cpp +79 -18
- package/src/duckdb/src/optimizer/column_binding_replacer.cpp +43 -0
- package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +1 -2
- package/src/duckdb/src/optimizer/compressed_materialization/compress_aggregate.cpp +140 -0
- package/src/duckdb/src/optimizer/compressed_materialization/compress_distinct.cpp +42 -0
- package/src/duckdb/src/optimizer/compressed_materialization/compress_order.cpp +65 -0
- package/src/duckdb/src/optimizer/compressed_materialization.cpp +478 -0
- package/src/duckdb/src/optimizer/deliminator.cpp +176 -321
- package/src/duckdb/src/optimizer/filter_pushdown.cpp +9 -0
- package/src/duckdb/src/optimizer/join_order/estimated_properties.cpp +7 -0
- package/src/duckdb/src/optimizer/join_order/join_node.cpp +2 -2
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +113 -82
- package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +2 -6
- package/src/duckdb/src/optimizer/join_order/query_graph.cpp +22 -14
- package/src/duckdb/src/optimizer/optimizer.cpp +51 -14
- package/src/duckdb/src/optimizer/pushdown/pushdown_cross_product.cpp +5 -5
- package/src/duckdb/src/optimizer/pushdown/pushdown_get.cpp +0 -1
- package/src/duckdb/src/optimizer/remove_duplicate_groups.cpp +127 -0
- package/src/duckdb/src/optimizer/remove_unused_columns.cpp +4 -0
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +154 -15
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +65 -8
- package/src/duckdb/src/optimizer/statistics/operator/propagate_order.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics_propagator.cpp +7 -5
- package/src/duckdb/src/optimizer/topn_optimizer.cpp +20 -10
- package/src/duckdb/src/parallel/executor.cpp +15 -0
- package/src/duckdb/src/parallel/task_scheduler.cpp +11 -2
- package/src/duckdb/src/parser/common_table_expression_info.cpp +2 -0
- package/src/duckdb/src/parser/expression/between_expression.cpp +3 -15
- package/src/duckdb/src/parser/expression/case_expression.cpp +0 -13
- package/src/duckdb/src/parser/expression/cast_expression.cpp +3 -14
- package/src/duckdb/src/parser/expression/collate_expression.cpp +3 -13
- package/src/duckdb/src/parser/expression/columnref_expression.cpp +3 -12
- package/src/duckdb/src/parser/expression/comparison_expression.cpp +3 -13
- package/src/duckdb/src/parser/expression/conjunction_expression.cpp +0 -12
- package/src/duckdb/src/parser/expression/constant_expression.cpp +3 -11
- package/src/duckdb/src/parser/expression/default_expression.cpp +0 -4
- package/src/duckdb/src/parser/expression/function_expression.cpp +3 -32
- package/src/duckdb/src/parser/expression/lambda_expression.cpp +4 -14
- package/src/duckdb/src/parser/expression/operator_expression.cpp +0 -12
- package/src/duckdb/src/parser/expression/parameter_expression.cpp +0 -12
- package/src/duckdb/src/parser/expression/positional_reference_expression.cpp +4 -11
- package/src/duckdb/src/parser/expression/star_expression.cpp +0 -19
- package/src/duckdb/src/parser/expression/subquery_expression.cpp +0 -18
- package/src/duckdb/src/parser/expression/window_expression.cpp +3 -39
- package/src/duckdb/src/parser/parsed_expression.cpp +0 -70
- package/src/duckdb/src/parser/parsed_expression_iterator.cpp +7 -0
- package/src/duckdb/src/parser/parser.cpp +8 -2
- package/src/duckdb/src/parser/query_node/cte_node.cpp +58 -0
- package/src/duckdb/src/parser/query_node/recursive_cte_node.cpp +0 -19
- package/src/duckdb/src/parser/query_node/select_node.cpp +0 -29
- package/src/duckdb/src/parser/query_node/set_operation_node.cpp +0 -15
- package/src/duckdb/src/parser/query_node.cpp +15 -37
- package/src/duckdb/src/parser/result_modifier.cpp +0 -74
- package/src/duckdb/src/parser/tableref/basetableref.cpp +0 -19
- package/src/duckdb/src/parser/tableref/emptytableref.cpp +0 -4
- package/src/duckdb/src/parser/tableref/expressionlistref.cpp +0 -15
- package/src/duckdb/src/parser/tableref/joinref.cpp +3 -23
- package/src/duckdb/src/parser/tableref/pivotref.cpp +0 -23
- package/src/duckdb/src/parser/tableref/subqueryref.cpp +3 -13
- package/src/duckdb/src/parser/tableref/table_function.cpp +0 -15
- package/src/duckdb/src/parser/tableref.cpp +0 -44
- package/src/duckdb/src/parser/transform/expression/transform_constant.cpp +55 -3
- package/src/duckdb/src/parser/transform/expression/transform_expression.cpp +2 -0
- package/src/duckdb/src/parser/transform/expression/transform_multi_assign_reference.cpp +44 -0
- package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +19 -1
- package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +13 -0
- package/src/duckdb/src/parser/transform/statement/transform_delete.cpp +6 -1
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +6 -1
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +7 -2
- package/src/duckdb/src/parser/transform/statement/transform_pragma.cpp +14 -11
- package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +11 -2
- package/src/duckdb/src/parser/transform/statement/transform_update.cpp +6 -1
- package/src/duckdb/src/parser/transformer.cpp +15 -0
- package/src/duckdb/src/planner/binder/query_node/bind_cte_node.cpp +64 -0
- package/src/duckdb/src/planner/binder/query_node/plan_cte_node.cpp +26 -0
- package/src/duckdb/src/planner/binder/query_node/plan_recursive_cte_node.cpp +5 -5
- package/src/duckdb/src/planner/binder/query_node/plan_setop.cpp +4 -4
- package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +32 -29
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +5 -4
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +11 -2
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +32 -5
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +116 -49
- package/src/duckdb/src/planner/binder/tableref/plan_cteref.cpp +1 -1
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +64 -26
- package/src/duckdb/src/planner/binder/tableref/plan_subqueryref.cpp +3 -3
- package/src/duckdb/src/planner/binder.cpp +44 -31
- package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +4 -31
- package/src/duckdb/src/planner/expression_binder.cpp +3 -0
- package/src/duckdb/src/planner/expression_iterator.cpp +6 -0
- package/src/duckdb/src/planner/logical_operator.cpp +5 -0
- package/src/duckdb/src/planner/logical_operator_visitor.cpp +2 -0
- package/src/duckdb/src/planner/operator/logical_cteref.cpp +3 -1
- package/src/duckdb/src/planner/operator/logical_dependent_join.cpp +26 -0
- package/src/duckdb/src/planner/operator/logical_get.cpp +9 -4
- package/src/duckdb/src/planner/operator/logical_materialized_cte.cpp +21 -0
- package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +90 -38
- package/src/duckdb/src/planner/subquery/has_correlated_expressions.cpp +22 -7
- package/src/duckdb/src/planner/subquery/rewrite_correlated_expressions.cpp +65 -7
- package/src/duckdb/src/storage/arena_allocator.cpp +1 -2
- package/src/duckdb/src/storage/buffer/block_manager.cpp +3 -0
- package/src/duckdb/src/storage/checkpoint_manager.cpp +3 -0
- package/src/duckdb/src/storage/compression/rle.cpp +0 -1
- package/src/duckdb/src/storage/data_table.cpp +1 -1
- package/src/duckdb/src/storage/local_storage.cpp +3 -3
- package/src/duckdb/src/storage/serialization/serialize_parsed_expression.cpp +340 -0
- package/src/duckdb/src/storage/serialization/serialize_query_node.cpp +122 -0
- package/src/duckdb/src/storage/serialization/serialize_result_modifier.cpp +86 -0
- package/src/duckdb/src/storage/serialization/serialize_tableref.cpp +166 -0
- package/src/duckdb/src/storage/serialization/serialize_types.cpp +127 -0
- package/src/duckdb/src/storage/single_file_block_manager.cpp +23 -0
- package/src/duckdb/src/storage/statistics/string_stats.cpp +21 -2
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/src/storage/table/chunk_info.cpp +17 -0
- package/src/duckdb/src/storage/table/row_group.cpp +25 -9
- package/src/duckdb/src/storage/table/row_group_collection.cpp +19 -18
- package/src/duckdb/third_party/concurrentqueue/concurrentqueue.h +2 -2
- package/src/duckdb/third_party/concurrentqueue/lightweightsemaphore.h +76 -0
- package/src/duckdb/third_party/fast_float/fast_float/fast_float.h +2 -0
- package/src/duckdb/third_party/httplib/httplib.hpp +10 -1
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +9 -0
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +2 -1
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +12487 -12331
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +6 -6
- package/src/duckdb/ub_src_common.cpp +2 -0
- package/src/duckdb/ub_src_execution_index_art.cpp +0 -2
- package/src/duckdb/ub_src_execution_operator_persistent.cpp +2 -0
- package/src/duckdb/ub_src_execution_operator_set.cpp +2 -0
- package/src/duckdb/ub_src_execution_physical_plan.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_compressed_materialization.cpp +4 -0
- package/src/duckdb/ub_src_function_scalar_list.cpp +2 -0
- package/src/duckdb/ub_src_optimizer.cpp +6 -0
- package/src/duckdb/ub_src_optimizer_compressed_materialization.cpp +6 -0
- package/src/duckdb/ub_src_optimizer_statistics_expression.cpp +0 -2
- package/src/duckdb/ub_src_parser_query_node.cpp +2 -0
- package/src/duckdb/ub_src_parser_transform_expression.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_query_node.cpp +4 -0
- package/src/duckdb/ub_src_planner_operator.cpp +4 -0
- package/src/duckdb/ub_src_storage_serialization.cpp +10 -0
- package/src/statement.cpp +10 -3
- package/test/test_all_types.test.ts +233 -0
- package/tsconfig.json +1 -0
- package/src/duckdb/src/execution/index/art/prefix_segment.cpp +0 -42
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix_segment.hpp +0 -40
- package/src/duckdb/src/optimizer/statistics/expression/propagate_and_compress.cpp +0 -118
@@ -354,6 +354,49 @@ struct DatePart {
|
|
354
354
|
}
|
355
355
|
};
|
356
356
|
|
357
|
+
struct EpochNanosecondsOperator {
|
358
|
+
template <class TA, class TR>
|
359
|
+
static inline TR Operation(TA input) {
|
360
|
+
return input.micros * Interval::NANOS_PER_MICRO;
|
361
|
+
}
|
362
|
+
|
363
|
+
template <class T>
|
364
|
+
static unique_ptr<BaseStatistics> PropagateStatistics(ClientContext &context, FunctionStatisticsInput &input) {
|
365
|
+
return PropagateDatePartStatistics<T, EpochNanosecondsOperator>(input.child_stats);
|
366
|
+
}
|
367
|
+
};
|
368
|
+
|
369
|
+
struct EpochMicrosecondsOperator {
|
370
|
+
template <class TA, class TR>
|
371
|
+
static inline TR Operation(TA input) {
|
372
|
+
return input.micros;
|
373
|
+
}
|
374
|
+
|
375
|
+
template <class T>
|
376
|
+
static unique_ptr<BaseStatistics> PropagateStatistics(ClientContext &context, FunctionStatisticsInput &input) {
|
377
|
+
return PropagateDatePartStatistics<T, EpochMicrosecondsOperator>(input.child_stats);
|
378
|
+
}
|
379
|
+
};
|
380
|
+
|
381
|
+
struct EpochMillisOperator {
|
382
|
+
template <class TA, class TR>
|
383
|
+
static inline TR Operation(TA input) {
|
384
|
+
return input.micros / Interval::MICROS_PER_MSEC;
|
385
|
+
}
|
386
|
+
|
387
|
+
template <class T>
|
388
|
+
static unique_ptr<BaseStatistics> PropagateStatistics(ClientContext &context, FunctionStatisticsInput &input) {
|
389
|
+
return PropagateDatePartStatistics<T, EpochMillisOperator>(input.child_stats);
|
390
|
+
}
|
391
|
+
|
392
|
+
static void Inverse(DataChunk &input, ExpressionState &state, Vector &result) {
|
393
|
+
D_ASSERT(input.ColumnCount() == 1);
|
394
|
+
|
395
|
+
UnaryExecutor::Execute<int64_t, timestamp_t>(input.data[0], result, input.size(),
|
396
|
+
[&](int64_t input) { return Timestamp::FromEpochMs(input); });
|
397
|
+
}
|
398
|
+
};
|
399
|
+
|
357
400
|
struct MicrosecondsOperator {
|
358
401
|
template <class TA, class TR>
|
359
402
|
static inline TR Operation(TA input) {
|
@@ -521,9 +564,8 @@ struct DatePart {
|
|
521
564
|
}
|
522
565
|
|
523
566
|
template <typename P>
|
524
|
-
static inline
|
525
|
-
|
526
|
-
return value;
|
567
|
+
static inline P HasPartValue(P *part_values, DatePartSpecifier part) {
|
568
|
+
return part_values[int(part)];
|
527
569
|
}
|
528
570
|
|
529
571
|
template <class TA, class TR>
|
@@ -535,28 +577,36 @@ struct DatePart {
|
|
535
577
|
int32_t dd = 1;
|
536
578
|
if (mask & YMD) {
|
537
579
|
Date::Convert(input, yyyy, mm, dd);
|
538
|
-
|
580
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::YEAR);
|
581
|
+
if (part_data) {
|
539
582
|
part_data[idx] = yyyy;
|
540
583
|
}
|
541
|
-
|
584
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::MONTH);
|
585
|
+
if (part_data) {
|
542
586
|
part_data[idx] = mm;
|
543
587
|
}
|
544
|
-
|
588
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::DAY);
|
589
|
+
if (part_data) {
|
545
590
|
part_data[idx] = dd;
|
546
591
|
}
|
547
|
-
|
592
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::DECADE);
|
593
|
+
if (part_data) {
|
548
594
|
part_data[idx] = DecadeOperator::DecadeFromYear(yyyy);
|
549
595
|
}
|
550
|
-
|
596
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::CENTURY);
|
597
|
+
if (part_data) {
|
551
598
|
part_data[idx] = CenturyOperator::CenturyFromYear(yyyy);
|
552
599
|
}
|
553
|
-
|
600
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::MILLENNIUM);
|
601
|
+
if (part_data) {
|
554
602
|
part_data[idx] = MillenniumOperator::MillenniumFromYear(yyyy);
|
555
603
|
}
|
556
|
-
|
604
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::QUARTER);
|
605
|
+
if (part_data) {
|
557
606
|
part_data[idx] = QuarterOperator::QuarterFromMonth(mm);
|
558
607
|
}
|
559
|
-
|
608
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::ERA);
|
609
|
+
if (part_data) {
|
560
610
|
part_data[idx] = EraOperator::EraFromYear(yyyy);
|
561
611
|
}
|
562
612
|
}
|
@@ -564,10 +614,12 @@ struct DatePart {
|
|
564
614
|
// Week calculations
|
565
615
|
if (mask & DOW) {
|
566
616
|
auto isodow = Date::ExtractISODayOfTheWeek(input);
|
567
|
-
|
617
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::DOW);
|
618
|
+
if (part_data) {
|
568
619
|
part_data[idx] = DayOfWeekOperator::DayOfWeekFromISO(isodow);
|
569
620
|
}
|
570
|
-
|
621
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::ISODOW);
|
622
|
+
if (part_data) {
|
571
623
|
part_data[idx] = isodow;
|
572
624
|
}
|
573
625
|
}
|
@@ -577,24 +629,29 @@ struct DatePart {
|
|
577
629
|
int32_t ww = 0;
|
578
630
|
int32_t iyyy = 0;
|
579
631
|
Date::ExtractISOYearWeek(input, iyyy, ww);
|
580
|
-
|
632
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::WEEK);
|
633
|
+
if (part_data) {
|
581
634
|
part_data[idx] = ww;
|
582
635
|
}
|
583
|
-
|
636
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::ISOYEAR);
|
637
|
+
if (part_data) {
|
584
638
|
part_data[idx] = iyyy;
|
585
639
|
}
|
586
|
-
|
640
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::YEARWEEK);
|
641
|
+
if (part_data) {
|
587
642
|
part_data[idx] = YearWeekOperator::YearWeekFromParts(iyyy, ww);
|
588
643
|
}
|
589
644
|
}
|
590
645
|
|
591
646
|
if (mask & EPOCH) {
|
592
|
-
|
647
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::EPOCH);
|
648
|
+
if (part_data) {
|
593
649
|
part_data[idx] = Date::Epoch(input);
|
594
650
|
}
|
595
651
|
}
|
596
652
|
if (mask & DOY) {
|
597
|
-
|
653
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::DOY);
|
654
|
+
if (part_data) {
|
598
655
|
part_data[idx] = Date::ExtractDayOfTheYear(input);
|
599
656
|
}
|
600
657
|
}
|
@@ -798,6 +855,51 @@ int64_t DatePart::YearWeekOperator::Operation(dtime_t input) {
|
|
798
855
|
throw NotImplementedException("\"time\" units \"yearweek\" not recognized");
|
799
856
|
}
|
800
857
|
|
858
|
+
template <>
|
859
|
+
int64_t DatePart::EpochNanosecondsOperator::Operation(timestamp_t input) {
|
860
|
+
return Timestamp::GetEpochNanoSeconds(input);
|
861
|
+
}
|
862
|
+
|
863
|
+
template <>
|
864
|
+
int64_t DatePart::EpochNanosecondsOperator::Operation(date_t input) {
|
865
|
+
return Date::EpochNanoseconds(input);
|
866
|
+
}
|
867
|
+
|
868
|
+
template <>
|
869
|
+
int64_t DatePart::EpochNanosecondsOperator::Operation(interval_t input) {
|
870
|
+
return Interval::GetNanoseconds(input);
|
871
|
+
}
|
872
|
+
|
873
|
+
template <>
|
874
|
+
int64_t DatePart::EpochMicrosecondsOperator::Operation(timestamp_t input) {
|
875
|
+
return Timestamp::GetEpochMicroSeconds(input);
|
876
|
+
}
|
877
|
+
|
878
|
+
template <>
|
879
|
+
int64_t DatePart::EpochMicrosecondsOperator::Operation(date_t input) {
|
880
|
+
return Date::EpochMicroseconds(input);
|
881
|
+
}
|
882
|
+
|
883
|
+
template <>
|
884
|
+
int64_t DatePart::EpochMicrosecondsOperator::Operation(interval_t input) {
|
885
|
+
return Interval::GetMicro(input);
|
886
|
+
}
|
887
|
+
|
888
|
+
template <>
|
889
|
+
int64_t DatePart::EpochMillisOperator::Operation(timestamp_t input) {
|
890
|
+
return Timestamp::GetEpochMs(input);
|
891
|
+
}
|
892
|
+
|
893
|
+
template <>
|
894
|
+
int64_t DatePart::EpochMillisOperator::Operation(date_t input) {
|
895
|
+
return Date::EpochMilliseconds(input);
|
896
|
+
}
|
897
|
+
|
898
|
+
template <>
|
899
|
+
int64_t DatePart::EpochMillisOperator::Operation(interval_t input) {
|
900
|
+
return Interval::GetMilli(input);
|
901
|
+
}
|
902
|
+
|
801
903
|
template <>
|
802
904
|
int64_t DatePart::MicrosecondsOperator::Operation(timestamp_t input) {
|
803
905
|
auto time = Timestamp::GetTime(input);
|
@@ -949,37 +1051,47 @@ void DatePart::StructOperator::Operation(int64_t **part_values, const dtime_t &i
|
|
949
1051
|
int64_t *part_data;
|
950
1052
|
if (mask & TIME) {
|
951
1053
|
const auto micros = MicrosecondsOperator::Operation<dtime_t, int64_t>(input);
|
952
|
-
|
1054
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::MICROSECONDS);
|
1055
|
+
if (part_data) {
|
953
1056
|
part_data[idx] = micros;
|
954
1057
|
}
|
955
|
-
|
1058
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::MILLISECONDS);
|
1059
|
+
if (part_data) {
|
956
1060
|
part_data[idx] = micros / Interval::MICROS_PER_MSEC;
|
957
1061
|
}
|
958
|
-
|
1062
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::SECOND);
|
1063
|
+
if (part_data) {
|
959
1064
|
part_data[idx] = micros / Interval::MICROS_PER_SEC;
|
960
1065
|
}
|
961
|
-
|
1066
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::MINUTE);
|
1067
|
+
if (part_data) {
|
962
1068
|
part_data[idx] = MinutesOperator::Operation<dtime_t, int64_t>(input);
|
963
1069
|
}
|
964
|
-
|
1070
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::HOUR);
|
1071
|
+
if (part_data) {
|
965
1072
|
part_data[idx] = HoursOperator::Operation<dtime_t, int64_t>(input);
|
966
1073
|
}
|
967
1074
|
}
|
968
1075
|
|
969
1076
|
if (mask & EPOCH) {
|
970
|
-
|
1077
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::EPOCH);
|
1078
|
+
if (part_data) {
|
971
1079
|
part_data[idx] = EpochOperator::Operation<dtime_t, int64_t>(input);
|
1080
|
+
;
|
972
1081
|
}
|
973
1082
|
}
|
974
1083
|
|
975
1084
|
if (mask & ZONE) {
|
976
|
-
|
1085
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE);
|
1086
|
+
if (part_data) {
|
977
1087
|
part_data[idx] = 0;
|
978
1088
|
}
|
979
|
-
|
1089
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE_HOUR);
|
1090
|
+
if (part_data) {
|
980
1091
|
part_data[idx] = 0;
|
981
1092
|
}
|
982
|
-
|
1093
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE_MINUTE);
|
1094
|
+
if (part_data) {
|
983
1095
|
part_data[idx] = 0;
|
984
1096
|
}
|
985
1097
|
}
|
@@ -998,8 +1110,8 @@ void DatePart::StructOperator::Operation(int64_t **part_values, const timestamp_
|
|
998
1110
|
Operation(part_values, t, idx, mask & ~EPOCH);
|
999
1111
|
|
1000
1112
|
if (mask & EPOCH) {
|
1001
|
-
|
1002
|
-
if (
|
1113
|
+
auto part_data = HasPartValue(part_values, DatePartSpecifier::EPOCH);
|
1114
|
+
if (part_data) {
|
1003
1115
|
part_data[idx] = EpochOperator::Operation<timestamp_t, int64_t>(input);
|
1004
1116
|
}
|
1005
1117
|
}
|
@@ -1011,50 +1123,63 @@ void DatePart::StructOperator::Operation(int64_t **part_values, const interval_t
|
|
1011
1123
|
int64_t *part_data;
|
1012
1124
|
if (mask & YMD) {
|
1013
1125
|
const auto mm = input.months % Interval::MONTHS_PER_YEAR;
|
1014
|
-
|
1126
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::YEAR);
|
1127
|
+
if (part_data) {
|
1015
1128
|
part_data[idx] = input.months / Interval::MONTHS_PER_YEAR;
|
1016
1129
|
}
|
1017
|
-
|
1130
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::MONTH);
|
1131
|
+
if (part_data) {
|
1018
1132
|
part_data[idx] = mm;
|
1019
1133
|
}
|
1020
|
-
|
1134
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::DAY);
|
1135
|
+
if (part_data) {
|
1021
1136
|
part_data[idx] = input.days;
|
1022
1137
|
}
|
1023
|
-
|
1138
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::DECADE);
|
1139
|
+
if (part_data) {
|
1024
1140
|
part_data[idx] = input.months / Interval::MONTHS_PER_DECADE;
|
1025
1141
|
}
|
1026
|
-
|
1142
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::CENTURY);
|
1143
|
+
if (part_data) {
|
1027
1144
|
part_data[idx] = input.months / Interval::MONTHS_PER_CENTURY;
|
1028
1145
|
}
|
1029
|
-
|
1146
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::MILLENNIUM);
|
1147
|
+
if (part_data) {
|
1030
1148
|
part_data[idx] = input.months / Interval::MONTHS_PER_MILLENIUM;
|
1031
1149
|
}
|
1032
|
-
|
1150
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::QUARTER);
|
1151
|
+
if (part_data) {
|
1033
1152
|
part_data[idx] = mm / Interval::MONTHS_PER_QUARTER + 1;
|
1034
1153
|
}
|
1035
1154
|
}
|
1036
1155
|
|
1037
1156
|
if (mask & TIME) {
|
1038
1157
|
const auto micros = MicrosecondsOperator::Operation<interval_t, int64_t>(input);
|
1039
|
-
|
1158
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::MICROSECONDS);
|
1159
|
+
if (part_data) {
|
1040
1160
|
part_data[idx] = micros;
|
1041
1161
|
}
|
1042
|
-
|
1162
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::MILLISECONDS);
|
1163
|
+
if (part_data) {
|
1043
1164
|
part_data[idx] = micros / Interval::MICROS_PER_MSEC;
|
1044
1165
|
}
|
1045
|
-
|
1166
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::SECOND);
|
1167
|
+
if (part_data) {
|
1046
1168
|
part_data[idx] = micros / Interval::MICROS_PER_SEC;
|
1047
1169
|
}
|
1048
|
-
|
1170
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::MINUTE);
|
1171
|
+
if (part_data) {
|
1049
1172
|
part_data[idx] = MinutesOperator::Operation<interval_t, int64_t>(input);
|
1050
1173
|
}
|
1051
|
-
|
1174
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::HOUR);
|
1175
|
+
if (part_data) {
|
1052
1176
|
part_data[idx] = HoursOperator::Operation<interval_t, int64_t>(input);
|
1053
1177
|
}
|
1054
1178
|
}
|
1055
1179
|
|
1056
1180
|
if (mask & EPOCH) {
|
1057
|
-
|
1181
|
+
part_data = HasPartValue(part_values, DatePartSpecifier::EPOCH);
|
1182
|
+
if (part_data) {
|
1058
1183
|
part_data[idx] = EpochOperator::Operation<interval_t, int64_t>(input);
|
1059
1184
|
}
|
1060
1185
|
}
|
@@ -1466,6 +1591,47 @@ ScalarFunctionSet EpochFun::GetFunctions() {
|
|
1466
1591
|
return GetTimePartFunction<DatePart::EpochOperator>();
|
1467
1592
|
}
|
1468
1593
|
|
1594
|
+
ScalarFunctionSet EpochNsFun::GetFunctions() {
|
1595
|
+
using OP = DatePart::EpochNanosecondsOperator;
|
1596
|
+
auto operator_set = GetTimePartFunction<OP>();
|
1597
|
+
|
1598
|
+
// TIMESTAMP WITH TIME ZONE has the same representation as TIMESTAMP so no need to defer to ICU
|
1599
|
+
auto tstz_func = DatePart::UnaryFunction<timestamp_t, int64_t, OP>;
|
1600
|
+
auto tstz_stats = OP::template PropagateStatistics<timestamp_t>;
|
1601
|
+
operator_set.AddFunction(
|
1602
|
+
ScalarFunction({LogicalType::TIMESTAMP_TZ}, LogicalType::BIGINT, tstz_func, nullptr, nullptr, tstz_stats));
|
1603
|
+
return operator_set;
|
1604
|
+
}
|
1605
|
+
|
1606
|
+
ScalarFunctionSet EpochUsFun::GetFunctions() {
|
1607
|
+
using OP = DatePart::EpochMicrosecondsOperator;
|
1608
|
+
auto operator_set = GetTimePartFunction<OP>();
|
1609
|
+
|
1610
|
+
// TIMESTAMP WITH TIME ZONE has the same representation as TIMESTAMP so no need to defer to ICU
|
1611
|
+
auto tstz_func = DatePart::UnaryFunction<timestamp_t, int64_t, OP>;
|
1612
|
+
auto tstz_stats = OP::template PropagateStatistics<timestamp_t>;
|
1613
|
+
operator_set.AddFunction(
|
1614
|
+
ScalarFunction({LogicalType::TIMESTAMP_TZ}, LogicalType::BIGINT, tstz_func, nullptr, nullptr, tstz_stats));
|
1615
|
+
return operator_set;
|
1616
|
+
}
|
1617
|
+
|
1618
|
+
ScalarFunctionSet EpochMsFun::GetFunctions() {
|
1619
|
+
using OP = DatePart::EpochMillisOperator;
|
1620
|
+
auto operator_set = GetTimePartFunction<OP>();
|
1621
|
+
|
1622
|
+
// TIMESTAMP WITH TIME ZONE has the same representation as TIMESTAMP so no need to defer to ICU
|
1623
|
+
auto tstz_func = DatePart::UnaryFunction<timestamp_t, int64_t, OP>;
|
1624
|
+
auto tstz_stats = OP::template PropagateStatistics<timestamp_t>;
|
1625
|
+
operator_set.AddFunction(
|
1626
|
+
ScalarFunction({LogicalType::TIMESTAMP_TZ}, LogicalType::BIGINT, tstz_func, nullptr, nullptr, tstz_stats));
|
1627
|
+
|
1628
|
+
// Legacy inverse BIGINT => TIMESTAMP
|
1629
|
+
operator_set.AddFunction(
|
1630
|
+
ScalarFunction({LogicalType::BIGINT}, LogicalType::TIMESTAMP, DatePart::EpochMillisOperator::Inverse));
|
1631
|
+
|
1632
|
+
return operator_set;
|
1633
|
+
}
|
1634
|
+
|
1469
1635
|
ScalarFunctionSet MicrosecondsFun::GetFunctions() {
|
1470
1636
|
return GetTimePartFunction<DatePart::MicrosecondsOperator>();
|
1471
1637
|
}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
#include "duckdb/core_functions/scalar/date_functions.hpp"
|
2
|
-
|
3
|
-
#include "duckdb/common/
|
4
|
-
#include "duckdb/common/types/timestamp.hpp"
|
2
|
+
|
3
|
+
#include "duckdb/common/operator/cast_operators.hpp"
|
5
4
|
#include "duckdb/common/vector_operations/vector_operations.hpp"
|
6
5
|
#include "duckdb/common/vector_operations/unary_executor.hpp"
|
7
6
|
|
@@ -9,37 +8,24 @@ namespace duckdb {
|
|
9
8
|
|
10
9
|
struct EpochSecOperator {
|
11
10
|
template <class INPUT_TYPE, class RESULT_TYPE>
|
12
|
-
static RESULT_TYPE Operation(INPUT_TYPE
|
13
|
-
|
11
|
+
static RESULT_TYPE Operation(INPUT_TYPE sec) {
|
12
|
+
int64_t result;
|
13
|
+
if (!TryCast::Operation(sec * Interval::MICROS_PER_SEC, result)) {
|
14
|
+
throw ConversionException("Could not convert epoch seconds to TIMESTAMP WITH TIME ZONE");
|
15
|
+
}
|
16
|
+
return timestamp_t(result);
|
14
17
|
}
|
15
18
|
};
|
16
19
|
|
17
20
|
static void EpochSecFunction(DataChunk &input, ExpressionState &state, Vector &result) {
|
18
21
|
D_ASSERT(input.ColumnCount() == 1);
|
19
22
|
|
20
|
-
UnaryExecutor::Execute<
|
21
|
-
}
|
22
|
-
|
23
|
-
struct EpochMillisOperator {
|
24
|
-
template <class INPUT_TYPE, class RESULT_TYPE>
|
25
|
-
static RESULT_TYPE Operation(INPUT_TYPE input) {
|
26
|
-
return Timestamp::FromEpochMs(input);
|
27
|
-
}
|
28
|
-
};
|
29
|
-
|
30
|
-
static void EpochMillisFunction(DataChunk &input, ExpressionState &state, Vector &result) {
|
31
|
-
D_ASSERT(input.ColumnCount() == 1);
|
32
|
-
|
33
|
-
UnaryExecutor::Execute<int64_t, timestamp_t, EpochMillisOperator>(input.data[0], result, input.size());
|
34
|
-
}
|
35
|
-
|
36
|
-
ScalarFunction EpochMsFun::GetFunction() {
|
37
|
-
return ScalarFunction({LogicalType::BIGINT}, LogicalType::TIMESTAMP, EpochMillisFunction);
|
23
|
+
UnaryExecutor::Execute<double, timestamp_t, EpochSecOperator>(input.data[0], result, input.size());
|
38
24
|
}
|
39
25
|
|
40
26
|
ScalarFunction ToTimestampFun::GetFunction() {
|
41
27
|
// to_timestamp is an alias from Postgres that converts the time in seconds to a timestamp
|
42
|
-
return ScalarFunction({LogicalType::
|
28
|
+
return ScalarFunction({LogicalType::DOUBLE}, LogicalType::TIMESTAMP_TZ, EpochSecFunction);
|
43
29
|
}
|
44
30
|
|
45
31
|
} // namespace duckdb
|
@@ -72,10 +72,21 @@ struct MakeTimestampOperator {
|
|
72
72
|
const auto t = MakeTimeOperator::Operation<HR, MN, SS, dtime_t>(hr, mn, ss);
|
73
73
|
return Timestamp::FromDatetime(d, t);
|
74
74
|
}
|
75
|
+
|
76
|
+
template <typename T, typename RESULT_TYPE>
|
77
|
+
static RESULT_TYPE Operation(T micros) {
|
78
|
+
return timestamp_t(micros);
|
79
|
+
}
|
75
80
|
};
|
76
81
|
|
77
82
|
template <typename T>
|
78
83
|
static void ExecuteMakeTimestamp(DataChunk &input, ExpressionState &state, Vector &result) {
|
84
|
+
if (input.ColumnCount() == 1) {
|
85
|
+
auto func = MakeTimestampOperator::Operation<T, timestamp_t>;
|
86
|
+
UnaryExecutor::Execute<T, timestamp_t>(input.data[0], result, input.size(), func);
|
87
|
+
return;
|
88
|
+
}
|
89
|
+
|
79
90
|
D_ASSERT(input.ColumnCount() == 6);
|
80
91
|
|
81
92
|
auto func = MakeTimestampOperator::Operation<T, T, T, T, T, double, timestamp_t>;
|
@@ -99,10 +110,14 @@ ScalarFunction MakeTimeFun::GetFunction() {
|
|
99
110
|
ExecuteMakeTime<int64_t>);
|
100
111
|
}
|
101
112
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
113
|
+
ScalarFunctionSet MakeTimestampFun::GetFunctions() {
|
114
|
+
ScalarFunctionSet operator_set("make_timestamp");
|
115
|
+
operator_set.AddFunction(ScalarFunction({LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::BIGINT,
|
116
|
+
LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::DOUBLE},
|
117
|
+
LogicalType::TIMESTAMP, ExecuteMakeTimestamp<int64_t>));
|
118
|
+
operator_set.AddFunction(
|
119
|
+
ScalarFunction({LogicalType::BIGINT}, LogicalType::TIMESTAMP, ExecuteMakeTimestamp<int64_t>));
|
120
|
+
return operator_set;
|
106
121
|
}
|
107
122
|
|
108
123
|
} // namespace duckdb
|
@@ -74,7 +74,8 @@ struct StateVector {
|
|
74
74
|
// destroy objects within the aggregate states
|
75
75
|
auto &aggr = aggr_expr->Cast<BoundAggregateExpression>();
|
76
76
|
if (aggr.function.destructor) {
|
77
|
-
|
77
|
+
ArenaAllocator allocator(Allocator::DefaultAllocator());
|
78
|
+
AggregateInputData aggr_input_data(aggr.bind_info.get(), allocator);
|
78
79
|
aggr.function.destructor(state_vector, aggr_input_data, count);
|
79
80
|
}
|
80
81
|
}
|
@@ -181,7 +182,8 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
|
|
181
182
|
auto &func_expr = state.expr.Cast<BoundFunctionExpression>();
|
182
183
|
auto &info = func_expr.bind_info->Cast<ListAggregatesBindData>();
|
183
184
|
auto &aggr = info.aggr_expr->Cast<BoundAggregateExpression>();
|
184
|
-
|
185
|
+
ArenaAllocator allocator(Allocator::DefaultAllocator());
|
186
|
+
AggregateInputData aggr_input_data(aggr.bind_info.get(), allocator);
|
185
187
|
|
186
188
|
D_ASSERT(aggr.function.update);
|
187
189
|
|
@@ -58,9 +58,6 @@ GroupedAggregateHashTable::GroupedAggregateHashTable(ClientContext &context, All
|
|
58
58
|
data_collection = make_uniq<TupleDataCollection>(buffer_manager, layout);
|
59
59
|
data_collection->InitializeAppend(td_pin_state, TupleDataPinProperties::KEEP_EVERYTHING_PINNED);
|
60
60
|
|
61
|
-
hashes_hdl = buffer_manager.Allocate(Storage::BLOCK_SIZE);
|
62
|
-
hashes_hdl_ptr = hashes_hdl.Ptr();
|
63
|
-
|
64
61
|
switch (entry_type) {
|
65
62
|
case HtEntryType::HT_WIDTH_64: {
|
66
63
|
hash_prefix_shift = (HASH_WIDTH - sizeof(aggr_ht_entry_64::salt)) * 8;
|
@@ -100,7 +97,7 @@ void GroupedAggregateHashTable::Destroy() {
|
|
100
97
|
}
|
101
98
|
|
102
99
|
// There are aggregates with destructors: Call the destructor for each of the aggregates
|
103
|
-
RowOperationsState state(aggregate_allocator
|
100
|
+
RowOperationsState state(*aggregate_allocator);
|
104
101
|
TupleDataChunkIterator iterator(*data_collection, TupleDataPinProperties::DESTROY_AFTER_DONE, false);
|
105
102
|
auto &row_locations = iterator.GetChunkState().row_locations;
|
106
103
|
do {
|
@@ -182,10 +179,8 @@ void GroupedAggregateHashTable::Resize(idx_t size) {
|
|
182
179
|
|
183
180
|
bitmask = capacity - 1;
|
184
181
|
const auto byte_size = capacity * sizeof(ENTRY);
|
185
|
-
|
186
|
-
|
187
|
-
hashes_hdl_ptr = hashes_hdl.Ptr();
|
188
|
-
}
|
182
|
+
hashes_hdl = buffer_manager.GetBufferAllocator().Allocate(byte_size);
|
183
|
+
hashes_hdl_ptr = hashes_hdl.get();
|
189
184
|
memset(hashes_hdl_ptr, 0, byte_size);
|
190
185
|
|
191
186
|
if (Count() != 0) {
|
@@ -277,7 +272,7 @@ idx_t GroupedAggregateHashTable::AddChunk(AggregateHTAppendState &state, DataChu
|
|
277
272
|
auto &aggregates = layout.GetAggregates();
|
278
273
|
idx_t filter_idx = 0;
|
279
274
|
idx_t payload_idx = 0;
|
280
|
-
RowOperationsState row_state(aggregate_allocator
|
275
|
+
RowOperationsState row_state(*aggregate_allocator);
|
281
276
|
for (idx_t i = 0; i < aggregates.size(); i++) {
|
282
277
|
auto &aggr = aggregates[i];
|
283
278
|
if (filter_idx >= filter.size() || i < filter[filter_idx]) {
|
@@ -322,7 +317,7 @@ void GroupedAggregateHashTable::FetchAggregates(DataChunk &groups, DataChunk &re
|
|
322
317
|
Vector addresses(LogicalType::POINTER);
|
323
318
|
FindOrCreateGroups(append_state, groups, addresses);
|
324
319
|
// now fetch the aggregates
|
325
|
-
RowOperationsState row_state(aggregate_allocator
|
320
|
+
RowOperationsState row_state(*aggregate_allocator);
|
326
321
|
RowOperations::FinalizeStates(row_state, layout, addresses, result, 0);
|
327
322
|
}
|
328
323
|
|
@@ -581,7 +576,7 @@ void GroupedAggregateHashTable::Combine(GroupedAggregateHashTable &other) {
|
|
581
576
|
}
|
582
577
|
|
583
578
|
FlushMoveState state(*other.data_collection);
|
584
|
-
RowOperationsState row_state(aggregate_allocator
|
579
|
+
RowOperationsState row_state(*aggregate_allocator);
|
585
580
|
while (state.Scan()) {
|
586
581
|
FindOrCreateGroups(state.append_state, state.groups, state.hashes, state.group_addresses, state.new_groups_sel);
|
587
582
|
RowOperations::CombineStates(row_state, layout, state.scan_state.chunk_state.row_locations,
|
@@ -591,14 +586,27 @@ void GroupedAggregateHashTable::Combine(GroupedAggregateHashTable &other) {
|
|
591
586
|
Verify();
|
592
587
|
}
|
593
588
|
|
594
|
-
void GroupedAggregateHashTable::
|
589
|
+
void GroupedAggregateHashTable::Append(GroupedAggregateHashTable &other) {
|
590
|
+
data_collection->Combine(other.GetDataCollection());
|
591
|
+
|
592
|
+
// Inherit ownership to all stored aggregate allocators
|
593
|
+
stored_allocators.emplace_back(other.aggregate_allocator);
|
594
|
+
for (const auto &stored_allocator : other.stored_allocators) {
|
595
|
+
stored_allocators.emplace_back(stored_allocator);
|
596
|
+
}
|
597
|
+
}
|
598
|
+
|
599
|
+
void GroupedAggregateHashTable::Partition(vector<GroupedAggregateHashTable *> &partition_hts, idx_t radix_bits,
|
600
|
+
bool sink_done) {
|
595
601
|
const auto num_partitions = RadixPartitioning::NumberOfPartitions(radix_bits);
|
596
602
|
D_ASSERT(partition_hts.size() == num_partitions);
|
597
603
|
|
598
604
|
// Partition the data
|
605
|
+
auto pin_properties =
|
606
|
+
sink_done ? TupleDataPinProperties::UNPIN_AFTER_DONE : TupleDataPinProperties::KEEP_EVERYTHING_PINNED;
|
599
607
|
auto partitioned_data =
|
600
608
|
make_uniq<RadixPartitionedTupleData>(buffer_manager, layout, radix_bits, layout.ColumnCount() - 1);
|
601
|
-
partitioned_data->Partition(*data_collection,
|
609
|
+
partitioned_data->Partition(*data_collection, pin_properties);
|
602
610
|
D_ASSERT(partitioned_data->GetPartitions().size() == num_partitions);
|
603
611
|
|
604
612
|
// Move the partitioned data collections to the partitioned hash tables and initialize the 1st part of the HT
|
@@ -606,9 +614,17 @@ void GroupedAggregateHashTable::Partition(vector<GroupedAggregateHashTable *> &p
|
|
606
614
|
for (idx_t partition_idx = 0; partition_idx < num_partitions; partition_idx++) {
|
607
615
|
auto &partition_ht = *partition_hts[partition_idx];
|
608
616
|
partition_ht.data_collection = std::move(partitions[partition_idx]);
|
609
|
-
|
610
|
-
|
611
|
-
partition_ht.
|
617
|
+
|
618
|
+
// Inherit ownership to all stored aggregate allocators
|
619
|
+
partition_ht.stored_allocators.emplace_back(aggregate_allocator);
|
620
|
+
for (const auto &stored_allocator : stored_allocators) {
|
621
|
+
partition_ht.stored_allocators.emplace_back(stored_allocator);
|
622
|
+
}
|
623
|
+
|
624
|
+
if (!sink_done) {
|
625
|
+
partition_ht.InitializeFirstPart();
|
626
|
+
partition_ht.Verify();
|
627
|
+
}
|
612
628
|
}
|
613
629
|
}
|
614
630
|
|
@@ -631,7 +647,7 @@ idx_t GroupedAggregateHashTable::Scan(TupleDataParallelScanState &gstate, TupleD
|
|
631
647
|
DataChunk &result) {
|
632
648
|
data_collection->Scan(gstate, lstate, result);
|
633
649
|
|
634
|
-
RowOperationsState row_state(aggregate_allocator
|
650
|
+
RowOperationsState row_state(*aggregate_allocator);
|
635
651
|
const auto group_cols = layout.ColumnCount() - 1;
|
636
652
|
RowOperations::FinalizeStates(row_state, layout, lstate.chunk_state.row_locations, result, group_cols);
|
637
653
|
|
@@ -644,7 +660,7 @@ void GroupedAggregateHashTable::Finalize() {
|
|
644
660
|
}
|
645
661
|
|
646
662
|
// Early release hashes (not needed for partition/scan) and data collection (will be pinned again when scanning)
|
647
|
-
hashes_hdl.
|
663
|
+
hashes_hdl.Reset();
|
648
664
|
data_collection->FinalizePinState(td_pin_state);
|
649
665
|
data_collection->Unpin();
|
650
666
|
|