duckdb 1.0.1-dev22.0 → 1.0.1-dev27.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/.github/workflows/NodeJS.yml +1 -1
- package/binding.gyp +41 -0
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-dateadd.cpp +4 -2
- package/src/duckdb/extension/icu/icu-datefunc.cpp +6 -2
- package/src/duckdb/extension/icu/icu-datesub.cpp +13 -2
- package/src/duckdb/extension/icu/icu-strptime.cpp +6 -6
- package/src/duckdb/extension/icu/icu-table-range.cpp +92 -73
- package/src/duckdb/extension/icu/icu-timebucket.cpp +12 -2
- package/src/duckdb/extension/icu/icu-timezone.cpp +3 -3
- package/src/duckdb/extension/icu/icu_extension.cpp +61 -9
- package/src/duckdb/extension/json/include/json_executors.hpp +20 -23
- package/src/duckdb/extension/json/include/json_functions.hpp +4 -0
- package/src/duckdb/extension/json/include/json_scan.hpp +6 -2
- package/src/duckdb/extension/json/include/json_structure.hpp +12 -9
- package/src/duckdb/extension/json/json_common.cpp +66 -10
- package/src/duckdb/extension/json/json_extension.cpp +13 -5
- package/src/duckdb/extension/json/json_functions/json_array_length.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_create.cpp +21 -4
- package/src/duckdb/extension/json/json_functions/json_exists.cpp +32 -0
- package/src/duckdb/extension/json/json_functions/json_extract.cpp +2 -2
- package/src/duckdb/extension/json/json_functions/json_keys.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_pretty.cpp +32 -0
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +5 -1
- package/src/duckdb/extension/json/json_functions/json_structure.cpp +305 -94
- package/src/duckdb/extension/json/json_functions/json_transform.cpp +1 -1
- package/src/duckdb/extension/json/json_functions/json_type.cpp +3 -3
- package/src/duckdb/extension/json/json_functions/json_value.cpp +42 -0
- package/src/duckdb/extension/json/json_functions/read_json.cpp +16 -2
- package/src/duckdb/extension/json/json_functions/read_json_objects.cpp +3 -2
- package/src/duckdb/extension/json/json_functions.cpp +5 -1
- package/src/duckdb/extension/json/json_scan.cpp +13 -12
- package/src/duckdb/extension/json/serialize_json.cpp +5 -3
- package/src/duckdb/extension/parquet/column_reader.cpp +206 -43
- package/src/duckdb/extension/parquet/column_writer.cpp +133 -62
- package/src/duckdb/extension/parquet/geo_parquet.cpp +391 -0
- package/src/duckdb/extension/parquet/include/boolean_column_reader.hpp +16 -5
- package/src/duckdb/extension/parquet/include/column_reader.hpp +37 -12
- package/src/duckdb/extension/parquet/include/column_writer.hpp +10 -11
- package/src/duckdb/extension/parquet/include/expression_column_reader.hpp +52 -0
- package/src/duckdb/extension/parquet/include/geo_parquet.hpp +139 -0
- package/src/duckdb/extension/parquet/include/parquet_crypto.hpp +13 -8
- package/src/duckdb/extension/parquet/include/parquet_decimal_utils.hpp +3 -0
- package/src/duckdb/extension/parquet/include/parquet_file_metadata_cache.hpp +7 -3
- package/src/duckdb/extension/parquet/include/parquet_reader.hpp +55 -8
- package/src/duckdb/extension/parquet/include/parquet_rle_bp_decoder.hpp +3 -3
- package/src/duckdb/extension/parquet/include/parquet_rle_bp_encoder.hpp +1 -1
- package/src/duckdb/extension/parquet/include/parquet_timestamp.hpp +8 -0
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +21 -7
- package/src/duckdb/extension/parquet/include/resizable_buffer.hpp +33 -11
- package/src/duckdb/extension/parquet/include/string_column_reader.hpp +5 -2
- package/src/duckdb/extension/parquet/include/templated_column_reader.hpp +48 -14
- package/src/duckdb/extension/parquet/parquet_crypto.cpp +109 -61
- package/src/duckdb/extension/parquet/parquet_extension.cpp +305 -72
- package/src/duckdb/extension/parquet/parquet_metadata.cpp +4 -4
- package/src/duckdb/extension/parquet/parquet_reader.cpp +151 -40
- package/src/duckdb/extension/parquet/parquet_statistics.cpp +50 -16
- package/src/duckdb/extension/parquet/parquet_timestamp.cpp +42 -1
- package/src/duckdb/extension/parquet/parquet_writer.cpp +67 -75
- package/src/duckdb/extension/parquet/serialize_parquet.cpp +3 -1
- package/src/duckdb/extension/parquet/zstd_file_system.cpp +5 -1
- package/src/duckdb/src/catalog/catalog.cpp +14 -16
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +14 -11
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +39 -19
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +92 -78
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +10 -2
- package/src/duckdb/src/catalog/catalog_entry/macro_catalog_entry.cpp +10 -3
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +7 -7
- package/src/duckdb/src/catalog/catalog_entry.cpp +6 -3
- package/src/duckdb/src/catalog/catalog_set.cpp +14 -19
- package/src/duckdb/src/catalog/default/default_functions.cpp +179 -166
- package/src/duckdb/src/catalog/default/default_generator.cpp +24 -0
- package/src/duckdb/src/catalog/default/default_schemas.cpp +4 -3
- package/src/duckdb/src/catalog/default/default_table_functions.cpp +148 -0
- package/src/duckdb/src/catalog/default/default_views.cpp +7 -3
- package/src/duckdb/src/catalog/duck_catalog.cpp +7 -1
- package/src/duckdb/src/common/adbc/adbc.cpp +120 -58
- package/src/duckdb/src/common/allocator.cpp +71 -6
- package/src/duckdb/src/common/arrow/appender/bool_data.cpp +8 -7
- package/src/duckdb/src/common/arrow/appender/fixed_size_list_data.cpp +1 -1
- package/src/duckdb/src/common/arrow/appender/union_data.cpp +4 -5
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +55 -21
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +85 -10
- package/src/duckdb/src/common/arrow/arrow_merge_event.cpp +142 -0
- package/src/duckdb/src/common/arrow/arrow_query_result.cpp +56 -0
- package/src/duckdb/src/common/arrow/physical_arrow_batch_collector.cpp +37 -0
- package/src/duckdb/src/common/arrow/physical_arrow_collector.cpp +128 -0
- package/src/duckdb/src/common/arrow/schema_metadata.cpp +101 -0
- package/src/duckdb/src/common/cgroups.cpp +189 -0
- package/src/duckdb/src/common/compressed_file_system.cpp +6 -3
- package/src/duckdb/src/common/encryption_state.cpp +38 -0
- package/src/duckdb/src/common/enum_util.cpp +682 -14
- package/src/duckdb/src/common/enums/file_compression_type.cpp +24 -0
- package/src/duckdb/src/common/enums/metric_type.cpp +208 -0
- package/src/duckdb/src/common/enums/optimizer_type.cpp +8 -2
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/relation_type.cpp +4 -0
- package/src/duckdb/src/common/enums/statement_type.cpp +15 -0
- package/src/duckdb/src/common/error_data.cpp +22 -20
- package/src/duckdb/src/common/exception/binder_exception.cpp +5 -0
- package/src/duckdb/src/common/exception.cpp +11 -1
- package/src/duckdb/src/common/extra_type_info.cpp +3 -0
- package/src/duckdb/src/common/file_buffer.cpp +1 -1
- package/src/duckdb/src/common/file_system.cpp +25 -3
- package/src/duckdb/src/common/filename_pattern.cpp +1 -0
- package/src/duckdb/src/common/fsst.cpp +15 -14
- package/src/duckdb/src/common/gzip_file_system.cpp +3 -1
- package/src/duckdb/src/common/hive_partitioning.cpp +103 -43
- package/src/duckdb/src/common/http_util.cpp +25 -0
- package/src/duckdb/src/common/local_file_system.cpp +48 -27
- package/src/duckdb/src/common/multi_file_list.cpp +113 -22
- package/src/duckdb/src/common/multi_file_reader.cpp +59 -58
- package/src/duckdb/src/common/operator/cast_operators.cpp +133 -34
- package/src/duckdb/src/common/operator/string_cast.cpp +42 -11
- package/src/duckdb/src/common/progress_bar/progress_bar.cpp +2 -2
- package/src/duckdb/src/common/progress_bar/terminal_progress_bar_display.cpp +1 -1
- package/src/duckdb/src/common/radix_partitioning.cpp +31 -21
- package/src/duckdb/src/common/random_engine.cpp +4 -0
- package/src/duckdb/src/common/re2_regex.cpp +47 -12
- package/src/duckdb/src/common/render_tree.cpp +243 -0
- package/src/duckdb/src/common/row_operations/row_aggregate.cpp +1 -1
- package/src/duckdb/src/common/row_operations/row_gather.cpp +2 -2
- package/src/duckdb/src/common/row_operations/row_matcher.cpp +58 -5
- package/src/duckdb/src/common/row_operations/row_radix_scatter.cpp +79 -43
- package/src/duckdb/src/common/serializer/binary_deserializer.cpp +1 -1
- package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +6 -4
- package/src/duckdb/src/common/serializer/buffered_file_writer.cpp +18 -9
- package/src/duckdb/src/common/serializer/memory_stream.cpp +1 -0
- package/src/duckdb/src/common/sort/partition_state.cpp +33 -18
- package/src/duckdb/src/common/sort/radix_sort.cpp +22 -15
- package/src/duckdb/src/common/sort/sort_state.cpp +19 -16
- package/src/duckdb/src/common/sort/sorted_block.cpp +11 -10
- package/src/duckdb/src/common/string_util.cpp +167 -10
- package/src/duckdb/src/common/tree_renderer/graphviz_tree_renderer.cpp +108 -0
- package/src/duckdb/src/common/tree_renderer/html_tree_renderer.cpp +267 -0
- package/src/duckdb/src/common/tree_renderer/json_tree_renderer.cpp +116 -0
- package/src/duckdb/src/common/tree_renderer/text_tree_renderer.cpp +482 -0
- package/src/duckdb/src/common/tree_renderer/tree_renderer.cpp +12 -0
- package/src/duckdb/src/common/tree_renderer.cpp +16 -508
- package/src/duckdb/src/common/types/batched_data_collection.cpp +78 -9
- package/src/duckdb/src/common/types/bit.cpp +24 -22
- package/src/duckdb/src/common/types/blob.cpp +15 -11
- package/src/duckdb/src/common/types/column/column_data_allocator.cpp +18 -9
- package/src/duckdb/src/common/types/column/column_data_collection.cpp +4 -4
- package/src/duckdb/src/common/types/column/column_data_collection_segment.cpp +3 -4
- package/src/duckdb/src/common/types/column/column_data_consumer.cpp +2 -2
- package/src/duckdb/src/common/types/column/partitioned_column_data.cpp +70 -21
- package/src/duckdb/src/common/types/data_chunk.cpp +10 -1
- package/src/duckdb/src/common/types/date.cpp +8 -19
- package/src/duckdb/src/common/types/decimal.cpp +3 -2
- package/src/duckdb/src/common/types/hugeint.cpp +11 -3
- package/src/duckdb/src/common/types/hyperloglog.cpp +212 -227
- package/src/duckdb/src/common/types/interval.cpp +1 -1
- package/src/duckdb/src/common/types/list_segment.cpp +83 -49
- package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +22 -83
- package/src/duckdb/src/common/types/row/row_data_collection.cpp +2 -2
- package/src/duckdb/src/common/types/row/row_data_collection_scanner.cpp +20 -4
- package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +28 -7
- package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +29 -14
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +152 -102
- package/src/duckdb/src/common/types/row/tuple_data_segment.cpp +4 -1
- package/src/duckdb/src/common/types/selection_vector.cpp +17 -1
- package/src/duckdb/src/common/types/time.cpp +62 -31
- package/src/duckdb/src/common/types/timestamp.cpp +70 -12
- package/src/duckdb/src/common/types/uuid.cpp +1 -1
- package/src/duckdb/src/common/types/validity_mask.cpp +40 -5
- package/src/duckdb/src/common/types/value.cpp +50 -8
- package/src/duckdb/src/common/types/varint.cpp +295 -0
- package/src/duckdb/src/common/types/vector.cpp +165 -54
- package/src/duckdb/src/common/types/vector_buffer.cpp +5 -4
- package/src/duckdb/src/common/types.cpp +106 -26
- package/src/duckdb/src/common/vector_operations/vector_copy.cpp +13 -25
- package/src/duckdb/src/common/vector_operations/vector_hash.cpp +6 -0
- package/src/duckdb/src/common/virtual_file_system.cpp +3 -3
- package/src/duckdb/src/core_functions/aggregate/distributive/approx_count.cpp +35 -82
- package/src/duckdb/src/core_functions/aggregate/distributive/arg_min_max.cpp +283 -46
- package/src/duckdb/src/core_functions/aggregate/distributive/bitagg.cpp +4 -4
- package/src/duckdb/src/core_functions/aggregate/distributive/entropy.cpp +3 -2
- package/src/duckdb/src/core_functions/aggregate/distributive/minmax.cpp +226 -338
- package/src/duckdb/src/core_functions/aggregate/distributive/sum.cpp +2 -0
- package/src/duckdb/src/core_functions/aggregate/holistic/approx_top_k.cpp +388 -0
- package/src/duckdb/src/core_functions/aggregate/holistic/approximate_quantile.cpp +63 -21
- package/src/duckdb/src/core_functions/aggregate/holistic/mad.cpp +330 -0
- package/src/duckdb/src/core_functions/aggregate/holistic/mode.cpp +136 -97
- package/src/duckdb/src/core_functions/aggregate/holistic/quantile.cpp +601 -1485
- package/src/duckdb/src/core_functions/aggregate/nested/binned_histogram.cpp +405 -0
- package/src/duckdb/src/core_functions/aggregate/nested/histogram.cpp +136 -165
- package/src/duckdb/src/core_functions/function_list.cpp +35 -8
- package/src/duckdb/src/core_functions/lambda_functions.cpp +5 -7
- package/src/duckdb/src/core_functions/scalar/array/array_functions.cpp +172 -198
- package/src/duckdb/src/core_functions/scalar/blob/create_sort_key.cpp +341 -54
- package/src/duckdb/src/core_functions/scalar/date/date_diff.cpp +2 -2
- package/src/duckdb/src/core_functions/scalar/date/date_part.cpp +89 -29
- package/src/duckdb/src/core_functions/scalar/date/date_trunc.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/date/make_date.cpp +2 -2
- package/src/duckdb/src/core_functions/scalar/date/strftime.cpp +133 -71
- package/src/duckdb/src/core_functions/scalar/date/to_interval.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/enum/enum_functions.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/generic/can_implicitly_cast.cpp +40 -0
- package/src/duckdb/src/core_functions/scalar/generic/error.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/generic/least.cpp +161 -58
- package/src/duckdb/src/core_functions/scalar/generic/typeof.cpp +13 -0
- package/src/duckdb/src/core_functions/scalar/list/array_slice.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/list/list_aggregates.cpp +59 -75
- package/src/duckdb/src/core_functions/scalar/list/list_distance.cpp +93 -40
- package/src/duckdb/src/core_functions/scalar/list/list_has_any_or_all.cpp +227 -0
- package/src/duckdb/src/core_functions/scalar/list/list_reduce.cpp +20 -19
- package/src/duckdb/src/core_functions/scalar/list/list_sort.cpp +0 -2
- package/src/duckdb/src/core_functions/scalar/list/list_value.cpp +106 -8
- package/src/duckdb/src/core_functions/scalar/map/map_contains.cpp +56 -0
- package/src/duckdb/src/core_functions/scalar/map/map_extract.cpp +73 -118
- package/src/duckdb/src/core_functions/scalar/math/numeric.cpp +98 -2
- package/src/duckdb/src/core_functions/scalar/operators/bitwise.cpp +1 -2
- package/src/duckdb/src/core_functions/scalar/random/setseed.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/string/bar.cpp +1 -1
- package/src/duckdb/src/core_functions/scalar/string/hex.cpp +5 -1
- package/src/duckdb/src/core_functions/scalar/string/md5.cpp +10 -37
- package/src/duckdb/src/core_functions/scalar/string/printf.cpp +18 -2
- package/src/duckdb/src/core_functions/scalar/string/repeat.cpp +45 -0
- package/src/duckdb/src/core_functions/scalar/string/reverse.cpp +4 -5
- package/src/duckdb/src/core_functions/scalar/string/sha1.cpp +35 -0
- package/src/duckdb/src/core_functions/scalar/string/sha256.cpp +5 -2
- package/src/duckdb/src/core_functions/scalar/string/url_encode.cpp +49 -0
- package/src/duckdb/src/core_functions/scalar/struct/struct_pack.cpp +1 -2
- package/src/duckdb/src/core_functions/scalar/union/union_extract.cpp +4 -2
- package/src/duckdb/src/execution/adaptive_filter.cpp +30 -11
- package/src/duckdb/src/execution/aggregate_hashtable.cpp +13 -18
- package/src/duckdb/src/execution/expression_executor/execute_conjunction.cpp +4 -9
- package/src/duckdb/src/execution/expression_executor.cpp +1 -1
- package/src/duckdb/src/execution/index/art/art.cpp +683 -670
- package/src/duckdb/src/execution/index/art/art_key.cpp +121 -38
- package/src/duckdb/src/execution/index/art/base_leaf.cpp +168 -0
- package/src/duckdb/src/execution/index/art/base_node.cpp +163 -0
- package/src/duckdb/src/execution/index/art/iterator.cpp +148 -77
- package/src/duckdb/src/execution/index/art/leaf.cpp +159 -263
- package/src/duckdb/src/execution/index/art/node.cpp +493 -247
- package/src/duckdb/src/execution/index/art/node256.cpp +31 -91
- package/src/duckdb/src/execution/index/art/node256_leaf.cpp +71 -0
- package/src/duckdb/src/execution/index/art/node48.cpp +75 -143
- package/src/duckdb/src/execution/index/art/prefix.cpp +424 -244
- package/src/duckdb/src/execution/index/bound_index.cpp +7 -1
- package/src/duckdb/src/execution/index/fixed_size_allocator.cpp +22 -18
- package/src/duckdb/src/execution/index/fixed_size_buffer.cpp +22 -73
- package/src/duckdb/src/execution/join_hashtable.cpp +637 -179
- package/src/duckdb/src/execution/operator/aggregate/aggregate_object.cpp +4 -4
- package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +15 -10
- package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +13 -8
- package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +525 -132
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +147 -138
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +531 -312
- package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_buffer.cpp +1 -1
- package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_buffer_manager.cpp +4 -3
- package/src/duckdb/src/execution/operator/csv_scanner/buffer_manager/csv_file_handle.cpp +9 -2
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/base_scanner.cpp +13 -17
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/column_count_scanner.cpp +60 -16
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/csv_schema.cpp +105 -0
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/scanner_boundary.cpp +24 -24
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/skip_scanner.cpp +25 -2
- package/src/duckdb/src/execution/operator/csv_scanner/scanner/string_value_scanner.cpp +275 -112
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/csv_sniffer.cpp +106 -11
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/dialect_detection.cpp +253 -115
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/header_detection.cpp +93 -52
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_detection.cpp +116 -76
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_refinement.cpp +29 -14
- package/src/duckdb/src/execution/operator/csv_scanner/sniffer/type_replacement.cpp +1 -1
- package/src/duckdb/src/execution/operator/csv_scanner/state_machine/csv_state_machine_cache.cpp +70 -26
- package/src/duckdb/src/execution/operator/csv_scanner/table_function/csv_file_scanner.cpp +81 -60
- package/src/duckdb/src/execution/operator/csv_scanner/table_function/global_csv_state.cpp +88 -50
- package/src/duckdb/src/execution/operator/csv_scanner/util/csv_error.cpp +161 -51
- package/src/duckdb/src/execution/operator/csv_scanner/util/csv_reader_options.cpp +59 -17
- package/src/duckdb/src/execution/operator/filter/physical_filter.cpp +5 -5
- package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +0 -21
- package/src/duckdb/src/execution/operator/helper/physical_buffered_batch_collector.cpp +109 -0
- package/src/duckdb/src/execution/operator/helper/physical_buffered_collector.cpp +5 -13
- package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +1 -1
- package/src/duckdb/src/execution/operator/helper/physical_load.cpp +12 -4
- package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +0 -16
- package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +4 -2
- package/src/duckdb/src/execution/operator/helper/physical_reset.cpp +5 -0
- package/src/duckdb/src/execution/operator/helper/physical_result_collector.cpp +3 -1
- package/src/duckdb/src/execution/operator/helper/physical_set_variable.cpp +39 -0
- package/src/duckdb/src/execution/operator/helper/physical_streaming_sample.cpp +4 -2
- package/src/duckdb/src/execution/operator/helper/physical_transaction.cpp +16 -5
- package/src/duckdb/src/execution/operator/join/outer_join_marker.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_asof_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +5 -4
- package/src/duckdb/src/execution/operator/join/physical_comparison_join.cpp +59 -21
- package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +7 -4
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +333 -176
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +57 -34
- package/src/duckdb/src/execution/operator/join/physical_join.cpp +16 -8
- package/src/duckdb/src/execution/operator/join/physical_left_delim_join.cpp +10 -4
- package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +2 -5
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +3 -3
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +5 -5
- package/src/duckdb/src/execution/operator/join/physical_right_delim_join.cpp +7 -2
- package/src/duckdb/src/execution/operator/order/physical_order.cpp +17 -12
- package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +12 -9
- package/src/duckdb/src/execution/operator/persistent/physical_batch_copy_to_file.cpp +35 -17
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +17 -11
- package/src/duckdb/src/execution/operator/persistent/physical_copy_database.cpp +5 -1
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +156 -47
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +10 -2
- package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +1 -3
- package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +2 -2
- package/src/duckdb/src/execution/operator/projection/physical_projection.cpp +13 -6
- package/src/duckdb/src/execution/operator/projection/physical_tableinout_function.cpp +22 -3
- package/src/duckdb/src/execution/operator/projection/physical_unnest.cpp +19 -3
- package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +37 -22
- package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +77 -21
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +27 -55
- package/src/duckdb/src/execution/operator/schema/physical_create_art_index.cpp +41 -44
- package/src/duckdb/src/execution/operator/set/physical_cte.cpp +4 -6
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +4 -6
- package/src/duckdb/src/execution/operator/set/physical_union.cpp +18 -4
- package/src/duckdb/src/execution/perfect_aggregate_hashtable.cpp +3 -2
- package/src/duckdb/src/execution/physical_operator.cpp +45 -4
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +18 -7
- package/src/duckdb/src/execution/physical_plan/plan_copy_to_file.cpp +8 -3
- package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +13 -6
- package/src/duckdb/src/execution/physical_plan/plan_explain.cpp +3 -3
- package/src/duckdb/src/execution/physical_plan/plan_get.cpp +111 -19
- package/src/duckdb/src/execution/physical_plan/plan_limit.cpp +19 -2
- package/src/duckdb/src/execution/physical_plan/plan_set.cpp +9 -0
- package/src/duckdb/src/execution/physical_plan/plan_window.cpp +3 -1
- package/src/duckdb/src/execution/physical_plan_generator.cpp +3 -3
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +49 -49
- package/src/duckdb/src/execution/reservoir_sample.cpp +2 -2
- package/src/duckdb/src/execution/window_executor.cpp +556 -318
- package/src/duckdb/src/execution/window_segment_tree.cpp +1058 -485
- package/src/duckdb/src/function/aggregate/distributive/count.cpp +5 -5
- package/src/duckdb/src/function/aggregate/distributive/first.cpp +92 -95
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +10 -9
- package/src/duckdb/src/function/aggregate_function.cpp +8 -0
- package/src/duckdb/src/function/cast/cast_function_set.cpp +10 -1
- package/src/duckdb/src/function/cast/decimal_cast.cpp +10 -1
- package/src/duckdb/src/function/cast/default_casts.cpp +2 -0
- package/src/duckdb/src/function/cast/numeric_casts.cpp +3 -0
- package/src/duckdb/src/function/cast/string_cast.cpp +8 -5
- package/src/duckdb/src/function/cast/time_casts.cpp +2 -2
- package/src/duckdb/src/function/cast/union_casts.cpp +1 -1
- package/src/duckdb/src/function/cast/varint_casts.cpp +283 -0
- package/src/duckdb/src/function/cast/vector_cast_helpers.cpp +3 -1
- package/src/duckdb/src/function/cast_rules.cpp +104 -15
- package/src/duckdb/src/function/compression_config.cpp +35 -33
- package/src/duckdb/src/function/copy_function.cpp +27 -0
- package/src/duckdb/src/function/function_binder.cpp +39 -11
- package/src/duckdb/src/function/macro_function.cpp +75 -32
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +10 -0
- package/src/duckdb/src/function/scalar/compressed_materialization/compress_string.cpp +1 -0
- package/src/duckdb/src/function/scalar/generic/binning.cpp +507 -0
- package/src/duckdb/src/function/scalar/generic/getvariable.cpp +58 -0
- package/src/duckdb/src/function/scalar/generic_functions.cpp +1 -0
- package/src/duckdb/src/function/scalar/list/contains_or_position.cpp +33 -47
- package/src/duckdb/src/function/scalar/list/list_extract.cpp +70 -143
- package/src/duckdb/src/function/scalar/list/list_resize.cpp +93 -84
- package/src/duckdb/src/function/scalar/list/list_zip.cpp +3 -0
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +24 -11
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +4 -4
- package/src/duckdb/src/function/scalar/strftime_format.cpp +196 -57
- package/src/duckdb/src/function/scalar/string/caseconvert.cpp +9 -7
- package/src/duckdb/src/function/scalar/string/concat.cpp +239 -123
- package/src/duckdb/src/function/scalar/string/concat_ws.cpp +149 -0
- package/src/duckdb/src/function/scalar/string/contains.cpp +18 -7
- package/src/duckdb/src/function/scalar/string/like.cpp +2 -2
- package/src/duckdb/src/function/scalar/string/substring.cpp +6 -11
- package/src/duckdb/src/function/scalar/string_functions.cpp +1 -0
- package/src/duckdb/src/function/scalar/struct/struct_extract.cpp +7 -3
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +5 -5
- package/src/duckdb/src/function/scalar_function.cpp +5 -2
- package/src/duckdb/src/function/scalar_macro_function.cpp +2 -2
- package/src/duckdb/src/function/table/arrow/arrow_duck_schema.cpp +20 -39
- package/src/duckdb/src/function/table/arrow/arrow_type_info.cpp +135 -0
- package/src/duckdb/src/function/table/arrow.cpp +194 -52
- package/src/duckdb/src/function/table/arrow_conversion.cpp +212 -69
- package/src/duckdb/src/function/table/copy_csv.cpp +43 -14
- package/src/duckdb/src/function/table/query_function.cpp +80 -0
- package/src/duckdb/src/function/table/range.cpp +222 -142
- package/src/duckdb/src/function/table/read_csv.cpp +25 -13
- package/src/duckdb/src/function/table/sniff_csv.cpp +55 -35
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +141 -129
- package/src/duckdb/src/function/table/system/duckdb_extensions.cpp +25 -14
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +20 -14
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +15 -1
- package/src/duckdb/src/function/table/system/duckdb_variables.cpp +84 -0
- package/src/duckdb/src/function/table/system/test_all_types.cpp +1 -0
- package/src/duckdb/src/function/table/system/test_vector_types.cpp +33 -3
- package/src/duckdb/src/function/table/system_functions.cpp +1 -0
- package/src/duckdb/src/function/table/table_scan.cpp +45 -22
- package/src/duckdb/src/function/table/unnest.cpp +2 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +4 -4
- package/src/duckdb/src/function/table_function.cpp +5 -4
- package/src/duckdb/src/function/table_macro_function.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +8 -4
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +5 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_schema_entry.hpp +3 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +3 -4
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +5 -5
- package/src/duckdb/src/include/duckdb/catalog/default/builtin_types/types.hpp +2 -1
- package/src/duckdb/src/include/duckdb/catalog/default/default_functions.hpp +4 -5
- package/src/duckdb/src/include/duckdb/catalog/default/default_generator.hpp +4 -5
- package/src/duckdb/src/include/duckdb/catalog/default/default_schemas.hpp +2 -1
- package/src/duckdb/src/include/duckdb/catalog/default/default_table_functions.hpp +47 -0
- package/src/duckdb/src/include/duckdb/catalog/duck_catalog.hpp +2 -0
- package/src/duckdb/src/include/duckdb/catalog/similar_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +9 -1
- package/src/duckdb/src/include/duckdb/common/array_ptr.hpp +120 -0
- package/src/duckdb/src/include/duckdb/common/arrow/appender/append_data.hpp +37 -11
- package/src/duckdb/src/include/duckdb/common/arrow/appender/enum_data.hpp +9 -8
- package/src/duckdb/src/include/duckdb/common/arrow/appender/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/arrow/appender/list_data.hpp +6 -4
- package/src/duckdb/src/include/duckdb/common/arrow/appender/list_view_data.hpp +92 -0
- package/src/duckdb/src/include/duckdb/common/arrow/appender/map_data.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/arrow/appender/scalar_data.hpp +26 -4
- package/src/duckdb/src/include/duckdb/common/arrow/appender/varchar_data.hpp +90 -11
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +6 -6
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_buffer.hpp +8 -1
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_merge_event.hpp +62 -0
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_query_result.hpp +52 -0
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_types_extension.hpp +42 -0
- package/src/duckdb/src/include/duckdb/common/arrow/physical_arrow_batch_collector.hpp +30 -0
- package/src/duckdb/src/include/duckdb/common/arrow/physical_arrow_collector.hpp +65 -0
- package/src/duckdb/src/include/duckdb/common/arrow/schema_metadata.hpp +43 -0
- package/src/duckdb/src/include/duckdb/common/bswap.hpp +18 -16
- package/src/duckdb/src/include/duckdb/common/cgroups.hpp +30 -0
- package/src/duckdb/src/include/duckdb/common/compressed_file_system.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/dl.hpp +8 -1
- package/src/duckdb/src/include/duckdb/common/encryption_state.hpp +48 -0
- package/src/duckdb/src/include/duckdb/common/enum_util.hpp +88 -0
- package/src/duckdb/src/include/duckdb/common/enums/checkpoint_type.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/enums/copy_overwrite_mode.hpp +6 -1
- package/src/duckdb/src/include/duckdb/common/enums/destroy_buffer_upon.hpp +21 -0
- package/src/duckdb/src/include/duckdb/common/enums/explain_format.hpp +17 -0
- package/src/duckdb/src/include/duckdb/common/enums/file_compression_type.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/enums/join_type.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/enums/metric_type.hpp +88 -0
- package/src/duckdb/src/include/duckdb/common/enums/optimizer_type.hpp +6 -1
- package/src/duckdb/src/include/duckdb/common/enums/pending_execution_result.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/profiler_format.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/enums/relation_type.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/enums/set_scope.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/enums/statement_type.hpp +23 -2
- package/src/duckdb/src/include/duckdb/common/enums/stream_execution_result.hpp +25 -0
- package/src/duckdb/src/include/duckdb/common/enums/tableref_type.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/enums/wal_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/error_data.hpp +5 -2
- package/src/duckdb/src/include/duckdb/common/exception/binder_exception.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/exception.hpp +20 -2
- package/src/duckdb/src/include/duckdb/common/extra_operator_info.hpp +12 -0
- package/src/duckdb/src/include/duckdb/common/file_buffer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/file_open_flags.hpp +16 -0
- package/src/duckdb/src/include/duckdb/common/file_opener.hpp +18 -0
- package/src/duckdb/src/include/duckdb/common/file_system.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/filename_pattern.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/fixed_size_map.hpp +160 -96
- package/src/duckdb/src/include/duckdb/common/fsst.hpp +9 -2
- package/src/duckdb/src/include/duckdb/common/helper.hpp +22 -8
- package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +16 -7
- package/src/duckdb/src/include/duckdb/common/http_util.hpp +19 -0
- package/src/duckdb/src/include/duckdb/common/insertion_order_preserving_map.hpp +19 -6
- package/src/duckdb/src/include/duckdb/common/limits.hpp +9 -2
- package/src/duckdb/src/include/duckdb/common/multi_file_list.hpp +38 -6
- package/src/duckdb/src/include/duckdb/common/multi_file_reader.hpp +9 -2
- package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +5 -1
- package/src/duckdb/src/include/duckdb/common/numeric_utils.hpp +82 -50
- package/src/duckdb/src/include/duckdb/common/operator/abs.hpp +11 -0
- package/src/duckdb/src/include/duckdb/common/operator/cast_operators.hpp +7 -3
- package/src/duckdb/src/include/duckdb/common/operator/decimal_cast_operators.hpp +23 -1
- package/src/duckdb/src/include/duckdb/common/operator/double_cast_operator.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/operator/integer_cast_operator.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/operator/numeric_cast.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/operator/string_cast.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +10 -5
- package/src/duckdb/src/include/duckdb/common/optionally_owned_ptr.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/owning_string_map.hpp +155 -0
- package/src/duckdb/src/include/duckdb/common/perfect_map_set.hpp +2 -3
- package/src/duckdb/src/include/duckdb/common/platform.hpp +58 -0
- package/src/duckdb/src/include/duckdb/common/radix.hpp +172 -27
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +5 -1
- package/src/duckdb/src/include/duckdb/common/random_engine.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/re2_regex.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/render_tree.hpp +77 -0
- package/src/duckdb/src/include/duckdb/common/row_operations/row_matcher.hpp +12 -0
- package/src/duckdb/src/include/duckdb/common/serializer/binary_serializer.hpp +6 -2
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_writer.hpp +5 -3
- package/src/duckdb/src/include/duckdb/common/serializer/deserializer.hpp +15 -7
- package/src/duckdb/src/include/duckdb/common/serializer/memory_stream.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/serializer/serialization_data.hpp +245 -0
- package/src/duckdb/src/include/duckdb/common/serializer/serializer.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/sort/duckdb_pdqsort.hpp +10 -11
- package/src/duckdb/src/include/duckdb/common/sort/partition_state.hpp +12 -6
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +37 -7
- package/src/duckdb/src/include/duckdb/common/tree_renderer/graphviz_tree_renderer.hpp +44 -0
- package/src/duckdb/src/include/duckdb/common/tree_renderer/html_tree_renderer.hpp +44 -0
- package/src/duckdb/src/include/duckdb/common/tree_renderer/json_tree_renderer.hpp +44 -0
- package/src/duckdb/src/include/duckdb/common/tree_renderer/text_tree_renderer.hpp +119 -0
- package/src/duckdb/src/include/duckdb/common/tree_renderer.hpp +9 -123
- package/src/duckdb/src/include/duckdb/common/type_visitor.hpp +96 -0
- package/src/duckdb/src/include/duckdb/common/typedefs.hpp +11 -1
- package/src/duckdb/src/include/duckdb/common/types/arrow_string_view_type.hpp +84 -0
- package/src/duckdb/src/include/duckdb/common/types/batched_data_collection.hpp +36 -1
- package/src/duckdb/src/include/duckdb/common/types/bit.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/cast_helpers.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/types/column/column_data_allocator.hpp +4 -2
- package/src/duckdb/src/include/duckdb/common/types/column/partitioned_column_data.hpp +52 -0
- package/src/duckdb/src/include/duckdb/common/types/data_chunk.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/types/date.hpp +0 -3
- package/src/duckdb/src/include/duckdb/common/types/date_lookup_cache.hpp +65 -0
- package/src/duckdb/src/include/duckdb/common/types/datetime.hpp +5 -2
- package/src/duckdb/src/include/duckdb/common/types/hyperloglog.hpp +49 -40
- package/src/duckdb/src/include/duckdb/common/types/interval.hpp +5 -1
- package/src/duckdb/src/include/duckdb/common/types/list_segment.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +41 -9
- package/src/duckdb/src/include/duckdb/common/types/row/row_data_collection.hpp +4 -3
- package/src/duckdb/src/include/duckdb/common/types/row/row_data_collection_scanner.hpp +3 -1
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_allocator.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_states.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/selection_vector.hpp +4 -0
- package/src/duckdb/src/include/duckdb/common/types/string_type.hpp +4 -1
- package/src/duckdb/src/include/duckdb/common/types/time.hpp +11 -6
- package/src/duckdb/src/include/duckdb/common/types/timestamp.hpp +13 -3
- package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +103 -12
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +12 -3
- package/src/duckdb/src/include/duckdb/common/types/varint.hpp +107 -0
- package/src/duckdb/src/include/duckdb/common/types/vector.hpp +5 -1
- package/src/duckdb/src/include/duckdb/common/types/vector_buffer.hpp +7 -2
- package/src/duckdb/src/include/duckdb/common/types.hpp +6 -39
- package/src/duckdb/src/include/duckdb/common/union_by_name.hpp +42 -10
- package/src/duckdb/src/include/duckdb/common/vector_operations/generic_executor.hpp +29 -0
- package/src/duckdb/src/include/duckdb/common/vector_operations/unary_executor.hpp +0 -7
- package/src/duckdb/src/include/duckdb/common/vector_operations/vector_operations.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/winapi.hpp +8 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/covar.hpp +8 -4
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/algebraic/stddev.hpp +8 -4
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/distributive_functions.hpp +4 -2
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/histogram_helpers.hpp +99 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/holistic_functions.hpp +16 -7
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/minmax_n_helpers.hpp +396 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/nested_functions.hpp +10 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/quantile_helpers.hpp +65 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/quantile_sort_tree.hpp +349 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/quantile_state.hpp +300 -0
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/regression/regr_slope.hpp +1 -1
- package/src/duckdb/src/include/duckdb/core_functions/aggregate/sort_key_helpers.hpp +55 -0
- package/src/duckdb/src/include/duckdb/core_functions/array_kernels.hpp +107 -0
- package/src/duckdb/src/include/duckdb/core_functions/create_sort_key.hpp +55 -0
- package/src/duckdb/src/include/duckdb/core_functions/lambda_functions.hpp +1 -2
- package/src/duckdb/src/include/duckdb/core_functions/scalar/array_functions.hpp +24 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/date_functions.hpp +9 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/generic_functions.hpp +27 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/list_functions.hpp +80 -8
- package/src/duckdb/src/include/duckdb/core_functions/scalar/map_functions.hpp +9 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/math_functions.hpp +54 -0
- package/src/duckdb/src/include/duckdb/core_functions/scalar/string_functions.hpp +30 -21
- package/src/duckdb/src/include/duckdb/execution/adaptive_filter.hpp +25 -14
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +2 -48
- package/src/duckdb/src/include/duckdb/execution/executor.hpp +25 -2
- package/src/duckdb/src/include/duckdb/execution/ht_entry.hpp +102 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +94 -101
- package/src/duckdb/src/include/duckdb/execution/index/art/art_key.hpp +43 -25
- package/src/duckdb/src/include/duckdb/execution/index/art/base_leaf.hpp +109 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/base_node.hpp +140 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/iterator.hpp +43 -24
- package/src/duckdb/src/include/duckdb/execution/index/art/leaf.hpp +41 -52
- package/src/duckdb/src/include/duckdb/execution/index/art/node.hpp +133 -74
- package/src/duckdb/src/include/duckdb/execution/index/art/node256.hpp +46 -29
- package/src/duckdb/src/include/duckdb/execution/index/art/node256_leaf.hpp +53 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/node48.hpp +52 -35
- package/src/duckdb/src/include/duckdb/execution/index/art/prefix.hpp +96 -57
- package/src/duckdb/src/include/duckdb/execution/index/bound_index.hpp +9 -4
- package/src/duckdb/src/include/duckdb/execution/index/fixed_size_allocator.hpp +48 -10
- package/src/duckdb/src/include/duckdb/execution/index/fixed_size_buffer.hpp +0 -2
- package/src/duckdb/src/include/duckdb/execution/index/index_pointer.hpp +4 -2
- package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +114 -36
- package/src/duckdb/src/include/duckdb/execution/merge_sort_tree.hpp +158 -67
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/aggregate_object.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_streaming_window.hpp +19 -2
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/ungrouped_aggregate_state.hpp +75 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/base_scanner.hpp +81 -23
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/column_count_scanner.hpp +27 -8
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_buffer_manager.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_error.hpp +31 -22
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_file_handle.hpp +4 -2
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_file_scanner.hpp +48 -5
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_option.hpp +7 -3
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_reader_options.hpp +22 -12
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_schema.hpp +35 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_sniffer.hpp +81 -39
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state.hpp +2 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine.hpp +18 -1
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/csv_state_machine_cache.hpp +9 -7
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/global_csv_state.hpp +5 -4
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/header_value.hpp +26 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/scanner_boundary.hpp +6 -9
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/skip_scanner.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/state_machine_options.hpp +5 -3
- package/src/duckdb/src/include/duckdb/execution/operator/csv_scanner/string_value_scanner.hpp +36 -19
- package/src/duckdb/src/include/duckdb/execution/operator/filter/physical_filter.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_batch_collector.hpp +21 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_buffered_batch_collector.hpp +53 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_buffered_collector.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +6 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_materialized_collector.hpp +18 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reservoir_sample.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_result_collector.hpp +6 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set_variable.hpp +43 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_streaming_sample.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/join_filter_pushdown.hpp +59 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_comparison_join.hpp +8 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +5 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +4 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_left_delim_join.hpp +3 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_range_join.hpp +4 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_right_delim_join.hpp +3 -1
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/batch_memory_manager.hpp +5 -37
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_copy_to_file.hpp +5 -4
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +8 -2
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_projection.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_tableinout_function.hpp +2 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +9 -3
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +8 -6
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_art_index.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_cte.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +21 -6
- package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +3 -2
- package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/window_executor.hpp +137 -110
- package/src/duckdb/src/include/duckdb/execution/window_segment_tree.hpp +57 -126
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +21 -4
- package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/compression/compression.hpp +10 -10
- package/src/duckdb/src/include/duckdb/function/compression_function.hpp +37 -7
- package/src/duckdb/src/include/duckdb/function/copy_function.hpp +24 -11
- package/src/duckdb/src/include/duckdb/function/function_binder.hpp +4 -4
- package/src/duckdb/src/include/duckdb/function/function_serialization.hpp +41 -1
- package/src/duckdb/src/include/duckdb/function/macro_function.hpp +15 -5
- package/src/duckdb/src/include/duckdb/function/pragma/pragma_functions.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/replacement_scan.hpp +20 -4
- package/src/duckdb/src/include/duckdb/function/scalar/generic_functions.hpp +6 -0
- package/src/duckdb/src/include/duckdb/function/scalar/list/contains_or_position.hpp +77 -109
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar/regexp.hpp +6 -3
- package/src/duckdb/src/include/duckdb/function/scalar/strftime_format.hpp +25 -12
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +9 -8
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +38 -4
- package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/table/arrow/arrow_duck_schema.hpp +11 -57
- package/src/duckdb/src/include/duckdb/function/table/arrow/arrow_type_info.hpp +142 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow/enum/arrow_datetime_type.hpp +18 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow/enum/arrow_type_info_type.hpp +7 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow/enum/arrow_variable_size_type.hpp +10 -0
- package/src/duckdb/src/include/duckdb/function/table/arrow.hpp +2 -0
- package/src/duckdb/src/include/duckdb/function/table/range.hpp +4 -0
- package/src/duckdb/src/include/duckdb/function/table/read_csv.hpp +4 -1
- package/src/duckdb/src/include/duckdb/function/table/system_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/function/table/table_scan.hpp +5 -5
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +14 -2
- package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/appender.hpp +14 -4
- package/src/duckdb/src/include/duckdb/main/attached_database.hpp +25 -7
- package/src/duckdb/src/include/duckdb/main/buffered_data/batched_buffered_data.hpp +79 -0
- package/src/duckdb/src/include/duckdb/main/buffered_data/buffered_data.hpp +10 -20
- package/src/duckdb/src/include/duckdb/main/buffered_data/simple_buffered_data.hpp +11 -12
- package/src/duckdb/src/include/duckdb/main/capi/capi_internal.hpp +7 -2
- package/src/duckdb/src/include/duckdb/main/capi/cast/generic.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/capi/cast/utils.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/capi/extension_api.hpp +809 -0
- package/src/duckdb/src/include/duckdb/main/chunk_scan_state/batched_data_collection.hpp +35 -0
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +68 -2
- package/src/duckdb/src/include/duckdb/main/client_context.hpp +30 -22
- package/src/duckdb/src/include/duckdb/main/client_context_state.hpp +79 -1
- package/src/duckdb/src/include/duckdb/main/client_properties.hpp +9 -3
- package/src/duckdb/src/include/duckdb/main/config.hpp +55 -7
- package/src/duckdb/src/include/duckdb/main/connection.hpp +5 -1
- package/src/duckdb/src/include/duckdb/main/database.hpp +16 -5
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +9 -8
- package/src/duckdb/src/include/duckdb/main/db_instance_cache.hpp +21 -6
- package/src/duckdb/src/include/duckdb/main/extension.hpp +20 -0
- package/src/duckdb/src/include/duckdb/main/extension_entries.hpp +25 -0
- package/src/duckdb/src/include/duckdb/main/extension_helper.hpp +29 -23
- package/src/duckdb/src/include/duckdb/main/extension_install_info.hpp +6 -0
- package/src/duckdb/src/include/duckdb/main/extension_util.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/pending_query_result.hpp +4 -2
- package/src/duckdb/src/include/duckdb/main/prepared_statement.hpp +5 -6
- package/src/duckdb/src/include/duckdb/main/prepared_statement_data.hpp +2 -5
- package/src/duckdb/src/include/duckdb/main/profiling_info.hpp +87 -0
- package/src/duckdb/src/include/duckdb/main/profiling_node.hpp +60 -0
- package/src/duckdb/src/include/duckdb/main/query_profiler.hpp +72 -34
- package/src/duckdb/src/include/duckdb/main/query_result.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/relation/create_table_relation.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/relation/delim_get_relation.hpp +30 -0
- package/src/duckdb/src/include/duckdb/main/relation/explain_relation.hpp +3 -1
- package/src/duckdb/src/include/duckdb/main/relation/join_relation.hpp +3 -0
- package/src/duckdb/src/include/duckdb/main/relation/materialized_relation.hpp +1 -4
- package/src/duckdb/src/include/duckdb/main/relation/query_relation.hpp +4 -1
- package/src/duckdb/src/include/duckdb/main/relation/read_json_relation.hpp +6 -0
- package/src/duckdb/src/include/duckdb/main/relation/table_function_relation.hpp +1 -0
- package/src/duckdb/src/include/duckdb/main/relation/view_relation.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation.hpp +7 -4
- package/src/duckdb/src/include/duckdb/main/secret/default_secrets.hpp +36 -0
- package/src/duckdb/src/include/duckdb/main/secret/secret.hpp +108 -0
- package/src/duckdb/src/include/duckdb/main/secret/secret_manager.hpp +14 -4
- package/src/duckdb/src/include/duckdb/main/settings.hpp +227 -3
- package/src/duckdb/src/include/duckdb/main/stream_query_result.hpp +8 -0
- package/src/duckdb/src/include/duckdb/optimizer/build_probe_side_optimizer.hpp +51 -0
- package/src/duckdb/src/include/duckdb/optimizer/compressed_materialization.hpp +7 -0
- package/src/duckdb/src/include/duckdb/optimizer/cte_filter_pusher.hpp +46 -0
- package/src/duckdb/src/include/duckdb/optimizer/filter_combiner.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/filter_pushdown.hpp +7 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_filter_pushdown_optimizer.hpp +31 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +51 -10
- package/src/duckdb/src/include/duckdb/optimizer/join_order/cost_model.hpp +1 -0
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_order_optimizer.hpp +17 -5
- package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph_manager.hpp +15 -13
- package/src/duckdb/src/include/duckdb/optimizer/join_order/relation_manager.hpp +9 -4
- package/src/duckdb/src/include/duckdb/optimizer/limit_pushdown.hpp +25 -0
- package/src/duckdb/src/include/duckdb/optimizer/optimizer.hpp +1 -0
- package/src/duckdb/src/include/duckdb/optimizer/rule/join_dependent_filter.hpp +37 -0
- package/src/duckdb/src/include/duckdb/parallel/executor_task.hpp +6 -1
- package/src/duckdb/src/include/duckdb/parallel/interrupt.hpp +54 -2
- package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +27 -8
- package/src/duckdb/src/include/duckdb/parallel/pipeline.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parallel/pipeline_prepare_finish_event.hpp +25 -0
- package/src/duckdb/src/include/duckdb/parallel/task_executor.hpp +63 -0
- package/src/duckdb/src/include/duckdb/parallel/task_scheduler.hpp +10 -1
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +4 -1
- package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/alter_table_info.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/attach_info.hpp +5 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_index_info.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_data/create_macro_info.hpp +11 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/transaction_info.hpp +9 -0
- package/src/duckdb/src/include/duckdb/parser/parsed_expression_iterator.hpp +13 -6
- package/src/duckdb/src/include/duckdb/parser/parser_extension.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +1 -3
- package/src/duckdb/src/include/duckdb/parser/statement/copy_statement.hpp +2 -0
- package/src/duckdb/src/include/duckdb/parser/statement/explain_statement.hpp +5 -1
- package/src/duckdb/src/include/duckdb/parser/statement/set_statement.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/statement/transaction_statement.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +0 -2
- package/src/duckdb/src/include/duckdb/parser/tableref/column_data_ref.hpp +9 -7
- package/src/duckdb/src/include/duckdb/parser/tableref/delimgetref.hpp +37 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/joinref.hpp +4 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +0 -2
- package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +0 -2
- package/src/duckdb/src/include/duckdb/parser/tableref/table_function_ref.hpp +0 -1
- package/src/duckdb/src/include/duckdb/parser/tableref.hpp +3 -1
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +17 -9
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +24 -14
- package/src/duckdb/src/include/duckdb/planner/collation_binding.hpp +44 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_aggregate_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_between_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_case_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_cast_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_comparison_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_conjunction_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_constant_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_default_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_expanded_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_function_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_lambda_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_lambdaref_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_operator_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_data.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_reference_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_subquery_expression.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression/bound_unnest_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression/bound_window_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression.hpp +2 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/column_alias_binder.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/group_binder.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/order_binder.hpp +6 -5
- package/src/duckdb/src/include/duckdb/planner/expression_binder/where_binder.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +19 -11
- package/src/duckdb/src/include/duckdb/planner/filter/conjunction_filter.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/filter/constant_filter.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/filter/null_filter.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/filter/struct_filter.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +7 -2
- package/src/duckdb/src/include/duckdb/planner/logical_operator_visitor.hpp +2 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_any_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +6 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +10 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_distinct.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +4 -2
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +15 -5
- package/src/duckdb/src/include/duckdb/planner/operator/logical_materialized_cte.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_order.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/subquery/flatten_dependent_join.hpp +2 -1
- package/src/duckdb/src/include/duckdb/planner/table_filter.hpp +24 -2
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_delimgetref.hpp +26 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_joinref.hpp +6 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_subqueryref.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_table_function.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/list.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/arena_allocator.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/block.hpp +4 -2
- package/src/duckdb/src/include/duckdb/storage/block_manager.hpp +48 -3
- package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +21 -7
- package/src/duckdb/src/include/duckdb/storage/buffer/buffer_pool.hpp +65 -51
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +14 -5
- package/src/duckdb/src/include/duckdb/storage/checkpoint/row_group_writer.hpp +0 -4
- package/src/duckdb/src/include/duckdb/storage/checkpoint/string_checkpoint_state.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/checkpoint/table_data_writer.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/checkpoint/write_overflow_strings_to_disk.hpp +3 -4
- package/src/duckdb/src/include/duckdb/storage/checkpoint_manager.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/compression/alp/algorithm/alp.hpp +4 -4
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_analyze.hpp +6 -4
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_compress.hpp +19 -17
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_constants.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_scan.hpp +3 -4
- package/src/duckdb/src/include/duckdb/storage/compression/alp/alp_utils.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/compression/alprd/algorithm/alprd.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_analyze.hpp +13 -11
- package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_compress.hpp +19 -19
- package/src/duckdb/src/include/duckdb/storage/compression/alprd/alprd_scan.hpp +3 -4
- package/src/duckdb/src/include/duckdb/storage/compression/chimp/chimp_scan.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/compression/patas/patas_scan.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/data_pointer.hpp +10 -2
- package/src/duckdb/src/include/duckdb/storage/data_table.hpp +3 -2
- package/src/duckdb/src/include/duckdb/storage/in_memory_block_manager.hpp +15 -0
- package/src/duckdb/src/include/duckdb/storage/index_storage_info.hpp +14 -10
- package/src/duckdb/src/include/duckdb/storage/metadata/metadata_manager.hpp +6 -8
- package/src/duckdb/src/include/duckdb/storage/partial_block_manager.hpp +7 -4
- package/src/duckdb/src/include/duckdb/storage/segment/uncompressed.hpp +4 -7
- package/src/duckdb/src/include/duckdb/storage/single_file_block_manager.hpp +29 -4
- package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +22 -7
- package/src/duckdb/src/include/duckdb/storage/statistics/base_statistics.hpp +15 -2
- package/src/duckdb/src/include/duckdb/storage/statistics/distinct_statistics.hpp +8 -2
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats.hpp +5 -16
- package/src/duckdb/src/include/duckdb/storage/statistics/numeric_stats_union.hpp +51 -13
- package/src/duckdb/src/include/duckdb/storage/statistics/string_stats.hpp +6 -3
- package/src/duckdb/src/include/duckdb/storage/storage_info.hpp +29 -19
- package/src/duckdb/src/include/duckdb/storage/storage_manager.hpp +23 -7
- package/src/duckdb/src/include/duckdb/storage/string_uncompressed.hpp +27 -18
- package/src/duckdb/src/include/duckdb/storage/table/append_state.hpp +6 -3
- package/src/duckdb/src/include/duckdb/storage/table/array_column_data.hpp +5 -2
- package/src/duckdb/src/include/duckdb/storage/table/chunk_info.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/table/column_checkpoint_state.hpp +5 -1
- package/src/duckdb/src/include/duckdb/storage/table/column_data.hpp +77 -6
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +23 -11
- package/src/duckdb/src/include/duckdb/storage/table/data_table_info.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/table/list_column_data.hpp +5 -2
- package/src/duckdb/src/include/duckdb/storage/table/row_group.hpp +18 -4
- package/src/duckdb/src/include/duckdb/storage/table/row_group_collection.hpp +7 -1
- package/src/duckdb/src/include/duckdb/storage/table/row_version_manager.hpp +2 -1
- package/src/duckdb/src/include/duckdb/storage/table/scan_state.hpp +89 -14
- package/src/duckdb/src/include/duckdb/storage/table/standard_column_data.hpp +4 -2
- package/src/duckdb/src/include/duckdb/storage/table/struct_column_data.hpp +4 -2
- package/src/duckdb/src/include/duckdb/storage/table/table_index_list.hpp +2 -2
- package/src/duckdb/src/include/duckdb/storage/table/validity_column_data.hpp +1 -1
- package/src/duckdb/src/include/duckdb/storage/temporary_memory_manager.hpp +33 -15
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +9 -9
- package/src/duckdb/src/include/duckdb/transaction/cleanup_state.hpp +3 -1
- package/src/duckdb/src/include/duckdb/transaction/commit_state.hpp +4 -16
- package/src/duckdb/src/include/duckdb/transaction/duck_transaction.hpp +27 -4
- package/src/duckdb/src/include/duckdb/transaction/duck_transaction_manager.hpp +11 -0
- package/src/duckdb/src/include/duckdb/transaction/local_storage.hpp +6 -2
- package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +5 -5
- package/src/duckdb/src/include/duckdb/transaction/transaction_context.hpp +6 -2
- package/src/duckdb/src/include/duckdb/transaction/undo_buffer.hpp +5 -3
- package/src/duckdb/src/include/duckdb/transaction/wal_write_state.hpp +48 -0
- package/src/duckdb/src/include/duckdb.h +1779 -739
- package/src/duckdb/src/include/duckdb_extension.h +921 -0
- package/src/duckdb/src/main/appender.cpp +53 -7
- package/src/duckdb/src/main/attached_database.cpp +87 -17
- package/src/duckdb/src/main/buffered_data/batched_buffered_data.cpp +226 -0
- package/src/duckdb/src/main/buffered_data/buffered_data.cpp +35 -0
- package/src/duckdb/src/main/buffered_data/simple_buffered_data.cpp +48 -23
- package/src/duckdb/src/main/capi/aggregate_function-c.cpp +327 -0
- package/src/duckdb/src/main/capi/appender-c.cpp +18 -0
- package/src/duckdb/src/main/capi/cast/utils-c.cpp +2 -2
- package/src/duckdb/src/main/capi/cast_function-c.cpp +210 -0
- package/src/duckdb/src/main/capi/config-c.cpp +3 -3
- package/src/duckdb/src/main/capi/data_chunk-c.cpp +18 -7
- package/src/duckdb/src/main/capi/duckdb_value-c.cpp +223 -24
- package/src/duckdb/src/main/capi/helper-c.cpp +51 -11
- package/src/duckdb/src/main/capi/logical_types-c.cpp +105 -46
- package/src/duckdb/src/main/capi/pending-c.cpp +7 -6
- package/src/duckdb/src/main/capi/prepared-c.cpp +18 -7
- package/src/duckdb/src/main/capi/profiling_info-c.cpp +84 -0
- package/src/duckdb/src/main/capi/result-c.cpp +139 -37
- package/src/duckdb/src/main/capi/scalar_function-c.cpp +269 -0
- package/src/duckdb/src/main/capi/table_description-c.cpp +82 -0
- package/src/duckdb/src/main/capi/table_function-c.cpp +161 -95
- package/src/duckdb/src/main/capi/value-c.cpp +2 -2
- package/src/duckdb/src/main/chunk_scan_state/batched_data_collection.cpp +57 -0
- package/src/duckdb/src/main/client_config.cpp +17 -0
- package/src/duckdb/src/main/client_context.cpp +67 -52
- package/src/duckdb/src/main/client_data.cpp +3 -3
- package/src/duckdb/src/main/config.cpp +120 -62
- package/src/duckdb/src/main/connection.cpp +14 -2
- package/src/duckdb/src/main/database.cpp +96 -35
- package/src/duckdb/src/main/database_manager.cpp +25 -23
- package/src/duckdb/src/main/database_path_and_type.cpp +2 -2
- package/src/duckdb/src/main/db_instance_cache.cpp +54 -19
- package/src/duckdb/src/main/extension/extension_helper.cpp +47 -42
- package/src/duckdb/src/main/extension/extension_install.cpp +155 -87
- package/src/duckdb/src/main/extension/extension_load.cpp +180 -26
- package/src/duckdb/src/main/extension/extension_util.cpp +8 -0
- package/src/duckdb/src/main/extension.cpp +72 -5
- package/src/duckdb/src/main/pending_query_result.cpp +20 -12
- package/src/duckdb/src/main/prepared_statement.cpp +6 -6
- package/src/duckdb/src/main/prepared_statement_data.cpp +28 -17
- package/src/duckdb/src/main/profiling_info.cpp +196 -0
- package/src/duckdb/src/main/query_profiler.cpp +413 -224
- package/src/duckdb/src/main/query_result.cpp +1 -1
- package/src/duckdb/src/main/relation/create_table_relation.cpp +4 -2
- package/src/duckdb/src/main/relation/create_view_relation.cpp +0 -6
- package/src/duckdb/src/main/relation/delim_get_relation.cpp +44 -0
- package/src/duckdb/src/main/relation/explain_relation.cpp +4 -3
- package/src/duckdb/src/main/relation/join_relation.cpp +5 -0
- package/src/duckdb/src/main/relation/limit_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/materialized_relation.cpp +3 -3
- package/src/duckdb/src/main/relation/query_relation.cpp +42 -15
- package/src/duckdb/src/main/relation/read_csv_relation.cpp +7 -14
- package/src/duckdb/src/main/relation/read_json_relation.cpp +20 -0
- package/src/duckdb/src/main/relation/setop_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/table_function_relation.cpp +6 -0
- package/src/duckdb/src/main/relation/view_relation.cpp +10 -0
- package/src/duckdb/src/main/relation.cpp +12 -8
- package/src/duckdb/src/main/secret/default_secrets.cpp +108 -0
- package/src/duckdb/src/main/secret/secret.cpp +145 -2
- package/src/duckdb/src/main/secret/secret_manager.cpp +85 -35
- package/src/duckdb/src/main/secret/secret_storage.cpp +29 -17
- package/src/duckdb/src/main/settings/settings.cpp +503 -11
- package/src/duckdb/src/main/stream_query_result.cpp +75 -2
- package/src/duckdb/src/optimizer/build_probe_side_optimizer.cpp +248 -0
- package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +28 -6
- package/src/duckdb/src/optimizer/compressed_materialization/compress_comparison_join.cpp +152 -0
- package/src/duckdb/src/optimizer/compressed_materialization.cpp +11 -1
- package/src/duckdb/src/optimizer/cse_optimizer.cpp +3 -0
- package/src/duckdb/src/optimizer/cte_filter_pusher.cpp +117 -0
- package/src/duckdb/src/optimizer/filter_combiner.cpp +30 -9
- package/src/duckdb/src/optimizer/filter_pullup.cpp +54 -2
- package/src/duckdb/src/optimizer/filter_pushdown.cpp +71 -3
- package/src/duckdb/src/optimizer/join_filter_pushdown_optimizer.cpp +154 -0
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +245 -114
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +42 -20
- package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +6 -2
- package/src/duckdb/src/optimizer/join_order/plan_enumerator.cpp +32 -10
- package/src/duckdb/src/optimizer/join_order/query_graph_manager.cpp +97 -131
- package/src/duckdb/src/optimizer/join_order/relation_manager.cpp +265 -51
- package/src/duckdb/src/optimizer/join_order/relation_statistics_helper.cpp +21 -17
- package/src/duckdb/src/optimizer/limit_pushdown.cpp +42 -0
- package/src/duckdb/src/optimizer/optimizer.cpp +51 -8
- package/src/duckdb/src/optimizer/pushdown/pushdown_aggregate.cpp +17 -17
- package/src/duckdb/src/optimizer/pushdown/pushdown_cross_product.cpp +22 -4
- package/src/duckdb/src/optimizer/pushdown/pushdown_get.cpp +1 -18
- package/src/duckdb/src/optimizer/pushdown/pushdown_inner_join.cpp +6 -0
- package/src/duckdb/src/optimizer/pushdown/pushdown_mark_join.cpp +4 -2
- package/src/duckdb/src/optimizer/pushdown/pushdown_window.cpp +91 -0
- package/src/duckdb/src/optimizer/remove_unused_columns.cpp +21 -25
- package/src/duckdb/src/optimizer/rule/comparison_simplification.cpp +1 -0
- package/src/duckdb/src/optimizer/rule/empty_needle_removal.cpp +3 -0
- package/src/duckdb/src/optimizer/rule/equal_or_null_simplification.cpp +2 -2
- package/src/duckdb/src/optimizer/rule/in_clause_simplification_rule.cpp +8 -2
- package/src/duckdb/src/optimizer/rule/join_dependent_filter.cpp +135 -0
- package/src/duckdb/src/optimizer/rule/like_optimizations.cpp +1 -1
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +1 -1
- package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +6 -1
- package/src/duckdb/src/optimizer/statistics/operator/propagate_get.cpp +7 -6
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +1 -1
- package/src/duckdb/src/optimizer/topn_optimizer.cpp +46 -7
- package/src/duckdb/src/parallel/executor.cpp +129 -51
- package/src/duckdb/src/parallel/executor_task.cpp +16 -3
- package/src/duckdb/src/parallel/meta_pipeline.cpp +98 -29
- package/src/duckdb/src/parallel/pipeline.cpp +17 -3
- package/src/duckdb/src/parallel/pipeline_executor.cpp +14 -2
- package/src/duckdb/src/parallel/pipeline_prepare_finish_event.cpp +34 -0
- package/src/duckdb/src/parallel/task_executor.cpp +84 -0
- package/src/duckdb/src/parallel/task_scheduler.cpp +94 -16
- package/src/duckdb/src/parallel/thread_context.cpp +1 -1
- package/src/duckdb/src/parser/expression/function_expression.cpp +14 -0
- package/src/duckdb/src/parser/expression/star_expression.cpp +35 -2
- package/src/duckdb/src/parser/parsed_data/alter_table_info.cpp +5 -1
- package/src/duckdb/src/parser/parsed_data/attach_info.cpp +17 -0
- package/src/duckdb/src/parser/parsed_data/create_index_info.cpp +37 -28
- package/src/duckdb/src/parser/parsed_data/create_macro_info.cpp +44 -2
- package/src/duckdb/src/parser/parsed_data/transaction_info.cpp +21 -1
- package/src/duckdb/src/parser/parsed_expression_iterator.cpp +29 -25
- package/src/duckdb/src/parser/parser.cpp +41 -1
- package/src/duckdb/src/parser/query_node/recursive_cte_node.cpp +1 -0
- package/src/duckdb/src/parser/statement/explain_statement.cpp +28 -13
- package/src/duckdb/src/parser/statement/relation_statement.cpp +5 -0
- package/src/duckdb/src/parser/statement/set_statement.cpp +4 -2
- package/src/duckdb/src/parser/statement/transaction_statement.cpp +3 -3
- package/src/duckdb/src/parser/tableref/column_data_ref.cpp +1 -27
- package/src/duckdb/src/parser/tableref/delimgetref.cpp +30 -0
- package/src/duckdb/src/parser/tableref/joinref.cpp +4 -0
- package/src/duckdb/src/parser/transform/constraint/transform_constraint.cpp +35 -29
- package/src/duckdb/src/parser/transform/expression/transform_array_access.cpp +32 -32
- package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +2 -1
- package/src/duckdb/src/parser/transform/expression/transform_constant.cpp +17 -0
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +5 -0
- package/src/duckdb/src/parser/transform/expression/transform_multi_assign_reference.cpp +36 -34
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +30 -14
- package/src/duckdb/src/parser/transform/expression/transform_subquery.cpp +1 -1
- package/src/duckdb/src/parser/transform/helpers/transform_alias.cpp +2 -1
- package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +27 -19
- package/src/duckdb/src/parser/transform/helpers/transform_orderby.cpp +31 -28
- package/src/duckdb/src/parser/transform/statement/transform_alter_table.cpp +25 -27
- package/src/duckdb/src/parser/transform/statement/transform_copy.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_create_function.cpp +53 -42
- package/src/duckdb/src/parser/transform/statement/transform_create_table.cpp +6 -6
- package/src/duckdb/src/parser/transform/statement/transform_create_table_as.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_create_view.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_explain.cpp +38 -3
- package/src/duckdb/src/parser/transform/statement/transform_insert.cpp +1 -2
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_prepare.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_select.cpp +26 -21
- package/src/duckdb/src/parser/transform/statement/transform_set.cpp +8 -8
- package/src/duckdb/src/parser/transform/statement/transform_show.cpp +5 -2
- package/src/duckdb/src/parser/transform/statement/transform_show_select.cpp +6 -4
- package/src/duckdb/src/parser/transform/statement/transform_transaction.cpp +27 -6
- package/src/duckdb/src/parser/transform/statement/transform_update.cpp +8 -9
- package/src/duckdb/src/parser/transform/statement/transform_upsert.cpp +11 -12
- package/src/duckdb/src/parser/transform/statement/transform_vacuum.cpp +3 -3
- package/src/duckdb/src/parser/transform/tableref/transform_join.cpp +16 -10
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +1 -1
- package/src/duckdb/src/parser/transform/tableref/transform_subquery.cpp +1 -1
- package/src/duckdb/src/parser/transformer.cpp +11 -7
- package/src/duckdb/src/planner/bind_context.cpp +3 -3
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +22 -7
- package/src/duckdb/src/planner/binder/expression/bind_between_expression.cpp +3 -3
- package/src/duckdb/src/planner/binder/expression/bind_collate_expression.cpp +3 -2
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +11 -4
- package/src/duckdb/src/planner/binder/expression/bind_comparison_expression.cpp +9 -54
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +3 -5
- package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +24 -27
- package/src/duckdb/src/planner/binder/expression/bind_operator_expression.cpp +7 -7
- package/src/duckdb/src/planner/binder/expression/bind_parameter_expression.cpp +9 -2
- package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +26 -7
- package/src/duckdb/src/planner/binder/expression/bind_unnest_expression.cpp +5 -0
- package/src/duckdb/src/planner/binder/expression/bind_unpacked_star_expression.cpp +91 -0
- package/src/duckdb/src/planner/binder/expression/bind_window_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +11 -8
- package/src/duckdb/src/planner/binder/query_node/bind_setop_node.cpp +1 -1
- package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +6 -10
- package/src/duckdb/src/planner/binder/query_node/plan_cte_node.cpp +14 -10
- package/src/duckdb/src/planner/binder/query_node/plan_setop.cpp +3 -3
- package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +46 -7
- package/src/duckdb/src/planner/binder/statement/bind_call.cpp +13 -20
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +105 -13
- package/src/duckdb/src/planner/binder/statement/bind_copy_database.cpp +7 -3
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +75 -55
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +5 -4
- package/src/duckdb/src/planner/binder/statement/bind_drop.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_execute.cpp +24 -8
- package/src/duckdb/src/planner/binder/statement/bind_explain.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +5 -105
- package/src/duckdb/src/planner/binder/statement/bind_extension.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +109 -41
- package/src/duckdb/src/planner/binder/statement/bind_set.cpp +23 -7
- package/src/duckdb/src/planner/binder/statement/bind_simple.cpp +4 -1
- package/src/duckdb/src/planner/binder/statement/bind_summarize.cpp +17 -3
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +5 -4
- package/src/duckdb/src/planner/binder/statement/bind_vacuum.cpp +8 -6
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +55 -42
- package/src/duckdb/src/planner/binder/tableref/bind_column_data_ref.cpp +3 -2
- package/src/duckdb/src/planner/binder/tableref/bind_delimgetref.cpp +16 -0
- package/src/duckdb/src/planner/binder/tableref/bind_joinref.cpp +31 -1
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +6 -0
- package/src/duckdb/src/planner/binder/tableref/bind_showref.cpp +2 -0
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +106 -46
- package/src/duckdb/src/planner/binder/tableref/plan_delimgetref.cpp +11 -0
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +15 -2
- package/src/duckdb/src/planner/binder/tableref/plan_table_function.cpp +4 -0
- package/src/duckdb/src/planner/binder.cpp +172 -15
- package/src/duckdb/src/planner/collation_binding.cpp +99 -0
- package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +10 -4
- package/src/duckdb/src/planner/expression/bound_between_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_case_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +14 -12
- package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_comparison_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_conjunction_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_constant_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_expanded_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_function_expression.cpp +8 -2
- package/src/duckdb/src/planner/expression/bound_lambda_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_lambdaref_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_operator_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_parameter_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_subquery_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_unnest_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_window_expression.cpp +6 -6
- package/src/duckdb/src/planner/expression_binder/aggregate_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/alter_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/column_alias_binder.cpp +7 -0
- package/src/duckdb/src/planner/expression_binder/constant_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/group_binder.cpp +26 -22
- package/src/duckdb/src/planner/expression_binder/having_binder.cpp +7 -1
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/insert_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/order_binder.cpp +61 -43
- package/src/duckdb/src/planner/expression_binder/qualify_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/relation_binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/returning_binder.cpp +3 -2
- package/src/duckdb/src/planner/expression_binder/table_function_binder.cpp +10 -3
- package/src/duckdb/src/planner/expression_binder/update_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/where_binder.cpp +9 -2
- package/src/duckdb/src/planner/expression_binder.cpp +121 -21
- package/src/duckdb/src/planner/expression_iterator.cpp +26 -1
- package/src/duckdb/src/planner/filter/conjunction_filter.cpp +33 -0
- package/src/duckdb/src/planner/filter/constant_filter.cpp +15 -0
- package/src/duckdb/src/planner/filter/null_filter.cpp +22 -0
- package/src/duckdb/src/planner/filter/struct_filter.cpp +16 -0
- package/src/duckdb/src/planner/logical_operator.cpp +24 -7
- package/src/duckdb/src/planner/operator/logical_aggregate.cpp +13 -7
- package/src/duckdb/src/planner/operator/logical_any_join.cpp +5 -2
- package/src/duckdb/src/planner/operator/logical_comparison_join.cpp +13 -5
- package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +64 -8
- package/src/duckdb/src/planner/operator/logical_cteref.cpp +7 -0
- package/src/duckdb/src/planner/operator/logical_distinct.cpp +6 -5
- package/src/duckdb/src/planner/operator/logical_get.cpp +60 -18
- package/src/duckdb/src/planner/operator/logical_materialized_cte.cpp +7 -0
- package/src/duckdb/src/planner/operator/logical_order.cpp +7 -4
- package/src/duckdb/src/planner/operator/logical_top_n.cpp +2 -2
- package/src/duckdb/src/planner/operator/logical_vacuum.cpp +1 -1
- package/src/duckdb/src/planner/planner.cpp +2 -3
- package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +27 -10
- package/src/duckdb/src/planner/table_filter.cpp +51 -0
- package/src/duckdb/src/storage/arena_allocator.cpp +28 -10
- package/src/duckdb/src/storage/block.cpp +3 -2
- package/src/duckdb/src/storage/buffer/block_handle.cpp +29 -14
- package/src/duckdb/src/storage/buffer/block_manager.cpp +6 -5
- package/src/duckdb/src/storage/buffer/buffer_handle.cpp +1 -1
- package/src/duckdb/src/storage/buffer/buffer_pool.cpp +264 -125
- package/src/duckdb/src/storage/buffer_manager.cpp +5 -1
- package/src/duckdb/src/storage/checkpoint/row_group_writer.cpp +0 -6
- package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +26 -3
- package/src/duckdb/src/storage/checkpoint/write_overflow_strings_to_disk.cpp +21 -9
- package/src/duckdb/src/storage/checkpoint_manager.cpp +49 -24
- package/src/duckdb/src/storage/compression/alp/alp.cpp +6 -11
- package/src/duckdb/src/storage/compression/alprd.cpp +5 -9
- package/src/duckdb/src/storage/compression/bitpacking.cpp +35 -31
- package/src/duckdb/src/storage/compression/chimp/chimp.cpp +6 -8
- package/src/duckdb/src/storage/compression/dictionary_compression.cpp +71 -58
- package/src/duckdb/src/storage/compression/fixed_size_uncompressed.cpp +15 -13
- package/src/duckdb/src/storage/compression/fsst.cpp +66 -53
- package/src/duckdb/src/storage/compression/numeric_constant.cpp +4 -5
- package/src/duckdb/src/storage/compression/patas.cpp +6 -17
- package/src/duckdb/src/storage/compression/rle.cpp +20 -18
- package/src/duckdb/src/storage/compression/string_uncompressed.cpp +71 -52
- package/src/duckdb/src/storage/compression/uncompressed.cpp +2 -2
- package/src/duckdb/src/storage/compression/validity_uncompressed.cpp +8 -7
- package/src/duckdb/src/storage/data_pointer.cpp +22 -0
- package/src/duckdb/src/storage/data_table.cpp +41 -12
- package/src/duckdb/src/storage/local_storage.cpp +22 -8
- package/src/duckdb/src/storage/metadata/metadata_manager.cpp +33 -17
- package/src/duckdb/src/storage/metadata/metadata_reader.cpp +4 -4
- package/src/duckdb/src/storage/metadata/metadata_writer.cpp +3 -3
- package/src/duckdb/src/storage/partial_block_manager.cpp +19 -8
- package/src/duckdb/src/storage/serialization/serialize_create_info.cpp +11 -8
- package/src/duckdb/src/storage/serialization/serialize_expression.cpp +1 -1
- package/src/duckdb/src/storage/serialization/serialize_extension_install_info.cpp +2 -0
- package/src/duckdb/src/storage/serialization/serialize_logical_operator.cpp +3 -3
- package/src/duckdb/src/storage/serialization/serialize_nodes.cpp +19 -5
- package/src/duckdb/src/storage/serialization/serialize_parse_info.cpp +21 -1
- package/src/duckdb/src/storage/serialization/serialize_parsed_expression.cpp +4 -2
- package/src/duckdb/src/storage/serialization/serialize_query_node.cpp +2 -2
- package/src/duckdb/src/storage/serialization/serialize_storage.cpp +2 -0
- package/src/duckdb/src/storage/serialization/serialize_tableref.cpp +8 -4
- package/src/duckdb/src/storage/serialization/serialize_types.cpp +4 -4
- package/src/duckdb/src/storage/single_file_block_manager.cpp +170 -34
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +221 -64
- package/src/duckdb/src/storage/statistics/column_statistics.cpp +4 -3
- package/src/duckdb/src/storage/statistics/distinct_statistics.cpp +36 -26
- package/src/duckdb/src/storage/statistics/numeric_stats.cpp +4 -15
- package/src/duckdb/src/storage/statistics/string_stats.cpp +14 -8
- package/src/duckdb/src/storage/statistics/struct_stats.cpp +2 -1
- package/src/duckdb/src/storage/storage_info.cpp +34 -9
- package/src/duckdb/src/storage/storage_manager.cpp +147 -74
- package/src/duckdb/src/storage/table/array_column_data.cpp +37 -17
- package/src/duckdb/src/storage/table/chunk_info.cpp +38 -0
- package/src/duckdb/src/storage/table/column_checkpoint_state.cpp +10 -6
- package/src/duckdb/src/storage/table/column_data.cpp +252 -31
- package/src/duckdb/src/storage/table/column_data_checkpointer.cpp +2 -12
- package/src/duckdb/src/storage/table/column_segment.cpp +63 -34
- package/src/duckdb/src/storage/table/list_column_data.cpp +34 -15
- package/src/duckdb/src/storage/table/row_group.cpp +228 -120
- package/src/duckdb/src/storage/table/row_group_collection.cpp +122 -120
- package/src/duckdb/src/storage/table/row_version_manager.cpp +27 -1
- package/src/duckdb/src/storage/table/scan_state.cpp +101 -18
- package/src/duckdb/src/storage/table/standard_column_data.cpp +20 -34
- package/src/duckdb/src/storage/table/struct_column_data.cpp +39 -42
- package/src/duckdb/src/storage/table/table_statistics.cpp +2 -1
- package/src/duckdb/src/storage/table/update_segment.cpp +9 -8
- package/src/duckdb/src/storage/table/validity_column_data.cpp +2 -2
- package/src/duckdb/src/storage/table_index_list.cpp +8 -7
- package/src/duckdb/src/storage/temporary_file_manager.cpp +11 -9
- package/src/duckdb/src/storage/temporary_memory_manager.cpp +227 -39
- package/src/duckdb/src/storage/wal_replay.cpp +68 -28
- package/src/duckdb/src/storage/write_ahead_log.cpp +56 -47
- package/src/duckdb/src/transaction/cleanup_state.cpp +9 -1
- package/src/duckdb/src/transaction/commit_state.cpp +7 -170
- package/src/duckdb/src/transaction/duck_transaction.cpp +87 -19
- package/src/duckdb/src/transaction/duck_transaction_manager.cpp +65 -10
- package/src/duckdb/src/transaction/meta_transaction.cpp +18 -3
- package/src/duckdb/src/transaction/transaction_context.cpp +21 -17
- package/src/duckdb/src/transaction/undo_buffer.cpp +20 -14
- package/src/duckdb/src/transaction/wal_write_state.cpp +292 -0
- package/src/duckdb/src/verification/prepared_statement_verifier.cpp +0 -1
- package/src/duckdb/third_party/brotli/common/brotli_constants.h +204 -0
- package/src/duckdb/third_party/brotli/common/brotli_platform.h +543 -0
- package/src/duckdb/third_party/brotli/common/constants.cpp +17 -0
- package/src/duckdb/third_party/brotli/common/context.cpp +156 -0
- package/src/duckdb/third_party/brotli/common/context.h +110 -0
- package/src/duckdb/third_party/brotli/common/dictionary.cpp +5912 -0
- package/src/duckdb/third_party/brotli/common/dictionary.h +60 -0
- package/src/duckdb/third_party/brotli/common/platform.cpp +24 -0
- package/src/duckdb/third_party/brotli/common/shared_dictionary.cpp +517 -0
- package/src/duckdb/third_party/brotli/common/shared_dictionary_internal.h +71 -0
- package/src/duckdb/third_party/brotli/common/transform.cpp +287 -0
- package/src/duckdb/third_party/brotli/common/transform.h +77 -0
- package/src/duckdb/third_party/brotli/common/version.h +51 -0
- package/src/duckdb/third_party/brotli/dec/bit_reader.cpp +74 -0
- package/src/duckdb/third_party/brotli/dec/bit_reader.h +419 -0
- package/src/duckdb/third_party/brotli/dec/decode.cpp +2758 -0
- package/src/duckdb/third_party/brotli/dec/huffman.cpp +338 -0
- package/src/duckdb/third_party/brotli/dec/huffman.h +118 -0
- package/src/duckdb/third_party/brotli/dec/prefix.h +733 -0
- package/src/duckdb/third_party/brotli/dec/state.cpp +178 -0
- package/src/duckdb/third_party/brotli/dec/state.h +386 -0
- package/src/duckdb/third_party/brotli/enc/backward_references.cpp +3775 -0
- package/src/duckdb/third_party/brotli/enc/backward_references.h +36 -0
- package/src/duckdb/third_party/brotli/enc/backward_references_hq.cpp +935 -0
- package/src/duckdb/third_party/brotli/enc/backward_references_hq.h +92 -0
- package/src/duckdb/third_party/brotli/enc/bit_cost.cpp +410 -0
- package/src/duckdb/third_party/brotli/enc/bit_cost.h +60 -0
- package/src/duckdb/third_party/brotli/enc/block_splitter.cpp +1653 -0
- package/src/duckdb/third_party/brotli/enc/block_splitter.h +48 -0
- package/src/duckdb/third_party/brotli/enc/brotli_bit_stream.cpp +1431 -0
- package/src/duckdb/third_party/brotli/enc/brotli_bit_stream.h +85 -0
- package/src/duckdb/third_party/brotli/enc/brotli_hash.h +4352 -0
- package/src/duckdb/third_party/brotli/enc/brotli_params.h +47 -0
- package/src/duckdb/third_party/brotli/enc/cluster.cpp +1025 -0
- package/src/duckdb/third_party/brotli/enc/cluster.h +1017 -0
- package/src/duckdb/third_party/brotli/enc/command.cpp +24 -0
- package/src/duckdb/third_party/brotli/enc/command.h +187 -0
- package/src/duckdb/third_party/brotli/enc/compound_dictionary.cpp +209 -0
- package/src/duckdb/third_party/brotli/enc/compound_dictionary.h +75 -0
- package/src/duckdb/third_party/brotli/enc/compress_fragment.cpp +796 -0
- package/src/duckdb/third_party/brotli/enc/compress_fragment.h +82 -0
- package/src/duckdb/third_party/brotli/enc/compress_fragment_two_pass.cpp +653 -0
- package/src/duckdb/third_party/brotli/enc/compress_fragment_two_pass.h +68 -0
- package/src/duckdb/third_party/brotli/enc/dictionary_hash.cpp +1844 -0
- package/src/duckdb/third_party/brotli/enc/dictionary_hash.h +21 -0
- package/src/duckdb/third_party/brotli/enc/encode.cpp +1990 -0
- package/src/duckdb/third_party/brotli/enc/encoder_dict.cpp +636 -0
- package/src/duckdb/third_party/brotli/enc/encoder_dict.h +153 -0
- package/src/duckdb/third_party/brotli/enc/entropy_encode.cpp +500 -0
- package/src/duckdb/third_party/brotli/enc/entropy_encode.h +119 -0
- package/src/duckdb/third_party/brotli/enc/entropy_encode_static.h +538 -0
- package/src/duckdb/third_party/brotli/enc/fast_log.cpp +101 -0
- package/src/duckdb/third_party/brotli/enc/fast_log.h +63 -0
- package/src/duckdb/third_party/brotli/enc/find_match_length.h +68 -0
- package/src/duckdb/third_party/brotli/enc/histogram.cpp +96 -0
- package/src/duckdb/third_party/brotli/enc/histogram.h +210 -0
- package/src/duckdb/third_party/brotli/enc/literal_cost.cpp +176 -0
- package/src/duckdb/third_party/brotli/enc/literal_cost.h +28 -0
- package/src/duckdb/third_party/brotli/enc/memory.cpp +190 -0
- package/src/duckdb/third_party/brotli/enc/memory.h +127 -0
- package/src/duckdb/third_party/brotli/enc/metablock.cpp +1225 -0
- package/src/duckdb/third_party/brotli/enc/metablock.h +102 -0
- package/src/duckdb/third_party/brotli/enc/prefix.h +50 -0
- package/src/duckdb/third_party/brotli/enc/quality.h +202 -0
- package/src/duckdb/third_party/brotli/enc/ringbuffer.h +164 -0
- package/src/duckdb/third_party/brotli/enc/state.h +106 -0
- package/src/duckdb/third_party/brotli/enc/static_dict.cpp +538 -0
- package/src/duckdb/third_party/brotli/enc/static_dict.h +37 -0
- package/src/duckdb/third_party/brotli/enc/static_dict_lut.h +5862 -0
- package/src/duckdb/third_party/brotli/enc/utf8_util.cpp +81 -0
- package/src/duckdb/third_party/brotli/enc/utf8_util.h +29 -0
- package/src/duckdb/third_party/brotli/enc/write_bits.h +84 -0
- package/src/duckdb/third_party/brotli/include/brotli/decode.h +405 -0
- package/src/duckdb/third_party/brotli/include/brotli/encode.h +489 -0
- package/src/duckdb/third_party/brotli/include/brotli/port.h +238 -0
- package/src/duckdb/third_party/brotli/include/brotli/shared_dictionary.h +96 -0
- package/src/duckdb/third_party/brotli/include/brotli/types.h +83 -0
- package/src/duckdb/third_party/fast_float/fast_float/fast_float.h +20 -4
- package/src/duckdb/third_party/fmt/include/fmt/format.h +54 -10
- package/src/duckdb/third_party/fsst/fsst.h +2 -2
- package/src/duckdb/third_party/fsst/libfsst.hpp +2 -2
- package/src/duckdb/third_party/httplib/httplib.hpp +6763 -5580
- package/src/duckdb/third_party/hyperloglog/hyperloglog.cpp +13 -30
- package/src/duckdb/third_party/hyperloglog/hyperloglog.hpp +8 -2
- package/src/duckdb/third_party/libpg_query/include/nodes/nodes.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +22 -9
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +1041 -554
- package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +1 -0
- package/src/duckdb/third_party/libpg_query/postgres_parser.cpp +2 -1
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +21605 -21752
- package/src/duckdb/third_party/libpg_query/src_backend_parser_scan.cpp +538 -299
- package/src/duckdb/third_party/mbedtls/include/mbedtls/mbedtls_config.h +1 -0
- package/src/duckdb/third_party/mbedtls/include/mbedtls_wrapper.hpp +36 -12
- package/src/duckdb/third_party/mbedtls/library/md.cpp +6 -6
- package/src/duckdb/third_party/mbedtls/library/sha1.cpp +2 -0
- package/src/duckdb/third_party/mbedtls/library/sha256.cpp +3 -0
- package/src/duckdb/third_party/mbedtls/mbedtls_wrapper.cpp +99 -47
- package/src/duckdb/third_party/pcg/pcg_extras.hpp +1 -1
- package/src/duckdb/third_party/re2/re2/prog.cc +2 -2
- package/src/duckdb/third_party/snappy/snappy-internal.h +398 -0
- package/src/duckdb/third_party/snappy/snappy-sinksource.cc +111 -9
- package/src/duckdb/third_party/snappy/snappy-sinksource.h +158 -0
- package/src/duckdb/third_party/snappy/snappy-stubs-internal.h +523 -3
- package/src/duckdb/third_party/snappy/snappy-stubs-public.h +34 -1
- package/src/duckdb/third_party/snappy/snappy.cc +2626 -0
- package/src/duckdb/third_party/snappy/snappy.h +223 -0
- package/src/duckdb/third_party/snappy/snappy_version.hpp +11 -0
- package/src/duckdb/third_party/utf8proc/include/utf8proc.hpp +69 -101
- package/src/duckdb/third_party/utf8proc/include/utf8proc_wrapper.hpp +53 -0
- package/src/duckdb/third_party/utf8proc/utf8proc.cpp +627 -678
- package/src/duckdb/third_party/utf8proc/utf8proc_data.cpp +15008 -12868
- package/src/duckdb/third_party/utf8proc/utf8proc_wrapper.cpp +185 -29
- package/src/duckdb/ub_extension_json_json_functions.cpp +6 -0
- package/src/duckdb/ub_src_catalog_default.cpp +4 -0
- package/src/duckdb/ub_src_common.cpp +7 -1
- package/src/duckdb/ub_src_common_arrow.cpp +10 -0
- package/src/duckdb/ub_src_common_enums.cpp +2 -0
- package/src/duckdb/ub_src_common_tree_renderer.cpp +10 -0
- package/src/duckdb/ub_src_common_types.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_aggregate_holistic.cpp +4 -0
- package/src/duckdb/ub_src_core_functions_aggregate_nested.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_scalar_generic.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_scalar_list.cpp +2 -4
- package/src/duckdb/ub_src_core_functions_scalar_map.cpp +2 -0
- package/src/duckdb/ub_src_core_functions_scalar_string.cpp +4 -0
- package/src/duckdb/ub_src_execution_index_art.cpp +5 -3
- package/src/duckdb/ub_src_execution_operator_csv_scanner_scanner.cpp +2 -0
- package/src/duckdb/ub_src_execution_operator_helper.cpp +4 -0
- package/src/duckdb/ub_src_function.cpp +4 -0
- package/src/duckdb/ub_src_function_cast.cpp +2 -0
- package/src/duckdb/ub_src_function_scalar_generic.cpp +4 -0
- package/src/duckdb/ub_src_function_scalar_list.cpp +0 -2
- package/src/duckdb/ub_src_function_scalar_string.cpp +2 -0
- package/src/duckdb/ub_src_function_table.cpp +2 -0
- package/src/duckdb/ub_src_function_table_arrow.cpp +2 -0
- package/src/duckdb/ub_src_function_table_system.cpp +2 -0
- package/src/duckdb/ub_src_main.cpp +4 -0
- package/src/duckdb/ub_src_main_buffered_data.cpp +4 -0
- package/src/duckdb/ub_src_main_capi.cpp +10 -0
- package/src/duckdb/ub_src_main_chunk_scan_state.cpp +2 -0
- package/src/duckdb/ub_src_main_relation.cpp +2 -0
- package/src/duckdb/ub_src_main_secret.cpp +2 -0
- package/src/duckdb/ub_src_optimizer.cpp +8 -0
- package/src/duckdb/ub_src_optimizer_compressed_materialization.cpp +2 -0
- package/src/duckdb/ub_src_optimizer_pushdown.cpp +2 -0
- package/src/duckdb/ub_src_optimizer_rule.cpp +2 -0
- package/src/duckdb/ub_src_parallel.cpp +4 -0
- package/src/duckdb/ub_src_parser_tableref.cpp +2 -0
- package/src/duckdb/ub_src_planner.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_expression.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_tableref.cpp +4 -0
- package/src/duckdb/ub_src_storage_statistics.cpp +0 -2
- package/src/duckdb/ub_src_transaction.cpp +2 -0
- package/test/columns.test.ts +1 -1
- package/test/prepare.test.ts +1 -1
- package/test/test_all_types.test.ts +1 -1
@@ -1,141 +1,18 @@
|
|
1
1
|
#include "duckdb/execution/expression_executor.hpp"
|
2
2
|
#include "duckdb/core_functions/aggregate/holistic_functions.hpp"
|
3
|
-
#include "duckdb/execution/merge_sort_tree.hpp"
|
4
3
|
#include "duckdb/core_functions/aggregate/quantile_enum.hpp"
|
5
4
|
#include "duckdb/planner/expression.hpp"
|
6
5
|
#include "duckdb/common/operator/cast_operators.hpp"
|
7
6
|
#include "duckdb/common/operator/abs.hpp"
|
8
|
-
#include "duckdb/
|
9
|
-
|
7
|
+
#include "duckdb/core_functions/aggregate/quantile_state.hpp"
|
10
8
|
#include "duckdb/common/types/timestamp.hpp"
|
11
9
|
#include "duckdb/common/queue.hpp"
|
12
10
|
#include "duckdb/common/serializer/serializer.hpp"
|
13
11
|
#include "duckdb/common/serializer/deserializer.hpp"
|
14
|
-
|
15
|
-
#include "SkipList.h"
|
16
|
-
|
17
|
-
#include <algorithm>
|
18
|
-
#include <numeric>
|
19
|
-
#include <stdlib.h>
|
20
|
-
#include <utility>
|
12
|
+
#include "duckdb/core_functions/aggregate/sort_key_helpers.hpp"
|
21
13
|
|
22
14
|
namespace duckdb {
|
23
15
|
|
24
|
-
// Interval arithmetic
|
25
|
-
static interval_t MultiplyByDouble(const interval_t &i, const double &d) { // NOLINT
|
26
|
-
D_ASSERT(d >= 0 && d <= 1);
|
27
|
-
return Interval::FromMicro(std::llround(Interval::GetMicro(i) * d));
|
28
|
-
}
|
29
|
-
|
30
|
-
inline interval_t operator+(const interval_t &lhs, const interval_t &rhs) {
|
31
|
-
return Interval::FromMicro(Interval::GetMicro(lhs) + Interval::GetMicro(rhs));
|
32
|
-
}
|
33
|
-
|
34
|
-
inline interval_t operator-(const interval_t &lhs, const interval_t &rhs) {
|
35
|
-
return Interval::FromMicro(Interval::GetMicro(lhs) - Interval::GetMicro(rhs));
|
36
|
-
}
|
37
|
-
|
38
|
-
struct FrameSet {
|
39
|
-
inline explicit FrameSet(const SubFrames &frames_p) : frames(frames_p) {
|
40
|
-
}
|
41
|
-
|
42
|
-
inline idx_t Size() const {
|
43
|
-
idx_t result = 0;
|
44
|
-
for (const auto &frame : frames) {
|
45
|
-
result += frame.end - frame.start;
|
46
|
-
}
|
47
|
-
|
48
|
-
return result;
|
49
|
-
}
|
50
|
-
|
51
|
-
inline bool Contains(idx_t i) const {
|
52
|
-
for (idx_t f = 0; f < frames.size(); ++f) {
|
53
|
-
const auto &frame = frames[f];
|
54
|
-
if (frame.start <= i && i < frame.end) {
|
55
|
-
return true;
|
56
|
-
}
|
57
|
-
}
|
58
|
-
return false;
|
59
|
-
}
|
60
|
-
const SubFrames &frames;
|
61
|
-
};
|
62
|
-
|
63
|
-
struct QuantileIncluded {
|
64
|
-
inline explicit QuantileIncluded(const ValidityMask &fmask_p, const ValidityMask &dmask_p)
|
65
|
-
: fmask(fmask_p), dmask(dmask_p) {
|
66
|
-
}
|
67
|
-
|
68
|
-
inline bool operator()(const idx_t &idx) const {
|
69
|
-
return fmask.RowIsValid(idx) && dmask.RowIsValid(idx);
|
70
|
-
}
|
71
|
-
|
72
|
-
inline bool AllValid() const {
|
73
|
-
return fmask.AllValid() && dmask.AllValid();
|
74
|
-
}
|
75
|
-
|
76
|
-
const ValidityMask &fmask;
|
77
|
-
const ValidityMask &dmask;
|
78
|
-
};
|
79
|
-
|
80
|
-
struct QuantileReuseUpdater {
|
81
|
-
idx_t *index;
|
82
|
-
idx_t j;
|
83
|
-
|
84
|
-
inline QuantileReuseUpdater(idx_t *index, idx_t j) : index(index), j(j) {
|
85
|
-
}
|
86
|
-
|
87
|
-
inline void Neither(idx_t begin, idx_t end) {
|
88
|
-
}
|
89
|
-
|
90
|
-
inline void Left(idx_t begin, idx_t end) {
|
91
|
-
}
|
92
|
-
|
93
|
-
inline void Right(idx_t begin, idx_t end) {
|
94
|
-
for (; begin < end; ++begin) {
|
95
|
-
index[j++] = begin;
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
inline void Both(idx_t begin, idx_t end) {
|
100
|
-
}
|
101
|
-
};
|
102
|
-
|
103
|
-
void ReuseIndexes(idx_t *index, const SubFrames &currs, const SubFrames &prevs) {
|
104
|
-
|
105
|
-
// Copy overlapping indices by scanning the previous set and copying down into holes.
|
106
|
-
// We copy instead of leaving gaps in case there are fewer values in the current frame.
|
107
|
-
FrameSet prev_set(prevs);
|
108
|
-
FrameSet curr_set(currs);
|
109
|
-
const auto prev_count = prev_set.Size();
|
110
|
-
idx_t j = 0;
|
111
|
-
for (idx_t p = 0; p < prev_count; ++p) {
|
112
|
-
auto idx = index[p];
|
113
|
-
|
114
|
-
// Shift down into any hole
|
115
|
-
if (j != p) {
|
116
|
-
index[j] = idx;
|
117
|
-
}
|
118
|
-
|
119
|
-
// Skip overlapping values
|
120
|
-
if (curr_set.Contains(idx)) {
|
121
|
-
++j;
|
122
|
-
}
|
123
|
-
}
|
124
|
-
|
125
|
-
// Insert new indices
|
126
|
-
if (j > 0) {
|
127
|
-
QuantileReuseUpdater updater(index, j);
|
128
|
-
AggregateExecutor::IntersectFrames(prevs, currs, updater);
|
129
|
-
} else {
|
130
|
-
// No overlap: overwrite with new values
|
131
|
-
for (const auto &curr : currs) {
|
132
|
-
for (auto idx = curr.start; idx < curr.end; ++idx) {
|
133
|
-
index[j++] = idx;
|
134
|
-
}
|
135
|
-
}
|
136
|
-
}
|
137
|
-
}
|
138
|
-
|
139
16
|
template <class INPUT_TYPE>
|
140
17
|
struct IndirectLess {
|
141
18
|
inline explicit IndirectLess(const INPUT_TYPE *inputs_p) : inputs(inputs_p) {
|
@@ -148,262 +25,6 @@ struct IndirectLess {
|
|
148
25
|
const INPUT_TYPE *inputs;
|
149
26
|
};
|
150
27
|
|
151
|
-
struct CastInterpolation {
|
152
|
-
|
153
|
-
template <class INPUT_TYPE, class TARGET_TYPE>
|
154
|
-
static inline TARGET_TYPE Cast(const INPUT_TYPE &src, Vector &result) {
|
155
|
-
return Cast::Operation<INPUT_TYPE, TARGET_TYPE>(src);
|
156
|
-
}
|
157
|
-
template <typename TARGET_TYPE>
|
158
|
-
static inline TARGET_TYPE Interpolate(const TARGET_TYPE &lo, const double d, const TARGET_TYPE &hi) {
|
159
|
-
const auto delta = hi - lo;
|
160
|
-
return UnsafeNumericCast<TARGET_TYPE>(lo + delta * d);
|
161
|
-
}
|
162
|
-
};
|
163
|
-
|
164
|
-
template <>
|
165
|
-
interval_t CastInterpolation::Cast(const dtime_t &src, Vector &result) {
|
166
|
-
return {0, 0, src.micros};
|
167
|
-
}
|
168
|
-
|
169
|
-
template <>
|
170
|
-
double CastInterpolation::Interpolate(const double &lo, const double d, const double &hi) {
|
171
|
-
return lo * (1.0 - d) + hi * d;
|
172
|
-
}
|
173
|
-
|
174
|
-
template <>
|
175
|
-
dtime_t CastInterpolation::Interpolate(const dtime_t &lo, const double d, const dtime_t &hi) {
|
176
|
-
return dtime_t(std::llround(lo.micros * (1.0 - d) + hi.micros * d));
|
177
|
-
}
|
178
|
-
|
179
|
-
template <>
|
180
|
-
timestamp_t CastInterpolation::Interpolate(const timestamp_t &lo, const double d, const timestamp_t &hi) {
|
181
|
-
return timestamp_t(std::llround(lo.value * (1.0 - d) + hi.value * d));
|
182
|
-
}
|
183
|
-
|
184
|
-
template <>
|
185
|
-
hugeint_t CastInterpolation::Interpolate(const hugeint_t &lo, const double d, const hugeint_t &hi) {
|
186
|
-
return Hugeint::Convert(Interpolate(Hugeint::Cast<double>(lo), d, Hugeint::Cast<double>(hi)));
|
187
|
-
}
|
188
|
-
|
189
|
-
template <>
|
190
|
-
interval_t CastInterpolation::Interpolate(const interval_t &lo, const double d, const interval_t &hi) {
|
191
|
-
const interval_t delta = hi - lo;
|
192
|
-
return lo + MultiplyByDouble(delta, d);
|
193
|
-
}
|
194
|
-
|
195
|
-
template <>
|
196
|
-
string_t CastInterpolation::Cast(const std::string &src, Vector &result) {
|
197
|
-
return StringVector::AddString(result, src);
|
198
|
-
}
|
199
|
-
|
200
|
-
template <>
|
201
|
-
string_t CastInterpolation::Cast(const string_t &src, Vector &result) {
|
202
|
-
return StringVector::AddString(result, src);
|
203
|
-
}
|
204
|
-
|
205
|
-
// Direct access
|
206
|
-
template <typename T>
|
207
|
-
struct QuantileDirect {
|
208
|
-
using INPUT_TYPE = T;
|
209
|
-
using RESULT_TYPE = T;
|
210
|
-
|
211
|
-
inline const INPUT_TYPE &operator()(const INPUT_TYPE &x) const {
|
212
|
-
return x;
|
213
|
-
}
|
214
|
-
};
|
215
|
-
|
216
|
-
// Indirect access
|
217
|
-
template <typename T>
|
218
|
-
struct QuantileIndirect {
|
219
|
-
using INPUT_TYPE = idx_t;
|
220
|
-
using RESULT_TYPE = T;
|
221
|
-
const RESULT_TYPE *data;
|
222
|
-
|
223
|
-
explicit QuantileIndirect(const RESULT_TYPE *data_p) : data(data_p) {
|
224
|
-
}
|
225
|
-
|
226
|
-
inline RESULT_TYPE operator()(const idx_t &input) const {
|
227
|
-
return data[input];
|
228
|
-
}
|
229
|
-
};
|
230
|
-
|
231
|
-
// Composed access
|
232
|
-
template <typename OUTER, typename INNER>
|
233
|
-
struct QuantileComposed {
|
234
|
-
using INPUT_TYPE = typename INNER::INPUT_TYPE;
|
235
|
-
using RESULT_TYPE = typename OUTER::RESULT_TYPE;
|
236
|
-
|
237
|
-
const OUTER &outer;
|
238
|
-
const INNER &inner;
|
239
|
-
|
240
|
-
explicit QuantileComposed(const OUTER &outer_p, const INNER &inner_p) : outer(outer_p), inner(inner_p) {
|
241
|
-
}
|
242
|
-
|
243
|
-
inline RESULT_TYPE operator()(const idx_t &input) const {
|
244
|
-
return outer(inner(input));
|
245
|
-
}
|
246
|
-
};
|
247
|
-
|
248
|
-
// Accessed comparison
|
249
|
-
template <typename ACCESSOR>
|
250
|
-
struct QuantileCompare {
|
251
|
-
using INPUT_TYPE = typename ACCESSOR::INPUT_TYPE;
|
252
|
-
const ACCESSOR &accessor;
|
253
|
-
const bool desc;
|
254
|
-
explicit QuantileCompare(const ACCESSOR &accessor_p, bool desc_p) : accessor(accessor_p), desc(desc_p) {
|
255
|
-
}
|
256
|
-
|
257
|
-
inline bool operator()(const INPUT_TYPE &lhs, const INPUT_TYPE &rhs) const {
|
258
|
-
const auto lval = accessor(lhs);
|
259
|
-
const auto rval = accessor(rhs);
|
260
|
-
|
261
|
-
return desc ? (rval < lval) : (lval < rval);
|
262
|
-
}
|
263
|
-
};
|
264
|
-
|
265
|
-
// Avoid using naked Values in inner loops...
|
266
|
-
struct QuantileValue {
|
267
|
-
explicit QuantileValue(const Value &v) : val(v), dbl(v.GetValue<double>()) {
|
268
|
-
const auto &type = val.type();
|
269
|
-
switch (type.id()) {
|
270
|
-
case LogicalTypeId::DECIMAL: {
|
271
|
-
integral = IntegralValue::Get(v);
|
272
|
-
scaling = Hugeint::POWERS_OF_TEN[DecimalType::GetScale(type)];
|
273
|
-
break;
|
274
|
-
}
|
275
|
-
default:
|
276
|
-
break;
|
277
|
-
}
|
278
|
-
}
|
279
|
-
|
280
|
-
Value val;
|
281
|
-
|
282
|
-
// DOUBLE
|
283
|
-
double dbl;
|
284
|
-
|
285
|
-
// DECIMAL
|
286
|
-
hugeint_t integral;
|
287
|
-
hugeint_t scaling;
|
288
|
-
};
|
289
|
-
|
290
|
-
bool operator==(const QuantileValue &x, const QuantileValue &y) {
|
291
|
-
return x.val == y.val;
|
292
|
-
}
|
293
|
-
|
294
|
-
// Continuous interpolation
|
295
|
-
template <bool DISCRETE>
|
296
|
-
struct Interpolator {
|
297
|
-
Interpolator(const QuantileValue &q, const idx_t n_p, const bool desc_p)
|
298
|
-
: desc(desc_p), RN((double)(n_p - 1) * q.dbl), FRN(UnsafeNumericCast<idx_t>(floor(RN))),
|
299
|
-
CRN(UnsafeNumericCast<idx_t>(ceil(RN))), begin(0), end(n_p) {
|
300
|
-
}
|
301
|
-
|
302
|
-
template <class INPUT_TYPE, class TARGET_TYPE, typename ACCESSOR = QuantileDirect<INPUT_TYPE>>
|
303
|
-
TARGET_TYPE Interpolate(INPUT_TYPE lidx, INPUT_TYPE hidx, Vector &result, const ACCESSOR &accessor) const {
|
304
|
-
using ACCESS_TYPE = typename ACCESSOR::RESULT_TYPE;
|
305
|
-
if (lidx == hidx) {
|
306
|
-
return CastInterpolation::Cast<ACCESS_TYPE, TARGET_TYPE>(accessor(lidx), result);
|
307
|
-
} else {
|
308
|
-
auto lo = CastInterpolation::Cast<ACCESS_TYPE, TARGET_TYPE>(accessor(lidx), result);
|
309
|
-
auto hi = CastInterpolation::Cast<ACCESS_TYPE, TARGET_TYPE>(accessor(hidx), result);
|
310
|
-
return CastInterpolation::Interpolate<TARGET_TYPE>(lo, RN - FRN, hi);
|
311
|
-
}
|
312
|
-
}
|
313
|
-
|
314
|
-
template <class INPUT_TYPE, class TARGET_TYPE, typename ACCESSOR = QuantileDirect<INPUT_TYPE>>
|
315
|
-
TARGET_TYPE Operation(INPUT_TYPE *v_t, Vector &result, const ACCESSOR &accessor = ACCESSOR()) const {
|
316
|
-
using ACCESS_TYPE = typename ACCESSOR::RESULT_TYPE;
|
317
|
-
QuantileCompare<ACCESSOR> comp(accessor, desc);
|
318
|
-
if (CRN == FRN) {
|
319
|
-
std::nth_element(v_t + begin, v_t + FRN, v_t + end, comp);
|
320
|
-
return CastInterpolation::Cast<ACCESS_TYPE, TARGET_TYPE>(accessor(v_t[FRN]), result);
|
321
|
-
} else {
|
322
|
-
std::nth_element(v_t + begin, v_t + FRN, v_t + end, comp);
|
323
|
-
std::nth_element(v_t + FRN, v_t + CRN, v_t + end, comp);
|
324
|
-
auto lo = CastInterpolation::Cast<ACCESS_TYPE, TARGET_TYPE>(accessor(v_t[FRN]), result);
|
325
|
-
auto hi = CastInterpolation::Cast<ACCESS_TYPE, TARGET_TYPE>(accessor(v_t[CRN]), result);
|
326
|
-
return CastInterpolation::Interpolate<TARGET_TYPE>(lo, RN - FRN, hi);
|
327
|
-
}
|
328
|
-
}
|
329
|
-
|
330
|
-
template <class INPUT_TYPE, class TARGET_TYPE>
|
331
|
-
inline TARGET_TYPE Extract(const INPUT_TYPE **dest, Vector &result) const {
|
332
|
-
if (CRN == FRN) {
|
333
|
-
return CastInterpolation::Cast<INPUT_TYPE, TARGET_TYPE>(*dest[0], result);
|
334
|
-
} else {
|
335
|
-
auto lo = CastInterpolation::Cast<INPUT_TYPE, TARGET_TYPE>(*dest[0], result);
|
336
|
-
auto hi = CastInterpolation::Cast<INPUT_TYPE, TARGET_TYPE>(*dest[1], result);
|
337
|
-
return CastInterpolation::Interpolate<TARGET_TYPE>(lo, RN - FRN, hi);
|
338
|
-
}
|
339
|
-
}
|
340
|
-
|
341
|
-
const bool desc;
|
342
|
-
const double RN;
|
343
|
-
const idx_t FRN;
|
344
|
-
const idx_t CRN;
|
345
|
-
|
346
|
-
idx_t begin;
|
347
|
-
idx_t end;
|
348
|
-
};
|
349
|
-
|
350
|
-
// Discrete "interpolation"
|
351
|
-
template <>
|
352
|
-
struct Interpolator<true> {
|
353
|
-
static inline idx_t Index(const QuantileValue &q, const idx_t n) {
|
354
|
-
idx_t floored;
|
355
|
-
switch (q.val.type().id()) {
|
356
|
-
case LogicalTypeId::DECIMAL: {
|
357
|
-
// Integer arithmetic for accuracy
|
358
|
-
const auto integral = q.integral;
|
359
|
-
const auto scaling = q.scaling;
|
360
|
-
const auto scaled_q =
|
361
|
-
DecimalMultiplyOverflowCheck::Operation<hugeint_t, hugeint_t, hugeint_t>(Hugeint::Convert(n), integral);
|
362
|
-
const auto scaled_n =
|
363
|
-
DecimalMultiplyOverflowCheck::Operation<hugeint_t, hugeint_t, hugeint_t>(Hugeint::Convert(n), scaling);
|
364
|
-
floored = Cast::Operation<hugeint_t, idx_t>((scaled_n - scaled_q) / scaling);
|
365
|
-
break;
|
366
|
-
}
|
367
|
-
default:
|
368
|
-
const auto scaled_q = (double)(n * q.dbl);
|
369
|
-
floored = UnsafeNumericCast<idx_t>(floor(n - scaled_q));
|
370
|
-
break;
|
371
|
-
}
|
372
|
-
|
373
|
-
return MaxValue<idx_t>(1, n - floored) - 1;
|
374
|
-
}
|
375
|
-
|
376
|
-
Interpolator(const QuantileValue &q, const idx_t n_p, bool desc_p)
|
377
|
-
: desc(desc_p), FRN(Index(q, n_p)), CRN(FRN), begin(0), end(n_p) {
|
378
|
-
}
|
379
|
-
|
380
|
-
template <class INPUT_TYPE, class TARGET_TYPE, typename ACCESSOR = QuantileDirect<INPUT_TYPE>>
|
381
|
-
TARGET_TYPE Interpolate(INPUT_TYPE lidx, INPUT_TYPE hidx, Vector &result, const ACCESSOR &accessor) const {
|
382
|
-
using ACCESS_TYPE = typename ACCESSOR::RESULT_TYPE;
|
383
|
-
return CastInterpolation::Cast<ACCESS_TYPE, TARGET_TYPE>(accessor(lidx), result);
|
384
|
-
}
|
385
|
-
|
386
|
-
template <class INPUT_TYPE, class TARGET_TYPE, typename ACCESSOR = QuantileDirect<INPUT_TYPE>>
|
387
|
-
TARGET_TYPE Operation(INPUT_TYPE *v_t, Vector &result, const ACCESSOR &accessor = ACCESSOR()) const {
|
388
|
-
using ACCESS_TYPE = typename ACCESSOR::RESULT_TYPE;
|
389
|
-
QuantileCompare<ACCESSOR> comp(accessor, desc);
|
390
|
-
std::nth_element(v_t + begin, v_t + FRN, v_t + end, comp);
|
391
|
-
return CastInterpolation::Cast<ACCESS_TYPE, TARGET_TYPE>(accessor(v_t[FRN]), result);
|
392
|
-
}
|
393
|
-
|
394
|
-
template <class INPUT_TYPE, class TARGET_TYPE>
|
395
|
-
TARGET_TYPE Extract(const INPUT_TYPE **dest, Vector &result) const {
|
396
|
-
return CastInterpolation::Cast<INPUT_TYPE, TARGET_TYPE>(*dest[0], result);
|
397
|
-
}
|
398
|
-
|
399
|
-
const bool desc;
|
400
|
-
const idx_t FRN;
|
401
|
-
const idx_t CRN;
|
402
|
-
|
403
|
-
idx_t begin;
|
404
|
-
idx_t end;
|
405
|
-
};
|
406
|
-
|
407
28
|
template <typename T>
|
408
29
|
static inline T QuantileAbs(const T &t) {
|
409
30
|
return AbsOperator::Operation<T, T>(t);
|
@@ -435,1052 +56,511 @@ inline Value QuantileAbs(const Value &v) {
|
|
435
56
|
}
|
436
57
|
}
|
437
58
|
|
438
|
-
|
59
|
+
//===--------------------------------------------------------------------===//
|
60
|
+
// Quantile Bind Data
|
61
|
+
//===--------------------------------------------------------------------===//
|
62
|
+
QuantileBindData::QuantileBindData() {
|
63
|
+
}
|
439
64
|
|
440
|
-
|
441
|
-
|
442
|
-
|
65
|
+
QuantileBindData::QuantileBindData(const Value &quantile_p)
|
66
|
+
: quantiles(1, QuantileValue(QuantileAbs(quantile_p))), order(1, 0), desc(quantile_p < 0) {
|
67
|
+
}
|
443
68
|
|
444
|
-
|
445
|
-
|
69
|
+
QuantileBindData::QuantileBindData(const vector<Value> &quantiles_p) {
|
70
|
+
vector<Value> normalised;
|
71
|
+
size_t pos = 0;
|
72
|
+
size_t neg = 0;
|
73
|
+
for (idx_t i = 0; i < quantiles_p.size(); ++i) {
|
74
|
+
const auto &q = quantiles_p[i];
|
75
|
+
pos += (q > 0);
|
76
|
+
neg += (q < 0);
|
77
|
+
normalised.emplace_back(QuantileAbs(q));
|
78
|
+
order.push_back(i);
|
446
79
|
}
|
447
|
-
|
448
|
-
|
449
|
-
vector<Value> normalised;
|
450
|
-
size_t pos = 0;
|
451
|
-
size_t neg = 0;
|
452
|
-
for (idx_t i = 0; i < quantiles_p.size(); ++i) {
|
453
|
-
const auto &q = quantiles_p[i];
|
454
|
-
pos += (q > 0);
|
455
|
-
neg += (q < 0);
|
456
|
-
normalised.emplace_back(QuantileAbs(q));
|
457
|
-
order.push_back(i);
|
458
|
-
}
|
459
|
-
if (pos && neg) {
|
460
|
-
throw BinderException("QUANTILE parameters must have consistent signs");
|
461
|
-
}
|
462
|
-
desc = (neg > 0);
|
463
|
-
|
464
|
-
IndirectLess<Value> lt(normalised.data());
|
465
|
-
std::sort(order.begin(), order.end(), lt);
|
466
|
-
|
467
|
-
for (const auto &q : normalised) {
|
468
|
-
quantiles.emplace_back(QuantileValue(q));
|
469
|
-
}
|
80
|
+
if (pos && neg) {
|
81
|
+
throw BinderException("QUANTILE parameters must have consistent signs");
|
470
82
|
}
|
83
|
+
desc = (neg > 0);
|
471
84
|
|
472
|
-
|
473
|
-
|
474
|
-
quantiles.emplace_back(q);
|
475
|
-
}
|
476
|
-
}
|
85
|
+
IndirectLess<Value> lt(normalised.data());
|
86
|
+
std::sort(order.begin(), order.end(), lt);
|
477
87
|
|
478
|
-
|
479
|
-
|
88
|
+
for (const auto &q : normalised) {
|
89
|
+
quantiles.emplace_back(QuantileValue(q));
|
480
90
|
}
|
91
|
+
}
|
481
92
|
|
482
|
-
|
483
|
-
|
484
|
-
|
93
|
+
QuantileBindData::QuantileBindData(const QuantileBindData &other) : order(other.order), desc(other.desc) {
|
94
|
+
for (const auto &q : other.quantiles) {
|
95
|
+
quantiles.emplace_back(q);
|
485
96
|
}
|
97
|
+
}
|
486
98
|
|
487
|
-
|
488
|
-
|
489
|
-
|
490
|
-
vector<Value> raw;
|
491
|
-
for (const auto &q : bind_data.quantiles) {
|
492
|
-
raw.emplace_back(q.val);
|
493
|
-
}
|
494
|
-
serializer.WriteProperty(100, "quantiles", raw);
|
495
|
-
serializer.WriteProperty(101, "order", bind_data.order);
|
496
|
-
serializer.WriteProperty(102, "desc", bind_data.desc);
|
497
|
-
}
|
99
|
+
unique_ptr<FunctionData> QuantileBindData::Copy() const {
|
100
|
+
return make_uniq<QuantileBindData>(*this);
|
101
|
+
}
|
498
102
|
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
deserializer.ReadProperty(101, "order", result->order);
|
504
|
-
deserializer.ReadProperty(102, "desc", result->desc);
|
505
|
-
QuantileSerializationType deserialization_type;
|
506
|
-
deserializer.ReadPropertyWithDefault(103, "quantile_type", deserialization_type,
|
507
|
-
QuantileSerializationType::NON_DECIMAL);
|
508
|
-
|
509
|
-
if (deserialization_type != QuantileSerializationType::NON_DECIMAL) {
|
510
|
-
LogicalType arg_type;
|
511
|
-
deserializer.ReadProperty(104, "logical_type", arg_type);
|
512
|
-
|
513
|
-
BindQuantileInner(function, arg_type, deserialization_type);
|
514
|
-
}
|
103
|
+
bool QuantileBindData::Equals(const FunctionData &other_p) const {
|
104
|
+
auto &other = other_p.Cast<QuantileBindData>();
|
105
|
+
return desc == other.desc && quantiles == other.quantiles && order == other.order;
|
106
|
+
}
|
515
107
|
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
108
|
+
void QuantileBindData::Serialize(Serializer &serializer, const optional_ptr<FunctionData> bind_data_p,
|
109
|
+
const AggregateFunction &function) {
|
110
|
+
auto &bind_data = bind_data_p->Cast<QuantileBindData>();
|
111
|
+
vector<Value> raw;
|
112
|
+
for (const auto &q : bind_data.quantiles) {
|
113
|
+
raw.emplace_back(q.val);
|
520
114
|
}
|
115
|
+
serializer.WriteProperty(100, "quantiles", raw);
|
116
|
+
serializer.WriteProperty(101, "order", bind_data.order);
|
117
|
+
serializer.WriteProperty(102, "desc", bind_data.desc);
|
118
|
+
}
|
521
119
|
|
522
|
-
|
523
|
-
|
524
|
-
|
120
|
+
unique_ptr<FunctionData> QuantileBindData::Deserialize(Deserializer &deserializer, AggregateFunction &function) {
|
121
|
+
auto result = make_uniq<QuantileBindData>();
|
122
|
+
vector<Value> raw;
|
123
|
+
deserializer.ReadProperty(100, "quantiles", raw);
|
124
|
+
deserializer.ReadProperty(101, "order", result->order);
|
125
|
+
deserializer.ReadProperty(102, "desc", result->desc);
|
126
|
+
QuantileSerializationType deserialization_type;
|
127
|
+
deserializer.ReadPropertyWithExplicitDefault(103, "quantile_type", deserialization_type,
|
128
|
+
QuantileSerializationType::NON_DECIMAL);
|
525
129
|
|
526
|
-
|
527
|
-
|
528
|
-
serializer.WriteProperty(104, "logical_type", function.arguments[0]);
|
130
|
+
if (deserialization_type != QuantileSerializationType::NON_DECIMAL) {
|
131
|
+
deserializer.ReadDeletedProperty<LogicalType>(104, "logical_type");
|
529
132
|
}
|
530
|
-
static void SerializeDecimalDiscreteList(Serializer &serializer, const optional_ptr<FunctionData> bind_data_p,
|
531
|
-
const AggregateFunction &function) {
|
532
|
-
|
533
|
-
Serialize(serializer, bind_data_p, function);
|
534
133
|
|
535
|
-
|
536
|
-
|
537
|
-
QuantileSerializationType::NON_DECIMAL);
|
538
|
-
serializer.WriteProperty(104, "logical_type", function.arguments[0]);
|
134
|
+
for (const auto &r : raw) {
|
135
|
+
result->quantiles.emplace_back(QuantileValue(r));
|
539
136
|
}
|
540
|
-
|
541
|
-
|
542
|
-
Serialize(serializer, bind_data_p, function);
|
543
|
-
|
544
|
-
serializer.WritePropertyWithDefault<QuantileSerializationType>(103, "quantile_type",
|
545
|
-
QuantileSerializationType::DECIMAL_CONTINUOUS,
|
546
|
-
QuantileSerializationType::NON_DECIMAL);
|
547
|
-
serializer.WriteProperty(104, "logical_type", function.arguments[0]);
|
548
|
-
}
|
549
|
-
static void SerializeDecimalContinuousList(Serializer &serializer, const optional_ptr<FunctionData> bind_data_p,
|
550
|
-
const AggregateFunction &function) {
|
137
|
+
return std::move(result);
|
138
|
+
}
|
551
139
|
|
552
|
-
|
140
|
+
//===--------------------------------------------------------------------===//
|
141
|
+
// Cast Interpolation
|
142
|
+
//===--------------------------------------------------------------------===//
|
143
|
+
template <>
|
144
|
+
interval_t CastInterpolation::Cast(const dtime_t &src, Vector &result) {
|
145
|
+
return {0, 0, src.micros};
|
146
|
+
}
|
553
147
|
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
}
|
148
|
+
template <>
|
149
|
+
double CastInterpolation::Interpolate(const double &lo, const double d, const double &hi) {
|
150
|
+
return lo * (1.0 - d) + hi * d;
|
151
|
+
}
|
559
152
|
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
}
|
153
|
+
template <>
|
154
|
+
dtime_t CastInterpolation::Interpolate(const dtime_t &lo, const double d, const dtime_t &hi) {
|
155
|
+
return dtime_t(std::llround(static_cast<double>(lo.micros) * (1.0 - d) + static_cast<double>(hi.micros) * d));
|
156
|
+
}
|
564
157
|
|
565
|
-
template
|
566
|
-
|
158
|
+
template <>
|
159
|
+
timestamp_t CastInterpolation::Interpolate(const timestamp_t &lo, const double d, const timestamp_t &hi) {
|
160
|
+
return timestamp_t(std::llround(static_cast<double>(lo.value) * (1.0 - d) + static_cast<double>(hi.value) * d));
|
161
|
+
}
|
567
162
|
|
568
|
-
|
569
|
-
|
163
|
+
template <>
|
164
|
+
hugeint_t CastInterpolation::Interpolate(const hugeint_t &lo, const double d, const hugeint_t &hi) {
|
165
|
+
return Hugeint::Convert(Interpolate(Hugeint::Cast<double>(lo), d, Hugeint::Cast<double>(hi)));
|
166
|
+
}
|
570
167
|
|
571
|
-
|
572
|
-
|
168
|
+
static interval_t MultiplyByDouble(const interval_t &i, const double &d) { // NOLINT
|
169
|
+
D_ASSERT(d >= 0 && d <= 1);
|
170
|
+
return Interval::FromMicro(std::llround(static_cast<double>(Interval::GetMicro(i)) * d));
|
171
|
+
}
|
573
172
|
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
idx_t count) {
|
578
|
-
// Build the indirection array
|
579
|
-
using ElementType = typename QuantileSortTree::ElementType;
|
580
|
-
vector<ElementType> sorted(count);
|
581
|
-
if (filter_mask.AllValid() && data_mask.AllValid()) {
|
582
|
-
std::iota(sorted.begin(), sorted.end(), 0);
|
583
|
-
} else {
|
584
|
-
size_t valid = 0;
|
585
|
-
QuantileIncluded included(filter_mask, data_mask);
|
586
|
-
for (ElementType i = 0; i < count; ++i) {
|
587
|
-
if (included(i)) {
|
588
|
-
sorted[valid++] = i;
|
589
|
-
}
|
590
|
-
}
|
591
|
-
sorted.resize(valid);
|
592
|
-
}
|
173
|
+
inline interval_t operator+(const interval_t &lhs, const interval_t &rhs) {
|
174
|
+
return Interval::FromMicro(Interval::GetMicro(lhs) + Interval::GetMicro(rhs));
|
175
|
+
}
|
593
176
|
|
594
|
-
|
595
|
-
|
596
|
-
|
597
|
-
Accessor indirect(data);
|
598
|
-
QuantileCompare<Accessor> cmp(indirect, bind_data.desc);
|
599
|
-
std::sort(sorted.begin(), sorted.end(), cmp);
|
177
|
+
inline interval_t operator-(const interval_t &lhs, const interval_t &rhs) {
|
178
|
+
return Interval::FromMicro(Interval::GetMicro(lhs) - Interval::GetMicro(rhs));
|
179
|
+
}
|
600
180
|
|
601
|
-
|
602
|
-
|
181
|
+
template <>
|
182
|
+
interval_t CastInterpolation::Interpolate(const interval_t &lo, const double d, const interval_t &hi) {
|
183
|
+
const interval_t delta = hi - lo;
|
184
|
+
return lo + MultiplyByDouble(delta, d);
|
185
|
+
}
|
603
186
|
|
604
|
-
|
605
|
-
|
606
|
-
|
187
|
+
template <>
|
188
|
+
string_t CastInterpolation::Cast(const string_t &src, Vector &result) {
|
189
|
+
return StringVector::AddStringOrBlob(result, src);
|
190
|
+
}
|
607
191
|
|
608
|
-
|
609
|
-
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
hi_data = SelectNth(frames, interp.CRN);
|
192
|
+
//===--------------------------------------------------------------------===//
|
193
|
+
// Scalar Quantile
|
194
|
+
//===--------------------------------------------------------------------===//
|
195
|
+
template <bool DISCRETE, class TYPE_OP = QuantileStandardType>
|
196
|
+
struct QuantileScalarOperation : public QuantileOperation {
|
197
|
+
template <class T, class STATE>
|
198
|
+
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
199
|
+
if (state.v.empty()) {
|
200
|
+
finalize_data.ReturnNull();
|
201
|
+
return;
|
619
202
|
}
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
203
|
+
D_ASSERT(finalize_data.input.bind_data);
|
204
|
+
auto &bind_data = finalize_data.input.bind_data->Cast<QuantileBindData>();
|
205
|
+
D_ASSERT(bind_data.quantiles.size() == 1);
|
206
|
+
Interpolator<DISCRETE> interp(bind_data.quantiles[0], state.v.size(), bind_data.desc);
|
207
|
+
target = interp.template Operation<typename STATE::InputType, T>(state.v.data(), finalize_data.result);
|
625
208
|
}
|
626
209
|
|
627
|
-
template <
|
628
|
-
void
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
auto ldata = FlatVector::GetData<list_entry_t>(list);
|
634
|
-
auto &lentry = ldata[lidx];
|
635
|
-
lentry.offset = ListVector::GetListSize(list);
|
636
|
-
lentry.length = bind_data.quantiles.size();
|
637
|
-
|
638
|
-
ListVector::Reserve(list, lentry.offset + lentry.length);
|
639
|
-
ListVector::SetListSize(list, lentry.offset + lentry.length);
|
640
|
-
auto &result = ListVector::GetEntry(list);
|
641
|
-
auto rdata = FlatVector::GetData<CHILD_TYPE>(result);
|
642
|
-
|
643
|
-
using ID = QuantileIndirect<INPUT_TYPE>;
|
644
|
-
ID indirect(data);
|
645
|
-
for (const auto &q : bind_data.order) {
|
646
|
-
const auto &quantile = bind_data.quantiles[q];
|
647
|
-
Interpolator<DISCRETE> interp(quantile, n, false);
|
648
|
-
|
649
|
-
const auto lo_data = SelectNth(frames, interp.FRN);
|
650
|
-
auto hi_data = lo_data;
|
651
|
-
if (interp.CRN != interp.FRN) {
|
652
|
-
hi_data = SelectNth(frames, interp.CRN);
|
653
|
-
}
|
654
|
-
|
655
|
-
// Interpolate indirectly
|
656
|
-
rdata[lentry.offset + q] =
|
657
|
-
interp.template Interpolate<idx_t, CHILD_TYPE, ID>(lo_data, hi_data, result, indirect);
|
658
|
-
}
|
659
|
-
}
|
660
|
-
};
|
661
|
-
|
662
|
-
template <class T>
|
663
|
-
struct PointerLess {
|
664
|
-
inline bool operator()(const T &lhi, const T &rhi) const {
|
665
|
-
return *lhi < *rhi;
|
666
|
-
}
|
667
|
-
};
|
668
|
-
|
669
|
-
template <typename INPUT_TYPE, typename SAVE_TYPE>
|
670
|
-
struct QuantileState {
|
671
|
-
using SaveType = SAVE_TYPE;
|
672
|
-
using InputType = INPUT_TYPE;
|
673
|
-
|
674
|
-
// Regular aggregation
|
675
|
-
vector<SaveType> v;
|
676
|
-
|
677
|
-
// Windowed Quantile merge sort trees
|
678
|
-
using QuantileSortTree32 = QuantileSortTree<uint32_t>;
|
679
|
-
using QuantileSortTree64 = QuantileSortTree<uint64_t>;
|
680
|
-
unique_ptr<QuantileSortTree32> qst32;
|
681
|
-
unique_ptr<QuantileSortTree64> qst64;
|
682
|
-
|
683
|
-
// Windowed Quantile skip lists
|
684
|
-
using PointerType = const InputType *;
|
685
|
-
using SkipListType = duckdb_skiplistlib::skip_list::HeadNode<PointerType, PointerLess<PointerType>>;
|
686
|
-
SubFrames prevs;
|
687
|
-
unique_ptr<SkipListType> s;
|
688
|
-
mutable vector<PointerType> dest;
|
689
|
-
|
690
|
-
// Windowed MAD indirection
|
691
|
-
idx_t count;
|
692
|
-
vector<idx_t> m;
|
693
|
-
|
694
|
-
QuantileState() : count(0) {
|
695
|
-
}
|
696
|
-
|
697
|
-
~QuantileState() {
|
698
|
-
}
|
699
|
-
|
700
|
-
inline void SetCount(size_t count_p) {
|
701
|
-
count = count_p;
|
702
|
-
if (count >= m.size()) {
|
703
|
-
m.resize(count);
|
704
|
-
}
|
705
|
-
}
|
706
|
-
|
707
|
-
inline SkipListType &GetSkipList(bool reset = false) {
|
708
|
-
if (reset || !s) {
|
709
|
-
s.reset();
|
710
|
-
s = make_uniq<SkipListType>();
|
711
|
-
}
|
712
|
-
return *s;
|
713
|
-
}
|
714
|
-
|
715
|
-
struct SkipListUpdater {
|
716
|
-
SkipListType &skip;
|
717
|
-
const INPUT_TYPE *data;
|
718
|
-
const QuantileIncluded &included;
|
719
|
-
|
720
|
-
inline SkipListUpdater(SkipListType &skip, const INPUT_TYPE *data, const QuantileIncluded &included)
|
721
|
-
: skip(skip), data(data), included(included) {
|
722
|
-
}
|
723
|
-
|
724
|
-
inline void Neither(idx_t begin, idx_t end) {
|
725
|
-
}
|
726
|
-
|
727
|
-
inline void Left(idx_t begin, idx_t end) {
|
728
|
-
for (; begin < end; ++begin) {
|
729
|
-
if (included(begin)) {
|
730
|
-
skip.remove(data + begin);
|
731
|
-
}
|
732
|
-
}
|
733
|
-
}
|
734
|
-
|
735
|
-
inline void Right(idx_t begin, idx_t end) {
|
736
|
-
for (; begin < end; ++begin) {
|
737
|
-
if (included(begin)) {
|
738
|
-
skip.insert(data + begin);
|
739
|
-
}
|
740
|
-
}
|
741
|
-
}
|
742
|
-
|
743
|
-
inline void Both(idx_t begin, idx_t end) {
|
744
|
-
}
|
745
|
-
};
|
746
|
-
|
747
|
-
void UpdateSkip(const INPUT_TYPE *data, const SubFrames &frames, const QuantileIncluded &included) {
|
748
|
-
// No overlap, or no data
|
749
|
-
if (!s || prevs.back().end <= frames.front().start || frames.back().end <= prevs.front().start) {
|
750
|
-
auto &skip = GetSkipList(true);
|
751
|
-
for (const auto &frame : frames) {
|
752
|
-
for (auto i = frame.start; i < frame.end; ++i) {
|
753
|
-
if (included(i)) {
|
754
|
-
skip.insert(data + i);
|
755
|
-
}
|
756
|
-
}
|
757
|
-
}
|
758
|
-
} else {
|
759
|
-
auto &skip = GetSkipList();
|
760
|
-
SkipListUpdater updater(skip, data, included);
|
761
|
-
AggregateExecutor::IntersectFrames(prevs, frames, updater);
|
762
|
-
}
|
763
|
-
}
|
764
|
-
|
765
|
-
bool HasTrees() const {
|
766
|
-
return qst32 || qst64;
|
767
|
-
}
|
768
|
-
|
769
|
-
template <typename RESULT_TYPE, bool DISCRETE>
|
770
|
-
RESULT_TYPE WindowScalar(const INPUT_TYPE *data, const SubFrames &frames, const idx_t n, Vector &result,
|
771
|
-
const QuantileValue &q) const {
|
772
|
-
D_ASSERT(n > 0);
|
773
|
-
if (qst32) {
|
774
|
-
return qst32->WindowScalar<INPUT_TYPE, RESULT_TYPE, DISCRETE>(data, frames, n, result, q);
|
775
|
-
} else if (qst64) {
|
776
|
-
return qst64->WindowScalar<INPUT_TYPE, RESULT_TYPE, DISCRETE>(data, frames, n, result, q);
|
777
|
-
} else if (s) {
|
778
|
-
// Find the position(s) needed
|
779
|
-
try {
|
780
|
-
Interpolator<DISCRETE> interp(q, s->size(), false);
|
781
|
-
s->at(interp.FRN, interp.CRN - interp.FRN + 1, dest);
|
782
|
-
return interp.template Extract<INPUT_TYPE, RESULT_TYPE>(dest.data(), result);
|
783
|
-
} catch (const duckdb_skiplistlib::skip_list::IndexError &idx_err) {
|
784
|
-
throw InternalException(idx_err.message());
|
785
|
-
}
|
786
|
-
} else {
|
787
|
-
throw InternalException("No accelerator for scalar QUANTILE");
|
788
|
-
}
|
789
|
-
}
|
790
|
-
|
791
|
-
template <typename CHILD_TYPE, bool DISCRETE>
|
792
|
-
void WindowList(const INPUT_TYPE *data, const SubFrames &frames, const idx_t n, Vector &list, const idx_t lidx,
|
793
|
-
const QuantileBindData &bind_data) const {
|
794
|
-
D_ASSERT(n > 0);
|
795
|
-
// Result is a constant LIST<CHILD_TYPE> with a fixed length
|
796
|
-
auto ldata = FlatVector::GetData<list_entry_t>(list);
|
797
|
-
auto &lentry = ldata[lidx];
|
798
|
-
lentry.offset = ListVector::GetListSize(list);
|
799
|
-
lentry.length = bind_data.quantiles.size();
|
800
|
-
|
801
|
-
ListVector::Reserve(list, lentry.offset + lentry.length);
|
802
|
-
ListVector::SetListSize(list, lentry.offset + lentry.length);
|
803
|
-
auto &result = ListVector::GetEntry(list);
|
804
|
-
auto rdata = FlatVector::GetData<CHILD_TYPE>(result);
|
805
|
-
|
806
|
-
for (const auto &q : bind_data.order) {
|
807
|
-
const auto &quantile = bind_data.quantiles[q];
|
808
|
-
rdata[lentry.offset + q] = WindowScalar<CHILD_TYPE, DISCRETE>(data, frames, n, result, quantile);
|
809
|
-
}
|
810
|
-
}
|
811
|
-
};
|
812
|
-
|
813
|
-
struct QuantileOperation {
|
814
|
-
template <class STATE>
|
815
|
-
static void Initialize(STATE &state) {
|
816
|
-
new (&state) STATE();
|
817
|
-
}
|
818
|
-
|
819
|
-
template <class INPUT_TYPE, class STATE, class OP>
|
820
|
-
static void ConstantOperation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &unary_input,
|
821
|
-
idx_t count) {
|
822
|
-
for (idx_t i = 0; i < count; i++) {
|
823
|
-
Operation<INPUT_TYPE, STATE, OP>(state, input, unary_input);
|
824
|
-
}
|
825
|
-
}
|
826
|
-
|
827
|
-
template <class INPUT_TYPE, class STATE, class OP>
|
828
|
-
static void Operation(STATE &state, const INPUT_TYPE &input, AggregateUnaryInput &) {
|
829
|
-
state.v.emplace_back(input);
|
830
|
-
}
|
831
|
-
|
832
|
-
template <class STATE, class OP>
|
833
|
-
static void Combine(const STATE &source, STATE &target, AggregateInputData &) {
|
834
|
-
if (source.v.empty()) {
|
835
|
-
return;
|
836
|
-
}
|
837
|
-
target.v.insert(target.v.end(), source.v.begin(), source.v.end());
|
838
|
-
}
|
839
|
-
|
840
|
-
template <class STATE>
|
841
|
-
static void Destroy(STATE &state, AggregateInputData &aggr_input_data) {
|
842
|
-
state.~STATE();
|
843
|
-
}
|
844
|
-
|
845
|
-
static bool IgnoreNull() {
|
846
|
-
return true;
|
847
|
-
}
|
848
|
-
|
849
|
-
template <class STATE, class INPUT_TYPE>
|
850
|
-
static void WindowInit(AggregateInputData &aggr_input_data, const WindowPartitionInput &partition,
|
851
|
-
data_ptr_t g_state) {
|
852
|
-
D_ASSERT(partition.input_count == 1);
|
853
|
-
|
854
|
-
auto inputs = partition.inputs;
|
855
|
-
const auto count = partition.count;
|
856
|
-
const auto &filter_mask = partition.filter_mask;
|
857
|
-
const auto &stats = partition.stats;
|
858
|
-
|
859
|
-
// If frames overlap significantly, then use local skip lists.
|
860
|
-
if (stats[0].end <= stats[1].begin) {
|
861
|
-
// Frames can overlap
|
862
|
-
const auto overlap = double(stats[1].begin - stats[0].end);
|
863
|
-
const auto cover = double(stats[1].end - stats[0].begin);
|
864
|
-
const auto ratio = overlap / cover;
|
865
|
-
if (ratio > .75) {
|
866
|
-
return;
|
867
|
-
}
|
868
|
-
}
|
869
|
-
|
870
|
-
const auto data = FlatVector::GetData<const INPUT_TYPE>(inputs[0]);
|
871
|
-
const auto &data_mask = FlatVector::Validity(inputs[0]);
|
872
|
-
|
873
|
-
// Build the tree
|
874
|
-
auto &state = *reinterpret_cast<STATE *>(g_state);
|
875
|
-
if (count < std::numeric_limits<uint32_t>::max()) {
|
876
|
-
state.qst32 = QuantileSortTree<uint32_t>::WindowInit<INPUT_TYPE>(data, aggr_input_data, data_mask,
|
877
|
-
filter_mask, count);
|
878
|
-
} else {
|
879
|
-
state.qst64 = QuantileSortTree<uint64_t>::WindowInit<INPUT_TYPE>(data, aggr_input_data, data_mask,
|
880
|
-
filter_mask, count);
|
881
|
-
}
|
882
|
-
}
|
883
|
-
|
884
|
-
static idx_t FrameSize(const QuantileIncluded &included, const SubFrames &frames) {
|
885
|
-
// Count the number of valid values
|
886
|
-
idx_t n = 0;
|
887
|
-
if (included.AllValid()) {
|
888
|
-
for (const auto &frame : frames) {
|
889
|
-
n += frame.end - frame.start;
|
890
|
-
}
|
891
|
-
} else {
|
892
|
-
// NULLs or FILTERed values,
|
893
|
-
for (const auto &frame : frames) {
|
894
|
-
for (auto i = frame.start; i < frame.end; ++i) {
|
895
|
-
n += included(i);
|
896
|
-
}
|
897
|
-
}
|
898
|
-
}
|
899
|
-
|
900
|
-
return n;
|
901
|
-
}
|
902
|
-
};
|
903
|
-
|
904
|
-
template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
|
905
|
-
static AggregateFunction QuantileListAggregate(const LogicalType &input_type, const LogicalType &child_type) { // NOLINT
|
906
|
-
LogicalType result_type =
|
907
|
-
LogicalType::LIST(child_type.id() == LogicalTypeId::ANY ? LogicalType::VARCHAR : child_type);
|
908
|
-
return AggregateFunction(
|
909
|
-
{input_type}, result_type, AggregateFunction::StateSize<STATE>, AggregateFunction::StateInitialize<STATE, OP>,
|
910
|
-
AggregateFunction::UnaryScatterUpdate<STATE, INPUT_TYPE, OP>, AggregateFunction::StateCombine<STATE, OP>,
|
911
|
-
AggregateFunction::StateFinalize<STATE, RESULT_TYPE, OP>, AggregateFunction::UnaryUpdate<STATE, INPUT_TYPE, OP>,
|
912
|
-
nullptr, AggregateFunction::StateDestroy<STATE, OP>);
|
913
|
-
}
|
914
|
-
|
915
|
-
template <bool DISCRETE>
|
916
|
-
struct QuantileScalarOperation : public QuantileOperation {
|
917
|
-
|
918
|
-
template <class T, class STATE>
|
919
|
-
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
920
|
-
if (state.v.empty()) {
|
921
|
-
finalize_data.ReturnNull();
|
922
|
-
return;
|
923
|
-
}
|
924
|
-
D_ASSERT(finalize_data.input.bind_data);
|
925
|
-
auto &bind_data = finalize_data.input.bind_data->Cast<QuantileBindData>();
|
926
|
-
D_ASSERT(bind_data.quantiles.size() == 1);
|
927
|
-
Interpolator<DISCRETE> interp(bind_data.quantiles[0], state.v.size(), bind_data.desc);
|
928
|
-
target = interp.template Operation<typename STATE::SaveType, T>(state.v.data(), finalize_data.result);
|
929
|
-
}
|
930
|
-
|
931
|
-
template <class STATE, class INPUT_TYPE, class RESULT_TYPE>
|
932
|
-
static void Window(const INPUT_TYPE *data, const ValidityMask &fmask, const ValidityMask &dmask,
|
933
|
-
AggregateInputData &aggr_input_data, STATE &state, const SubFrames &frames, Vector &result,
|
934
|
-
idx_t ridx, const STATE *gstate) {
|
935
|
-
QuantileIncluded included(fmask, dmask);
|
936
|
-
const auto n = FrameSize(included, frames);
|
210
|
+
template <class STATE, class INPUT_TYPE, class RESULT_TYPE>
|
211
|
+
static void Window(const INPUT_TYPE *data, const ValidityMask &fmask, const ValidityMask &dmask,
|
212
|
+
AggregateInputData &aggr_input_data, STATE &state, const SubFrames &frames, Vector &result,
|
213
|
+
idx_t ridx, const STATE *gstate) {
|
214
|
+
QuantileIncluded included(fmask, dmask);
|
215
|
+
const auto n = FrameSize(included, frames);
|
937
216
|
|
938
217
|
D_ASSERT(aggr_input_data.bind_data);
|
939
|
-
auto &bind_data = aggr_input_data.bind_data->Cast<QuantileBindData>();
|
940
|
-
|
941
|
-
auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
|
942
|
-
auto &rmask = FlatVector::Validity(result);
|
943
|
-
|
944
|
-
if (!n) {
|
945
|
-
rmask.Set(ridx, false);
|
946
|
-
return;
|
947
|
-
}
|
948
|
-
|
949
|
-
const auto &quantile = bind_data.quantiles[0];
|
950
|
-
if (gstate && gstate->HasTrees()) {
|
951
|
-
rdata[ridx] = gstate->template WindowScalar<RESULT_TYPE, DISCRETE>(data, frames, n, result, quantile);
|
952
|
-
} else {
|
953
|
-
// Update the skip list
|
954
|
-
state.UpdateSkip(data, frames, included);
|
955
|
-
|
956
|
-
// Find the position(s) needed
|
957
|
-
rdata[ridx] = state.template WindowScalar<RESULT_TYPE, DISCRETE>(data, frames, n, result, quantile);
|
958
|
-
|
959
|
-
// Save the previous state for next time
|
960
|
-
state.prevs = frames;
|
961
|
-
}
|
962
|
-
}
|
963
|
-
};
|
964
|
-
|
965
|
-
template <typename INPUT_TYPE, typename SAVED_TYPE>
|
966
|
-
AggregateFunction GetTypedDiscreteQuantileAggregateFunction(const LogicalType &type) {
|
967
|
-
using STATE = QuantileState<INPUT_TYPE, SAVED_TYPE>;
|
968
|
-
using OP = QuantileScalarOperation<true>;
|
969
|
-
auto return_type = type.id() == LogicalTypeId::ANY ? LogicalType::VARCHAR : type;
|
970
|
-
auto fun = AggregateFunction::UnaryAggregateDestructor<STATE, INPUT_TYPE, INPUT_TYPE, OP>(type, return_type);
|
971
|
-
fun.window = AggregateFunction::UnaryWindow<STATE, INPUT_TYPE, INPUT_TYPE, OP>;
|
972
|
-
fun.window_init = OP::WindowInit<STATE, INPUT_TYPE>;
|
973
|
-
return fun;
|
974
|
-
}
|
975
|
-
|
976
|
-
AggregateFunction GetDiscreteQuantileAggregateFunction(const LogicalType &type) {
|
977
|
-
switch (type.id()) {
|
978
|
-
case LogicalTypeId::TINYINT:
|
979
|
-
return GetTypedDiscreteQuantileAggregateFunction<int8_t, int8_t>(type);
|
980
|
-
case LogicalTypeId::SMALLINT:
|
981
|
-
return GetTypedDiscreteQuantileAggregateFunction<int16_t, int16_t>(type);
|
982
|
-
case LogicalTypeId::INTEGER:
|
983
|
-
return GetTypedDiscreteQuantileAggregateFunction<int32_t, int32_t>(type);
|
984
|
-
case LogicalTypeId::BIGINT:
|
985
|
-
return GetTypedDiscreteQuantileAggregateFunction<int64_t, int64_t>(type);
|
986
|
-
case LogicalTypeId::HUGEINT:
|
987
|
-
return GetTypedDiscreteQuantileAggregateFunction<hugeint_t, hugeint_t>(type);
|
988
|
-
case LogicalTypeId::FLOAT:
|
989
|
-
return GetTypedDiscreteQuantileAggregateFunction<float, float>(type);
|
990
|
-
case LogicalTypeId::DOUBLE:
|
991
|
-
return GetTypedDiscreteQuantileAggregateFunction<double, double>(type);
|
992
|
-
case LogicalTypeId::DECIMAL:
|
993
|
-
switch (type.InternalType()) {
|
994
|
-
case PhysicalType::INT16:
|
995
|
-
return GetTypedDiscreteQuantileAggregateFunction<int16_t, int16_t>(type);
|
996
|
-
case PhysicalType::INT32:
|
997
|
-
return GetTypedDiscreteQuantileAggregateFunction<int32_t, int32_t>(type);
|
998
|
-
case PhysicalType::INT64:
|
999
|
-
return GetTypedDiscreteQuantileAggregateFunction<int64_t, int64_t>(type);
|
1000
|
-
case PhysicalType::INT128:
|
1001
|
-
return GetTypedDiscreteQuantileAggregateFunction<hugeint_t, hugeint_t>(type);
|
1002
|
-
default:
|
1003
|
-
throw NotImplementedException("Unimplemented discrete quantile aggregate");
|
1004
|
-
}
|
1005
|
-
case LogicalTypeId::DATE:
|
1006
|
-
return GetTypedDiscreteQuantileAggregateFunction<int32_t, int32_t>(type);
|
1007
|
-
case LogicalTypeId::TIMESTAMP:
|
1008
|
-
case LogicalTypeId::TIMESTAMP_TZ:
|
1009
|
-
return GetTypedDiscreteQuantileAggregateFunction<int64_t, int64_t>(type);
|
1010
|
-
case LogicalTypeId::TIME:
|
1011
|
-
case LogicalTypeId::TIME_TZ:
|
1012
|
-
return GetTypedDiscreteQuantileAggregateFunction<int64_t, int64_t>(type);
|
1013
|
-
case LogicalTypeId::INTERVAL:
|
1014
|
-
return GetTypedDiscreteQuantileAggregateFunction<interval_t, interval_t>(type);
|
1015
|
-
case LogicalTypeId::ANY:
|
1016
|
-
return GetTypedDiscreteQuantileAggregateFunction<string_t, std::string>(type);
|
1017
|
-
|
1018
|
-
default:
|
1019
|
-
throw NotImplementedException("Unimplemented discrete quantile aggregate");
|
1020
|
-
}
|
1021
|
-
}
|
1022
|
-
|
1023
|
-
template <class CHILD_TYPE, bool DISCRETE>
|
1024
|
-
struct QuantileListOperation : public QuantileOperation {
|
1025
|
-
|
1026
|
-
template <class T, class STATE>
|
1027
|
-
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
1028
|
-
if (state.v.empty()) {
|
1029
|
-
finalize_data.ReturnNull();
|
1030
|
-
return;
|
1031
|
-
}
|
1032
|
-
|
1033
|
-
D_ASSERT(finalize_data.input.bind_data);
|
1034
|
-
auto &bind_data = finalize_data.input.bind_data->Cast<QuantileBindData>();
|
1035
|
-
|
1036
|
-
auto &result = ListVector::GetEntry(finalize_data.result);
|
1037
|
-
auto ridx = ListVector::GetListSize(finalize_data.result);
|
1038
|
-
ListVector::Reserve(finalize_data.result, ridx + bind_data.quantiles.size());
|
1039
|
-
auto rdata = FlatVector::GetData<CHILD_TYPE>(result);
|
1040
|
-
|
1041
|
-
auto v_t = state.v.data();
|
1042
|
-
D_ASSERT(v_t);
|
1043
|
-
|
1044
|
-
auto &entry = target;
|
1045
|
-
entry.offset = ridx;
|
1046
|
-
idx_t lower = 0;
|
1047
|
-
for (const auto &q : bind_data.order) {
|
1048
|
-
const auto &quantile = bind_data.quantiles[q];
|
1049
|
-
Interpolator<DISCRETE> interp(quantile, state.v.size(), bind_data.desc);
|
1050
|
-
interp.begin = lower;
|
1051
|
-
rdata[ridx + q] = interp.template Operation<typename STATE::SaveType, CHILD_TYPE>(v_t, result);
|
1052
|
-
lower = interp.FRN;
|
1053
|
-
}
|
1054
|
-
entry.length = bind_data.quantiles.size();
|
1055
|
-
|
1056
|
-
ListVector::SetListSize(finalize_data.result, entry.offset + entry.length);
|
1057
|
-
}
|
1058
|
-
|
1059
|
-
template <class STATE, class INPUT_TYPE, class RESULT_TYPE>
|
1060
|
-
static void Window(const INPUT_TYPE *data, const ValidityMask &fmask, const ValidityMask &dmask,
|
1061
|
-
AggregateInputData &aggr_input_data, STATE &state, const SubFrames &frames, Vector &list,
|
1062
|
-
idx_t lidx, const STATE *gstate) {
|
1063
|
-
D_ASSERT(aggr_input_data.bind_data);
|
1064
|
-
auto &bind_data = aggr_input_data.bind_data->Cast<QuantileBindData>();
|
1065
|
-
|
1066
|
-
QuantileIncluded included(fmask, dmask);
|
1067
|
-
const auto n = FrameSize(included, frames);
|
1068
|
-
|
1069
|
-
// Result is a constant LIST<RESULT_TYPE> with a fixed length
|
1070
|
-
if (!n) {
|
1071
|
-
auto &lmask = FlatVector::Validity(list);
|
1072
|
-
lmask.Set(lidx, false);
|
1073
|
-
return;
|
1074
|
-
}
|
1075
|
-
|
1076
|
-
if (gstate && gstate->HasTrees()) {
|
1077
|
-
gstate->template WindowList<CHILD_TYPE, DISCRETE>(data, frames, n, list, lidx, bind_data);
|
1078
|
-
} else {
|
1079
|
-
//
|
1080
|
-
state.UpdateSkip(data, frames, included);
|
1081
|
-
state.template WindowList<CHILD_TYPE, DISCRETE>(data, frames, n, list, lidx, bind_data);
|
1082
|
-
state.prevs = frames;
|
1083
|
-
}
|
1084
|
-
}
|
1085
|
-
};
|
1086
|
-
|
1087
|
-
template <typename INPUT_TYPE, typename SAVE_TYPE>
|
1088
|
-
AggregateFunction GetTypedDiscreteQuantileListAggregateFunction(const LogicalType &type) {
|
1089
|
-
using STATE = QuantileState<INPUT_TYPE, SAVE_TYPE>;
|
1090
|
-
using OP = QuantileListOperation<INPUT_TYPE, true>;
|
1091
|
-
auto fun = QuantileListAggregate<STATE, INPUT_TYPE, list_entry_t, OP>(type, type);
|
1092
|
-
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
1093
|
-
fun.window = AggregateFunction::UnaryWindow<STATE, INPUT_TYPE, list_entry_t, OP>;
|
1094
|
-
fun.window_init = OP::template WindowInit<STATE, INPUT_TYPE>;
|
1095
|
-
return fun;
|
1096
|
-
}
|
1097
|
-
|
1098
|
-
AggregateFunction GetDiscreteQuantileListAggregateFunction(const LogicalType &type) {
|
1099
|
-
switch (type.id()) {
|
1100
|
-
case LogicalTypeId::TINYINT:
|
1101
|
-
return GetTypedDiscreteQuantileListAggregateFunction<int8_t, int8_t>(type);
|
1102
|
-
case LogicalTypeId::SMALLINT:
|
1103
|
-
return GetTypedDiscreteQuantileListAggregateFunction<int16_t, int16_t>(type);
|
1104
|
-
case LogicalTypeId::INTEGER:
|
1105
|
-
return GetTypedDiscreteQuantileListAggregateFunction<int32_t, int32_t>(type);
|
1106
|
-
case LogicalTypeId::BIGINT:
|
1107
|
-
return GetTypedDiscreteQuantileListAggregateFunction<int64_t, int64_t>(type);
|
1108
|
-
case LogicalTypeId::HUGEINT:
|
1109
|
-
return GetTypedDiscreteQuantileListAggregateFunction<hugeint_t, hugeint_t>(type);
|
1110
|
-
case LogicalTypeId::FLOAT:
|
1111
|
-
return GetTypedDiscreteQuantileListAggregateFunction<float, float>(type);
|
1112
|
-
case LogicalTypeId::DOUBLE:
|
1113
|
-
return GetTypedDiscreteQuantileListAggregateFunction<double, double>(type);
|
1114
|
-
case LogicalTypeId::DECIMAL:
|
1115
|
-
switch (type.InternalType()) {
|
1116
|
-
case PhysicalType::INT16:
|
1117
|
-
return GetTypedDiscreteQuantileListAggregateFunction<int16_t, int16_t>(type);
|
1118
|
-
case PhysicalType::INT32:
|
1119
|
-
return GetTypedDiscreteQuantileListAggregateFunction<int32_t, int32_t>(type);
|
1120
|
-
case PhysicalType::INT64:
|
1121
|
-
return GetTypedDiscreteQuantileListAggregateFunction<int64_t, int64_t>(type);
|
1122
|
-
case PhysicalType::INT128:
|
1123
|
-
return GetTypedDiscreteQuantileListAggregateFunction<hugeint_t, hugeint_t>(type);
|
1124
|
-
default:
|
1125
|
-
throw NotImplementedException("Unimplemented discrete quantile list aggregate");
|
1126
|
-
}
|
1127
|
-
case LogicalTypeId::DATE:
|
1128
|
-
return GetTypedDiscreteQuantileListAggregateFunction<date_t, date_t>(type);
|
1129
|
-
case LogicalTypeId::TIMESTAMP:
|
1130
|
-
case LogicalTypeId::TIMESTAMP_TZ:
|
1131
|
-
return GetTypedDiscreteQuantileListAggregateFunction<timestamp_t, timestamp_t>(type);
|
1132
|
-
case LogicalTypeId::TIME:
|
1133
|
-
case LogicalTypeId::TIME_TZ:
|
1134
|
-
return GetTypedDiscreteQuantileListAggregateFunction<dtime_t, dtime_t>(type);
|
1135
|
-
case LogicalTypeId::INTERVAL:
|
1136
|
-
return GetTypedDiscreteQuantileListAggregateFunction<interval_t, interval_t>(type);
|
1137
|
-
case LogicalTypeId::ANY:
|
1138
|
-
return GetTypedDiscreteQuantileListAggregateFunction<string_t, std::string>(type);
|
1139
|
-
default:
|
1140
|
-
throw NotImplementedException("Unimplemented discrete quantile list aggregate");
|
1141
|
-
}
|
1142
|
-
}
|
1143
|
-
|
1144
|
-
template <typename INPUT_TYPE, typename TARGET_TYPE>
|
1145
|
-
AggregateFunction GetTypedContinuousQuantileAggregateFunction(const LogicalType &input_type,
|
1146
|
-
const LogicalType &target_type) {
|
1147
|
-
using STATE = QuantileState<INPUT_TYPE, INPUT_TYPE>;
|
1148
|
-
using OP = QuantileScalarOperation<false>;
|
1149
|
-
auto fun = AggregateFunction::UnaryAggregateDestructor<STATE, INPUT_TYPE, TARGET_TYPE, OP>(input_type, target_type);
|
1150
|
-
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
1151
|
-
fun.window = AggregateFunction::UnaryWindow<STATE, INPUT_TYPE, TARGET_TYPE, OP>;
|
1152
|
-
fun.window_init = OP::template WindowInit<STATE, INPUT_TYPE>;
|
1153
|
-
return fun;
|
1154
|
-
}
|
1155
|
-
|
1156
|
-
AggregateFunction GetContinuousQuantileAggregateFunction(const LogicalType &type) {
|
1157
|
-
switch (type.id()) {
|
1158
|
-
case LogicalTypeId::TINYINT:
|
1159
|
-
return GetTypedContinuousQuantileAggregateFunction<int8_t, double>(type, LogicalType::DOUBLE);
|
1160
|
-
case LogicalTypeId::SMALLINT:
|
1161
|
-
return GetTypedContinuousQuantileAggregateFunction<int16_t, double>(type, LogicalType::DOUBLE);
|
1162
|
-
case LogicalTypeId::INTEGER:
|
1163
|
-
return GetTypedContinuousQuantileAggregateFunction<int32_t, double>(type, LogicalType::DOUBLE);
|
1164
|
-
case LogicalTypeId::BIGINT:
|
1165
|
-
return GetTypedContinuousQuantileAggregateFunction<int64_t, double>(type, LogicalType::DOUBLE);
|
1166
|
-
case LogicalTypeId::HUGEINT:
|
1167
|
-
return GetTypedContinuousQuantileAggregateFunction<hugeint_t, double>(type, LogicalType::DOUBLE);
|
1168
|
-
case LogicalTypeId::FLOAT:
|
1169
|
-
return GetTypedContinuousQuantileAggregateFunction<float, float>(type, type);
|
1170
|
-
case LogicalTypeId::DOUBLE:
|
1171
|
-
return GetTypedContinuousQuantileAggregateFunction<double, double>(type, type);
|
1172
|
-
case LogicalTypeId::DECIMAL:
|
1173
|
-
switch (type.InternalType()) {
|
1174
|
-
case PhysicalType::INT16:
|
1175
|
-
return GetTypedContinuousQuantileAggregateFunction<int16_t, int16_t>(type, type);
|
1176
|
-
case PhysicalType::INT32:
|
1177
|
-
return GetTypedContinuousQuantileAggregateFunction<int32_t, int32_t>(type, type);
|
1178
|
-
case PhysicalType::INT64:
|
1179
|
-
return GetTypedContinuousQuantileAggregateFunction<int64_t, int64_t>(type, type);
|
1180
|
-
case PhysicalType::INT128:
|
1181
|
-
return GetTypedContinuousQuantileAggregateFunction<hugeint_t, hugeint_t>(type, type);
|
1182
|
-
default:
|
1183
|
-
throw NotImplementedException("Unimplemented continuous quantile DECIMAL aggregate");
|
1184
|
-
}
|
1185
|
-
case LogicalTypeId::DATE:
|
1186
|
-
return GetTypedContinuousQuantileAggregateFunction<date_t, timestamp_t>(type, LogicalType::TIMESTAMP);
|
1187
|
-
case LogicalTypeId::TIMESTAMP:
|
1188
|
-
case LogicalTypeId::TIMESTAMP_TZ:
|
1189
|
-
return GetTypedContinuousQuantileAggregateFunction<timestamp_t, timestamp_t>(type, type);
|
1190
|
-
case LogicalTypeId::TIME:
|
1191
|
-
case LogicalTypeId::TIME_TZ:
|
1192
|
-
return GetTypedContinuousQuantileAggregateFunction<dtime_t, dtime_t>(type, type);
|
1193
|
-
|
1194
|
-
default:
|
1195
|
-
throw NotImplementedException("Unimplemented continuous quantile aggregate");
|
1196
|
-
}
|
1197
|
-
}
|
1198
|
-
|
1199
|
-
template <typename INPUT_TYPE, typename CHILD_TYPE>
|
1200
|
-
AggregateFunction GetTypedContinuousQuantileListAggregateFunction(const LogicalType &input_type,
|
1201
|
-
const LogicalType &result_type) {
|
1202
|
-
using STATE = QuantileState<INPUT_TYPE, INPUT_TYPE>;
|
1203
|
-
using OP = QuantileListOperation<CHILD_TYPE, false>;
|
1204
|
-
auto fun = QuantileListAggregate<STATE, INPUT_TYPE, list_entry_t, OP>(input_type, result_type);
|
1205
|
-
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
1206
|
-
fun.window = AggregateFunction::UnaryWindow<STATE, INPUT_TYPE, list_entry_t, OP>;
|
1207
|
-
fun.window_init = OP::template WindowInit<STATE, INPUT_TYPE>;
|
1208
|
-
return fun;
|
1209
|
-
}
|
1210
|
-
|
1211
|
-
AggregateFunction GetContinuousQuantileListAggregateFunction(const LogicalType &type) {
|
1212
|
-
switch (type.id()) {
|
1213
|
-
case LogicalTypeId::TINYINT:
|
1214
|
-
return GetTypedContinuousQuantileListAggregateFunction<int8_t, double>(type, LogicalType::DOUBLE);
|
1215
|
-
case LogicalTypeId::SMALLINT:
|
1216
|
-
return GetTypedContinuousQuantileListAggregateFunction<int16_t, double>(type, LogicalType::DOUBLE);
|
1217
|
-
case LogicalTypeId::INTEGER:
|
1218
|
-
return GetTypedContinuousQuantileListAggregateFunction<int32_t, double>(type, LogicalType::DOUBLE);
|
1219
|
-
case LogicalTypeId::BIGINT:
|
1220
|
-
return GetTypedContinuousQuantileListAggregateFunction<int64_t, double>(type, LogicalType::DOUBLE);
|
1221
|
-
case LogicalTypeId::HUGEINT:
|
1222
|
-
return GetTypedContinuousQuantileListAggregateFunction<hugeint_t, double>(type, LogicalType::DOUBLE);
|
1223
|
-
case LogicalTypeId::FLOAT:
|
1224
|
-
return GetTypedContinuousQuantileListAggregateFunction<float, float>(type, type);
|
1225
|
-
case LogicalTypeId::DOUBLE:
|
1226
|
-
return GetTypedContinuousQuantileListAggregateFunction<double, double>(type, type);
|
1227
|
-
case LogicalTypeId::DECIMAL:
|
1228
|
-
switch (type.InternalType()) {
|
1229
|
-
case PhysicalType::INT16:
|
1230
|
-
return GetTypedContinuousQuantileListAggregateFunction<int16_t, int16_t>(type, type);
|
1231
|
-
case PhysicalType::INT32:
|
1232
|
-
return GetTypedContinuousQuantileListAggregateFunction<int32_t, int32_t>(type, type);
|
1233
|
-
case PhysicalType::INT64:
|
1234
|
-
return GetTypedContinuousQuantileListAggregateFunction<int64_t, int64_t>(type, type);
|
1235
|
-
case PhysicalType::INT128:
|
1236
|
-
return GetTypedContinuousQuantileListAggregateFunction<hugeint_t, hugeint_t>(type, type);
|
1237
|
-
default:
|
1238
|
-
throw NotImplementedException("Unimplemented discrete quantile DECIMAL list aggregate");
|
218
|
+
auto &bind_data = aggr_input_data.bind_data->Cast<QuantileBindData>();
|
219
|
+
|
220
|
+
auto rdata = FlatVector::GetData<RESULT_TYPE>(result);
|
221
|
+
auto &rmask = FlatVector::Validity(result);
|
222
|
+
|
223
|
+
if (!n) {
|
224
|
+
rmask.Set(ridx, false);
|
225
|
+
return;
|
1239
226
|
}
|
1240
|
-
case LogicalTypeId::DATE:
|
1241
|
-
return GetTypedContinuousQuantileListAggregateFunction<date_t, timestamp_t>(type, LogicalType::TIMESTAMP);
|
1242
|
-
case LogicalTypeId::TIMESTAMP:
|
1243
|
-
case LogicalTypeId::TIMESTAMP_TZ:
|
1244
|
-
return GetTypedContinuousQuantileListAggregateFunction<timestamp_t, timestamp_t>(type, type);
|
1245
|
-
case LogicalTypeId::TIME:
|
1246
|
-
case LogicalTypeId::TIME_TZ:
|
1247
|
-
return GetTypedContinuousQuantileListAggregateFunction<dtime_t, dtime_t>(type, type);
|
1248
|
-
default:
|
1249
|
-
throw NotImplementedException("Unimplemented discrete quantile list aggregate");
|
1250
|
-
}
|
1251
|
-
}
|
1252
227
|
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1256
|
-
|
1257
|
-
|
1258
|
-
|
1259
|
-
}
|
228
|
+
const auto &quantile = bind_data.quantiles[0];
|
229
|
+
if (gstate && gstate->HasTrees()) {
|
230
|
+
rdata[ridx] = gstate->GetWindowState().template WindowScalar<RESULT_TYPE, DISCRETE>(data, frames, n, result,
|
231
|
+
quantile);
|
232
|
+
} else {
|
233
|
+
auto &window_state = state.GetOrCreateWindowState();
|
1260
234
|
|
1261
|
-
|
1262
|
-
|
1263
|
-
return TryAbsOperator::Operation<RESULT_TYPE, RESULT_TYPE>(delta);
|
1264
|
-
}
|
1265
|
-
};
|
235
|
+
// Update the skip list
|
236
|
+
window_state.UpdateSkip(data, frames, included);
|
1266
237
|
|
1267
|
-
//
|
1268
|
-
template
|
1269
|
-
struct MadAccessor<hugeint_t, double, double> {
|
1270
|
-
using INPUT_TYPE = hugeint_t;
|
1271
|
-
using RESULT_TYPE = double;
|
1272
|
-
using MEDIAN_TYPE = double;
|
1273
|
-
const MEDIAN_TYPE &median;
|
1274
|
-
explicit MadAccessor(const MEDIAN_TYPE &median_p) : median(median_p) {
|
1275
|
-
}
|
1276
|
-
inline RESULT_TYPE operator()(const INPUT_TYPE &input) const {
|
1277
|
-
const auto delta = Hugeint::Cast<double>(input) - median;
|
1278
|
-
return TryAbsOperator::Operation<double, double>(delta);
|
1279
|
-
}
|
1280
|
-
};
|
238
|
+
// Find the position(s) needed
|
239
|
+
rdata[ridx] = window_state.template WindowScalar<RESULT_TYPE, DISCRETE>(data, frames, n, result, quantile);
|
1281
240
|
|
1282
|
-
//
|
1283
|
-
|
1284
|
-
|
1285
|
-
using INPUT_TYPE = date_t;
|
1286
|
-
using RESULT_TYPE = interval_t;
|
1287
|
-
using MEDIAN_TYPE = timestamp_t;
|
1288
|
-
const MEDIAN_TYPE &median;
|
1289
|
-
explicit MadAccessor(const MEDIAN_TYPE &median_p) : median(median_p) {
|
1290
|
-
}
|
1291
|
-
inline RESULT_TYPE operator()(const INPUT_TYPE &input) const {
|
1292
|
-
const auto dt = Cast::Operation<date_t, timestamp_t>(input);
|
1293
|
-
const auto delta = dt - median;
|
1294
|
-
return Interval::FromMicro(TryAbsOperator::Operation<int64_t, int64_t>(delta));
|
241
|
+
// Save the previous state for next time
|
242
|
+
window_state.prevs = frames;
|
243
|
+
}
|
1295
244
|
}
|
1296
245
|
};
|
1297
246
|
|
1298
|
-
|
1299
|
-
template
|
1300
|
-
|
1301
|
-
|
1302
|
-
using RESULT_TYPE = interval_t;
|
1303
|
-
using MEDIAN_TYPE = timestamp_t;
|
1304
|
-
const MEDIAN_TYPE &median;
|
1305
|
-
explicit MadAccessor(const MEDIAN_TYPE &median_p) : median(median_p) {
|
1306
|
-
}
|
1307
|
-
inline RESULT_TYPE operator()(const INPUT_TYPE &input) const {
|
1308
|
-
const auto delta = input - median;
|
1309
|
-
return Interval::FromMicro(TryAbsOperator::Operation<int64_t, int64_t>(delta));
|
247
|
+
struct QuantileScalarFallback : QuantileOperation {
|
248
|
+
template <class INPUT_TYPE, class STATE, class OP>
|
249
|
+
static void Execute(STATE &state, const INPUT_TYPE &key, AggregateInputData &input_data) {
|
250
|
+
state.AddElement(key, input_data);
|
1310
251
|
}
|
1311
|
-
};
|
1312
252
|
|
1313
|
-
|
1314
|
-
|
1315
|
-
|
1316
|
-
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
1322
|
-
|
1323
|
-
|
1324
|
-
|
253
|
+
template <class STATE>
|
254
|
+
static void Finalize(STATE &state, AggregateFinalizeData &finalize_data) {
|
255
|
+
if (state.v.empty()) {
|
256
|
+
finalize_data.ReturnNull();
|
257
|
+
return;
|
258
|
+
}
|
259
|
+
D_ASSERT(finalize_data.input.bind_data);
|
260
|
+
auto &bind_data = finalize_data.input.bind_data->Cast<QuantileBindData>();
|
261
|
+
D_ASSERT(bind_data.quantiles.size() == 1);
|
262
|
+
Interpolator<true> interp(bind_data.quantiles[0], state.v.size(), bind_data.desc);
|
263
|
+
auto interpolation_result = interp.InterpolateInternal<string_t>(state.v.data());
|
264
|
+
CreateSortKeyHelpers::DecodeSortKey(interpolation_result, finalize_data.result, finalize_data.result_idx,
|
265
|
+
OrderModifiers(OrderType::ASCENDING, OrderByNullType::NULLS_LAST));
|
1325
266
|
}
|
1326
267
|
};
|
1327
268
|
|
1328
|
-
|
1329
|
-
|
1330
|
-
|
269
|
+
//===--------------------------------------------------------------------===//
|
270
|
+
// Quantile List
|
271
|
+
//===--------------------------------------------------------------------===//
|
272
|
+
template <class CHILD_TYPE, bool DISCRETE>
|
273
|
+
struct QuantileListOperation : QuantileOperation {
|
1331
274
|
template <class T, class STATE>
|
1332
275
|
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
1333
276
|
if (state.v.empty()) {
|
1334
277
|
finalize_data.ReturnNull();
|
1335
278
|
return;
|
1336
279
|
}
|
1337
|
-
|
280
|
+
|
1338
281
|
D_ASSERT(finalize_data.input.bind_data);
|
1339
282
|
auto &bind_data = finalize_data.input.bind_data->Cast<QuantileBindData>();
|
1340
|
-
D_ASSERT(bind_data.quantiles.size() == 1);
|
1341
|
-
const auto &q = bind_data.quantiles[0];
|
1342
|
-
Interpolator<false> interp(q, state.v.size(), false);
|
1343
|
-
const auto med = interp.template Operation<SAVE_TYPE, MEDIAN_TYPE>(state.v.data(), finalize_data.result);
|
1344
283
|
|
1345
|
-
|
1346
|
-
|
284
|
+
auto &result = ListVector::GetEntry(finalize_data.result);
|
285
|
+
auto ridx = ListVector::GetListSize(finalize_data.result);
|
286
|
+
ListVector::Reserve(finalize_data.result, ridx + bind_data.quantiles.size());
|
287
|
+
auto rdata = FlatVector::GetData<CHILD_TYPE>(result);
|
288
|
+
|
289
|
+
auto v_t = state.v.data();
|
290
|
+
D_ASSERT(v_t);
|
291
|
+
|
292
|
+
auto &entry = target;
|
293
|
+
entry.offset = ridx;
|
294
|
+
idx_t lower = 0;
|
295
|
+
for (const auto &q : bind_data.order) {
|
296
|
+
const auto &quantile = bind_data.quantiles[q];
|
297
|
+
Interpolator<DISCRETE> interp(quantile, state.v.size(), bind_data.desc);
|
298
|
+
interp.begin = lower;
|
299
|
+
rdata[ridx + q] = interp.template Operation<typename STATE::InputType, CHILD_TYPE>(v_t, result);
|
300
|
+
lower = interp.FRN;
|
301
|
+
}
|
302
|
+
entry.length = bind_data.quantiles.size();
|
303
|
+
|
304
|
+
ListVector::SetListSize(finalize_data.result, entry.offset + entry.length);
|
1347
305
|
}
|
1348
306
|
|
1349
307
|
template <class STATE, class INPUT_TYPE, class RESULT_TYPE>
|
1350
308
|
static void Window(const INPUT_TYPE *data, const ValidityMask &fmask, const ValidityMask &dmask,
|
1351
|
-
AggregateInputData &aggr_input_data, STATE &state, const SubFrames &frames, Vector &
|
1352
|
-
idx_t
|
1353
|
-
|
309
|
+
AggregateInputData &aggr_input_data, STATE &state, const SubFrames &frames, Vector &list,
|
310
|
+
idx_t lidx, const STATE *gstate) {
|
311
|
+
D_ASSERT(aggr_input_data.bind_data);
|
312
|
+
auto &bind_data = aggr_input_data.bind_data->Cast<QuantileBindData>();
|
1354
313
|
|
1355
314
|
QuantileIncluded included(fmask, dmask);
|
1356
315
|
const auto n = FrameSize(included, frames);
|
1357
316
|
|
317
|
+
// Result is a constant LIST<RESULT_TYPE> with a fixed length
|
1358
318
|
if (!n) {
|
1359
|
-
auto &
|
1360
|
-
|
319
|
+
auto &lmask = FlatVector::Validity(list);
|
320
|
+
lmask.Set(lidx, false);
|
1361
321
|
return;
|
1362
322
|
}
|
1363
323
|
|
1364
|
-
// Compute the median
|
1365
|
-
D_ASSERT(aggr_input_data.bind_data);
|
1366
|
-
auto &bind_data = aggr_input_data.bind_data->Cast<QuantileBindData>();
|
1367
|
-
|
1368
|
-
D_ASSERT(bind_data.quantiles.size() == 1);
|
1369
|
-
const auto &quantile = bind_data.quantiles[0];
|
1370
|
-
MEDIAN_TYPE med;
|
1371
324
|
if (gstate && gstate->HasTrees()) {
|
1372
|
-
|
325
|
+
gstate->GetWindowState().template WindowList<CHILD_TYPE, DISCRETE>(data, frames, n, list, lidx, bind_data);
|
1373
326
|
} else {
|
1374
|
-
state.
|
1375
|
-
|
327
|
+
auto &window_state = state.GetOrCreateWindowState();
|
328
|
+
window_state.UpdateSkip(data, frames, included);
|
329
|
+
window_state.template WindowList<CHILD_TYPE, DISCRETE>(data, frames, n, list, lidx, bind_data);
|
330
|
+
window_state.prevs = frames;
|
1376
331
|
}
|
332
|
+
}
|
333
|
+
};
|
1377
334
|
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
335
|
+
struct QuantileListFallback : QuantileOperation {
|
336
|
+
template <class INPUT_TYPE, class STATE, class OP>
|
337
|
+
static void Execute(STATE &state, const INPUT_TYPE &key, AggregateInputData &input_data) {
|
338
|
+
state.AddElement(key, input_data);
|
339
|
+
}
|
1382
340
|
|
1383
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
341
|
+
template <class T, class STATE>
|
342
|
+
static void Finalize(STATE &state, T &target, AggregateFinalizeData &finalize_data) {
|
343
|
+
if (state.v.empty()) {
|
344
|
+
finalize_data.ReturnNull();
|
345
|
+
return;
|
346
|
+
}
|
1389
347
|
|
1390
|
-
|
348
|
+
D_ASSERT(finalize_data.input.bind_data);
|
349
|
+
auto &bind_data = finalize_data.input.bind_data->Cast<QuantileBindData>();
|
1391
350
|
|
1392
|
-
|
1393
|
-
|
1394
|
-
|
351
|
+
auto &result = ListVector::GetEntry(finalize_data.result);
|
352
|
+
auto ridx = ListVector::GetListSize(finalize_data.result);
|
353
|
+
ListVector::Reserve(finalize_data.result, ridx + bind_data.quantiles.size());
|
1395
354
|
|
1396
|
-
|
1397
|
-
MAD mad(med);
|
355
|
+
D_ASSERT(state.v.data());
|
1398
356
|
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
357
|
+
auto &entry = target;
|
358
|
+
entry.offset = ridx;
|
359
|
+
idx_t lower = 0;
|
360
|
+
for (const auto &q : bind_data.order) {
|
361
|
+
const auto &quantile = bind_data.quantiles[q];
|
362
|
+
Interpolator<true> interp(quantile, state.v.size(), bind_data.desc);
|
363
|
+
interp.begin = lower;
|
364
|
+
auto interpolation_result = interp.InterpolateInternal<string_t>(state.v.data());
|
365
|
+
CreateSortKeyHelpers::DecodeSortKey(interpolation_result, result, ridx + q,
|
366
|
+
OrderModifiers(OrderType::ASCENDING, OrderByNullType::NULLS_LAST));
|
367
|
+
lower = interp.FRN;
|
368
|
+
}
|
369
|
+
entry.length = bind_data.quantiles.size();
|
1402
370
|
|
1403
|
-
|
1404
|
-
prevs = frames;
|
371
|
+
ListVector::SetListSize(finalize_data.result, entry.offset + entry.length);
|
1405
372
|
}
|
1406
373
|
};
|
1407
374
|
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
375
|
+
//===--------------------------------------------------------------------===//
|
376
|
+
// Discrete Quantiles
|
377
|
+
//===--------------------------------------------------------------------===//
|
378
|
+
template <class OP>
|
379
|
+
AggregateFunction GetDiscreteQuantileTemplated(const LogicalType &type) {
|
380
|
+
switch (type.InternalType()) {
|
381
|
+
case PhysicalType::INT8:
|
382
|
+
return OP::template GetFunction<int8_t>(type);
|
383
|
+
case PhysicalType::INT16:
|
384
|
+
return OP::template GetFunction<int16_t>(type);
|
385
|
+
case PhysicalType::INT32:
|
386
|
+
return OP::template GetFunction<int32_t>(type);
|
387
|
+
case PhysicalType::INT64:
|
388
|
+
return OP::template GetFunction<int64_t>(type);
|
389
|
+
case PhysicalType::INT128:
|
390
|
+
return OP::template GetFunction<hugeint_t>(type);
|
391
|
+
case PhysicalType::FLOAT:
|
392
|
+
return OP::template GetFunction<float>(type);
|
393
|
+
case PhysicalType::DOUBLE:
|
394
|
+
return OP::template GetFunction<double>(type);
|
395
|
+
case PhysicalType::INTERVAL:
|
396
|
+
return OP::template GetFunction<interval_t>(type);
|
397
|
+
case PhysicalType::VARCHAR:
|
398
|
+
return OP::template GetFunction<string_t, QuantileStringType>(type);
|
399
|
+
default:
|
400
|
+
return OP::GetFallback(type);
|
401
|
+
}
|
1411
402
|
}
|
1412
403
|
|
1413
|
-
|
1414
|
-
|
1415
|
-
|
1416
|
-
|
1417
|
-
|
1418
|
-
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
404
|
+
struct ScalarDiscreteQuantile {
|
405
|
+
template <typename INPUT_TYPE, class TYPE_OP = QuantileStandardType>
|
406
|
+
static AggregateFunction GetFunction(const LogicalType &type) {
|
407
|
+
using STATE = QuantileState<INPUT_TYPE, TYPE_OP>;
|
408
|
+
using OP = QuantileScalarOperation<true>;
|
409
|
+
auto fun = AggregateFunction::UnaryAggregateDestructor<STATE, INPUT_TYPE, INPUT_TYPE, OP>(type, type);
|
410
|
+
fun.window = AggregateFunction::UnaryWindow<STATE, INPUT_TYPE, INPUT_TYPE, OP>;
|
411
|
+
fun.window_init = OP::WindowInit<STATE, INPUT_TYPE>;
|
412
|
+
return fun;
|
413
|
+
}
|
414
|
+
|
415
|
+
static AggregateFunction GetFallback(const LogicalType &type) {
|
416
|
+
using STATE = QuantileState<string_t, QuantileStringType>;
|
417
|
+
using OP = QuantileScalarFallback;
|
418
|
+
|
419
|
+
AggregateFunction fun(
|
420
|
+
{type}, type, AggregateFunction::StateSize<STATE>, AggregateFunction::StateInitialize<STATE, OP>,
|
421
|
+
AggregateSortKeyHelpers::UnaryUpdate<STATE, OP>, AggregateFunction::StateCombine<STATE, OP>,
|
422
|
+
AggregateFunction::StateVoidFinalize<STATE, OP>, nullptr, nullptr,
|
423
|
+
AggregateFunction::StateDestroy<STATE, OP>);
|
424
|
+
return fun;
|
425
|
+
}
|
426
|
+
};
|
427
|
+
|
428
|
+
template <class STATE, class INPUT_TYPE, class RESULT_TYPE, class OP>
|
429
|
+
static AggregateFunction QuantileListAggregate(const LogicalType &input_type, const LogicalType &child_type) { // NOLINT
|
430
|
+
LogicalType result_type = LogicalType::LIST(child_type);
|
431
|
+
return AggregateFunction(
|
432
|
+
{input_type}, result_type, AggregateFunction::StateSize<STATE>, AggregateFunction::StateInitialize<STATE, OP>,
|
433
|
+
AggregateFunction::UnaryScatterUpdate<STATE, INPUT_TYPE, OP>, AggregateFunction::StateCombine<STATE, OP>,
|
434
|
+
AggregateFunction::StateFinalize<STATE, RESULT_TYPE, OP>, AggregateFunction::UnaryUpdate<STATE, INPUT_TYPE, OP>,
|
435
|
+
nullptr, AggregateFunction::StateDestroy<STATE, OP>);
|
1424
436
|
}
|
1425
437
|
|
1426
|
-
|
438
|
+
struct ListDiscreteQuantile {
|
439
|
+
template <typename INPUT_TYPE, class TYPE_OP = QuantileStandardType>
|
440
|
+
static AggregateFunction GetFunction(const LogicalType &type) {
|
441
|
+
using STATE = QuantileState<INPUT_TYPE, TYPE_OP>;
|
442
|
+
using OP = QuantileListOperation<INPUT_TYPE, true>;
|
443
|
+
auto fun = QuantileListAggregate<STATE, INPUT_TYPE, list_entry_t, OP>(type, type);
|
444
|
+
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
445
|
+
fun.window = AggregateFunction::UnaryWindow<STATE, INPUT_TYPE, list_entry_t, OP>;
|
446
|
+
fun.window_init = OP::template WindowInit<STATE, INPUT_TYPE>;
|
447
|
+
return fun;
|
448
|
+
}
|
449
|
+
|
450
|
+
static AggregateFunction GetFallback(const LogicalType &type) {
|
451
|
+
using STATE = QuantileState<string_t, QuantileStringType>;
|
452
|
+
using OP = QuantileListFallback;
|
453
|
+
|
454
|
+
AggregateFunction fun(
|
455
|
+
{type}, LogicalType::LIST(type), AggregateFunction::StateSize<STATE>,
|
456
|
+
AggregateFunction::StateInitialize<STATE, OP>, AggregateSortKeyHelpers::UnaryUpdate<STATE, OP>,
|
457
|
+
AggregateFunction::StateCombine<STATE, OP>, AggregateFunction::StateFinalize<STATE, list_entry_t, OP>,
|
458
|
+
nullptr, nullptr, AggregateFunction::StateDestroy<STATE, OP>);
|
459
|
+
return fun;
|
460
|
+
}
|
461
|
+
};
|
462
|
+
|
463
|
+
AggregateFunction GetDiscreteQuantile(const LogicalType &type) {
|
464
|
+
return GetDiscreteQuantileTemplated<ScalarDiscreteQuantile>(type);
|
465
|
+
}
|
466
|
+
|
467
|
+
AggregateFunction GetDiscreteQuantileList(const LogicalType &type) {
|
468
|
+
return GetDiscreteQuantileTemplated<ListDiscreteQuantile>(type);
|
469
|
+
}
|
470
|
+
|
471
|
+
//===--------------------------------------------------------------------===//
|
472
|
+
// Continuous Quantiles
|
473
|
+
//===--------------------------------------------------------------------===//
|
474
|
+
template <class OP>
|
475
|
+
AggregateFunction GetContinuousQuantileTemplated(const LogicalType &type) {
|
1427
476
|
switch (type.id()) {
|
477
|
+
case LogicalTypeId::TINYINT:
|
478
|
+
return OP::template GetFunction<int8_t, double>(type, LogicalType::DOUBLE);
|
479
|
+
case LogicalTypeId::SMALLINT:
|
480
|
+
return OP::template GetFunction<int16_t, double>(type, LogicalType::DOUBLE);
|
481
|
+
case LogicalTypeId::SQLNULL:
|
482
|
+
case LogicalTypeId::INTEGER:
|
483
|
+
return OP::template GetFunction<int32_t, double>(type, LogicalType::DOUBLE);
|
484
|
+
case LogicalTypeId::BIGINT:
|
485
|
+
return OP::template GetFunction<int64_t, double>(type, LogicalType::DOUBLE);
|
486
|
+
case LogicalTypeId::HUGEINT:
|
487
|
+
return OP::template GetFunction<hugeint_t, double>(type, LogicalType::DOUBLE);
|
1428
488
|
case LogicalTypeId::FLOAT:
|
1429
|
-
return
|
489
|
+
return OP::template GetFunction<float, float>(type, type);
|
490
|
+
case LogicalTypeId::UTINYINT:
|
491
|
+
case LogicalTypeId::USMALLINT:
|
492
|
+
case LogicalTypeId::UINTEGER:
|
493
|
+
case LogicalTypeId::UBIGINT:
|
494
|
+
case LogicalTypeId::UHUGEINT:
|
1430
495
|
case LogicalTypeId::DOUBLE:
|
1431
|
-
return
|
496
|
+
return OP::template GetFunction<double, double>(LogicalType::DOUBLE, LogicalType::DOUBLE);
|
1432
497
|
case LogicalTypeId::DECIMAL:
|
1433
498
|
switch (type.InternalType()) {
|
1434
499
|
case PhysicalType::INT16:
|
1435
|
-
return
|
500
|
+
return OP::template GetFunction<int16_t, int16_t>(type, type);
|
1436
501
|
case PhysicalType::INT32:
|
1437
|
-
return
|
502
|
+
return OP::template GetFunction<int32_t, int32_t>(type, type);
|
1438
503
|
case PhysicalType::INT64:
|
1439
|
-
return
|
504
|
+
return OP::template GetFunction<int64_t, int64_t>(type, type);
|
1440
505
|
case PhysicalType::INT128:
|
1441
|
-
return
|
506
|
+
return OP::template GetFunction<hugeint_t, hugeint_t>(type, type);
|
1442
507
|
default:
|
1443
|
-
throw NotImplementedException("Unimplemented
|
508
|
+
throw NotImplementedException("Unimplemented continuous quantile DECIMAL aggregate");
|
1444
509
|
}
|
1445
|
-
break;
|
1446
|
-
|
1447
510
|
case LogicalTypeId::DATE:
|
1448
|
-
return
|
1449
|
-
LogicalType::INTERVAL);
|
511
|
+
return OP::template GetFunction<date_t, timestamp_t>(type, LogicalType::TIMESTAMP);
|
1450
512
|
case LogicalTypeId::TIMESTAMP:
|
1451
513
|
case LogicalTypeId::TIMESTAMP_TZ:
|
1452
|
-
|
1453
|
-
|
514
|
+
case LogicalTypeId::TIMESTAMP_SEC:
|
515
|
+
case LogicalTypeId::TIMESTAMP_MS:
|
516
|
+
case LogicalTypeId::TIMESTAMP_NS:
|
517
|
+
return OP::template GetFunction<timestamp_t, timestamp_t>(type, type);
|
1454
518
|
case LogicalTypeId::TIME:
|
1455
519
|
case LogicalTypeId::TIME_TZ:
|
1456
|
-
return
|
1457
|
-
LogicalType::INTERVAL);
|
1458
|
-
|
520
|
+
return OP::template GetFunction<dtime_t, dtime_t>(type, type);
|
1459
521
|
default:
|
1460
|
-
throw NotImplementedException("Unimplemented
|
522
|
+
throw NotImplementedException("Unimplemented continuous quantile aggregate");
|
1461
523
|
}
|
1462
524
|
}
|
1463
525
|
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
526
|
+
struct ScalarContinuousQuantile {
|
527
|
+
template <typename INPUT_TYPE, typename TARGET_TYPE>
|
528
|
+
static AggregateFunction GetFunction(const LogicalType &input_type, const LogicalType &target_type) {
|
529
|
+
using STATE = QuantileState<INPUT_TYPE, QuantileStandardType>;
|
530
|
+
using OP = QuantileScalarOperation<false>;
|
531
|
+
auto fun =
|
532
|
+
AggregateFunction::UnaryAggregateDestructor<STATE, INPUT_TYPE, TARGET_TYPE, OP>(input_type, target_type);
|
533
|
+
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
534
|
+
fun.window = AggregateFunction::UnaryWindow<STATE, INPUT_TYPE, TARGET_TYPE, OP>;
|
535
|
+
fun.window_init = OP::template WindowInit<STATE, INPUT_TYPE>;
|
536
|
+
return fun;
|
537
|
+
}
|
538
|
+
};
|
539
|
+
|
540
|
+
struct ListContinuousQuantile {
|
541
|
+
template <typename INPUT_TYPE, typename TARGET_TYPE>
|
542
|
+
static AggregateFunction GetFunction(const LogicalType &input_type, const LogicalType &target_type) {
|
543
|
+
using STATE = QuantileState<INPUT_TYPE, QuantileStandardType>;
|
544
|
+
using OP = QuantileListOperation<TARGET_TYPE, false>;
|
545
|
+
auto fun = QuantileListAggregate<STATE, INPUT_TYPE, list_entry_t, OP>(input_type, target_type);
|
546
|
+
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
547
|
+
fun.window = AggregateFunction::UnaryWindow<STATE, INPUT_TYPE, list_entry_t, OP>;
|
548
|
+
fun.window_init = OP::template WindowInit<STATE, INPUT_TYPE>;
|
549
|
+
return fun;
|
550
|
+
}
|
551
|
+
};
|
1467
552
|
|
1468
|
-
|
1469
|
-
|
1470
|
-
function.serialize = QuantileBindData::SerializeDecimalDiscrete;
|
1471
|
-
function.deserialize = QuantileBindData::Deserialize;
|
1472
|
-
function.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
1473
|
-
return bind_data;
|
553
|
+
AggregateFunction GetContinuousQuantile(const LogicalType &type) {
|
554
|
+
return GetContinuousQuantileTemplated<ScalarContinuousQuantile>(type);
|
1474
555
|
}
|
1475
556
|
|
1476
|
-
|
1477
|
-
|
1478
|
-
function = GetMedianAbsoluteDeviationAggregateFunction(arguments[0]->return_type);
|
1479
|
-
function.name = "mad";
|
1480
|
-
function.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
1481
|
-
return BindMedian(context, function, arguments);
|
557
|
+
AggregateFunction GetContinuousQuantileList(const LogicalType &type) {
|
558
|
+
return GetContinuousQuantileTemplated<ListContinuousQuantile>(type);
|
1482
559
|
}
|
1483
560
|
|
561
|
+
//===--------------------------------------------------------------------===//
|
562
|
+
// Quantile binding
|
563
|
+
//===--------------------------------------------------------------------===//
|
1484
564
|
static const Value &CheckQuantile(const Value &quantile_val) {
|
1485
565
|
if (quantile_val.IsNull()) {
|
1486
566
|
throw BinderException("QUANTILE parameter cannot be NULL");
|
@@ -1498,6 +578,9 @@ static const Value &CheckQuantile(const Value &quantile_val) {
|
|
1498
578
|
|
1499
579
|
unique_ptr<FunctionData> BindQuantile(ClientContext &context, AggregateFunction &function,
|
1500
580
|
vector<unique_ptr<Expression>> &arguments) {
|
581
|
+
if (arguments.size() < 2) {
|
582
|
+
throw BinderException("QUANTILE requires a range argument between [0, 1]");
|
583
|
+
}
|
1501
584
|
if (arguments[1]->HasParameter()) {
|
1502
585
|
throw ParameterNotResolvedException();
|
1503
586
|
}
|
@@ -1529,202 +612,235 @@ unique_ptr<FunctionData> BindQuantile(ClientContext &context, AggregateFunction
|
|
1529
612
|
return make_uniq<QuantileBindData>(quantiles);
|
1530
613
|
}
|
1531
614
|
|
1532
|
-
|
1533
|
-
|
1534
|
-
|
1535
|
-
|
1536
|
-
|
1537
|
-
|
1538
|
-
|
1539
|
-
|
1540
|
-
|
1541
|
-
|
1542
|
-
|
1543
|
-
|
1544
|
-
case
|
1545
|
-
|
1546
|
-
|
1547
|
-
|
1548
|
-
|
1549
|
-
case
|
1550
|
-
|
1551
|
-
|
1552
|
-
|
1553
|
-
|
1554
|
-
case
|
1555
|
-
|
615
|
+
//===--------------------------------------------------------------------===//
|
616
|
+
// Function definitions
|
617
|
+
//===--------------------------------------------------------------------===//
|
618
|
+
static bool CanInterpolate(const LogicalType &type) {
|
619
|
+
if (type.HasAlias()) {
|
620
|
+
return false;
|
621
|
+
}
|
622
|
+
switch (type.id()) {
|
623
|
+
case LogicalTypeId::DECIMAL:
|
624
|
+
case LogicalTypeId::SQLNULL:
|
625
|
+
case LogicalTypeId::TINYINT:
|
626
|
+
case LogicalTypeId::SMALLINT:
|
627
|
+
case LogicalTypeId::INTEGER:
|
628
|
+
case LogicalTypeId::UTINYINT:
|
629
|
+
case LogicalTypeId::USMALLINT:
|
630
|
+
case LogicalTypeId::UINTEGER:
|
631
|
+
case LogicalTypeId::UBIGINT:
|
632
|
+
case LogicalTypeId::BIGINT:
|
633
|
+
case LogicalTypeId::UHUGEINT:
|
634
|
+
case LogicalTypeId::HUGEINT:
|
635
|
+
case LogicalTypeId::FLOAT:
|
636
|
+
case LogicalTypeId::DOUBLE:
|
637
|
+
case LogicalTypeId::DATE:
|
638
|
+
case LogicalTypeId::TIMESTAMP:
|
639
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
640
|
+
case LogicalTypeId::TIMESTAMP_SEC:
|
641
|
+
case LogicalTypeId::TIMESTAMP_MS:
|
642
|
+
case LogicalTypeId::TIMESTAMP_NS:
|
643
|
+
case LogicalTypeId::TIME:
|
644
|
+
case LogicalTypeId::TIME_TZ:
|
645
|
+
return true;
|
646
|
+
default:
|
647
|
+
return false;
|
1556
648
|
}
|
1557
|
-
function.deserialize = QuantileBindData::Deserialize;
|
1558
|
-
function.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
1559
649
|
}
|
1560
650
|
|
1561
|
-
|
1562
|
-
|
1563
|
-
|
1564
|
-
|
1565
|
-
|
1566
|
-
|
651
|
+
struct MedianFunction {
|
652
|
+
static AggregateFunction GetAggregate(const LogicalType &type) {
|
653
|
+
auto fun = CanInterpolate(type) ? GetContinuousQuantile(type) : GetDiscreteQuantile(type);
|
654
|
+
fun.name = "median";
|
655
|
+
fun.serialize = QuantileBindData::Serialize;
|
656
|
+
fun.deserialize = Deserialize;
|
657
|
+
return fun;
|
658
|
+
}
|
1567
659
|
|
1568
|
-
unique_ptr<FunctionData>
|
1569
|
-
|
1570
|
-
auto bind_data = BindQuantile(context, function, arguments);
|
1571
|
-
BindQuantileInner(function, arguments[0]->return_type, QuantileSerializationType::DECIMAL_DISCRETE_LIST);
|
1572
|
-
return bind_data;
|
1573
|
-
}
|
660
|
+
static unique_ptr<FunctionData> Deserialize(Deserializer &deserializer, AggregateFunction &function) {
|
661
|
+
auto bind_data = QuantileBindData::Deserialize(deserializer, function);
|
1574
662
|
|
1575
|
-
|
1576
|
-
|
1577
|
-
|
1578
|
-
|
1579
|
-
return bind_data;
|
1580
|
-
}
|
663
|
+
auto &input_type = function.arguments[0];
|
664
|
+
function = GetAggregate(input_type);
|
665
|
+
return bind_data;
|
666
|
+
}
|
1581
667
|
|
1582
|
-
unique_ptr<FunctionData>
|
1583
|
-
|
1584
|
-
|
1585
|
-
|
1586
|
-
return bind_data;
|
1587
|
-
}
|
1588
|
-
static bool CanInterpolate(const LogicalType &type) {
|
1589
|
-
switch (type.id()) {
|
1590
|
-
case LogicalTypeId::INTERVAL:
|
1591
|
-
case LogicalTypeId::VARCHAR:
|
1592
|
-
case LogicalTypeId::ANY:
|
1593
|
-
return false;
|
1594
|
-
default:
|
1595
|
-
return true;
|
668
|
+
static unique_ptr<FunctionData> Bind(ClientContext &context, AggregateFunction &function,
|
669
|
+
vector<unique_ptr<Expression>> &arguments) {
|
670
|
+
function = GetAggregate(arguments[0]->return_type);
|
671
|
+
return make_uniq<QuantileBindData>(Value::DECIMAL(int16_t(5), 2, 1));
|
1596
672
|
}
|
1597
|
-
}
|
673
|
+
};
|
1598
674
|
|
1599
|
-
|
1600
|
-
|
1601
|
-
|
1602
|
-
|
1603
|
-
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
675
|
+
struct DiscreteQuantileListFunction {
|
676
|
+
static AggregateFunction GetAggregate(const LogicalType &type) {
|
677
|
+
auto fun = GetDiscreteQuantileList(type);
|
678
|
+
fun.name = "quantile_disc";
|
679
|
+
fun.bind = Bind;
|
680
|
+
fun.serialize = QuantileBindData::Serialize;
|
681
|
+
fun.deserialize = Deserialize;
|
682
|
+
// temporarily push an argument so we can bind the actual quantile
|
683
|
+
fun.arguments.emplace_back(LogicalType::LIST(LogicalType::DOUBLE));
|
684
|
+
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
685
|
+
return fun;
|
686
|
+
}
|
1607
687
|
|
1608
|
-
|
1609
|
-
|
1610
|
-
fun.bind = BindQuantile;
|
1611
|
-
fun.serialize = QuantileBindData::Serialize;
|
1612
|
-
fun.deserialize = QuantileBindData::Deserialize;
|
1613
|
-
// temporarily push an argument so we can bind the actual quantile
|
1614
|
-
fun.arguments.emplace_back(LogicalType::DOUBLE);
|
1615
|
-
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
1616
|
-
return fun;
|
1617
|
-
}
|
688
|
+
static unique_ptr<FunctionData> Deserialize(Deserializer &deserializer, AggregateFunction &function) {
|
689
|
+
auto bind_data = QuantileBindData::Deserialize(deserializer, function);
|
1618
690
|
|
1619
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
1623
|
-
fun.deserialize = QuantileBindData::Deserialize;
|
1624
|
-
// temporarily push an argument so we can bind the actual quantile
|
1625
|
-
auto list_of_double = LogicalType::LIST(LogicalType::DOUBLE);
|
1626
|
-
fun.arguments.push_back(list_of_double);
|
1627
|
-
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
1628
|
-
return fun;
|
1629
|
-
}
|
691
|
+
auto &input_type = function.arguments[0];
|
692
|
+
function = GetAggregate(input_type);
|
693
|
+
return bind_data;
|
694
|
+
}
|
1630
695
|
|
1631
|
-
|
1632
|
-
|
1633
|
-
|
1634
|
-
|
1635
|
-
|
1636
|
-
|
1637
|
-
fun.arguments.emplace_back(LogicalType::DOUBLE);
|
1638
|
-
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
1639
|
-
return fun;
|
1640
|
-
}
|
696
|
+
static unique_ptr<FunctionData> Bind(ClientContext &context, AggregateFunction &function,
|
697
|
+
vector<unique_ptr<Expression>> &arguments) {
|
698
|
+
function = GetAggregate(arguments[0]->return_type);
|
699
|
+
return BindQuantile(context, function, arguments);
|
700
|
+
}
|
701
|
+
};
|
1641
702
|
|
1642
|
-
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
|
1647
|
-
|
1648
|
-
|
1649
|
-
|
1650
|
-
|
1651
|
-
|
1652
|
-
|
703
|
+
struct DiscreteQuantileFunction {
|
704
|
+
static AggregateFunction GetAggregate(const LogicalType &type) {
|
705
|
+
auto fun = GetDiscreteQuantile(type);
|
706
|
+
fun.name = "quantile_disc";
|
707
|
+
fun.bind = Bind;
|
708
|
+
fun.serialize = QuantileBindData::Serialize;
|
709
|
+
fun.deserialize = Deserialize;
|
710
|
+
// temporarily push an argument so we can bind the actual quantile
|
711
|
+
fun.arguments.emplace_back(LogicalType::DOUBLE);
|
712
|
+
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
713
|
+
return fun;
|
714
|
+
}
|
715
|
+
|
716
|
+
static unique_ptr<FunctionData> Deserialize(Deserializer &deserializer, AggregateFunction &function) {
|
717
|
+
auto bind_data = QuantileBindData::Deserialize(deserializer, function);
|
718
|
+
auto &quantile_data = bind_data->Cast<QuantileBindData>();
|
719
|
+
|
720
|
+
auto &input_type = function.arguments[0];
|
721
|
+
if (quantile_data.quantiles.size() == 1) {
|
722
|
+
function = GetAggregate(input_type);
|
723
|
+
} else {
|
724
|
+
function = DiscreteQuantileListFunction::GetAggregate(input_type);
|
725
|
+
}
|
726
|
+
return bind_data;
|
727
|
+
}
|
728
|
+
|
729
|
+
static unique_ptr<FunctionData> Bind(ClientContext &context, AggregateFunction &function,
|
730
|
+
vector<unique_ptr<Expression>> &arguments) {
|
731
|
+
function = GetAggregate(arguments[0]->return_type);
|
732
|
+
return BindQuantile(context, function, arguments);
|
733
|
+
}
|
734
|
+
};
|
735
|
+
|
736
|
+
struct ContinuousQuantileFunction {
|
737
|
+
static AggregateFunction GetAggregate(const LogicalType &type) {
|
738
|
+
auto fun = GetContinuousQuantile(type);
|
739
|
+
fun.name = "quantile_cont";
|
740
|
+
fun.bind = Bind;
|
741
|
+
fun.serialize = QuantileBindData::Serialize;
|
742
|
+
fun.deserialize = Deserialize;
|
743
|
+
// temporarily push an argument so we can bind the actual quantile
|
744
|
+
fun.arguments.emplace_back(LogicalType::DOUBLE);
|
745
|
+
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
746
|
+
return fun;
|
747
|
+
}
|
748
|
+
|
749
|
+
static unique_ptr<FunctionData> Deserialize(Deserializer &deserializer, AggregateFunction &function) {
|
750
|
+
auto bind_data = QuantileBindData::Deserialize(deserializer, function);
|
751
|
+
|
752
|
+
auto &input_type = function.arguments[0];
|
753
|
+
function = GetAggregate(input_type);
|
754
|
+
return bind_data;
|
755
|
+
}
|
756
|
+
|
757
|
+
static unique_ptr<FunctionData> Bind(ClientContext &context, AggregateFunction &function,
|
758
|
+
vector<unique_ptr<Expression>> &arguments) {
|
759
|
+
function = GetAggregate(function.arguments[0].id() == LogicalTypeId::DECIMAL ? arguments[0]->return_type
|
760
|
+
: function.arguments[0]);
|
761
|
+
return BindQuantile(context, function, arguments);
|
762
|
+
}
|
763
|
+
};
|
764
|
+
|
765
|
+
struct ContinuousQuantileListFunction {
|
766
|
+
static AggregateFunction GetAggregate(const LogicalType &type) {
|
767
|
+
auto fun = GetContinuousQuantileList(type);
|
768
|
+
fun.name = "quantile_cont";
|
769
|
+
fun.bind = Bind;
|
770
|
+
fun.serialize = QuantileBindData::Serialize;
|
771
|
+
fun.deserialize = Deserialize;
|
772
|
+
// temporarily push an argument so we can bind the actual quantile
|
773
|
+
auto list_of_double = LogicalType::LIST(LogicalType::DOUBLE);
|
774
|
+
fun.arguments.push_back(list_of_double);
|
775
|
+
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
776
|
+
return fun;
|
777
|
+
}
|
778
|
+
|
779
|
+
static unique_ptr<FunctionData> Deserialize(Deserializer &deserializer, AggregateFunction &function) {
|
780
|
+
auto bind_data = QuantileBindData::Deserialize(deserializer, function);
|
781
|
+
|
782
|
+
auto &input_type = function.arguments[0];
|
783
|
+
function = GetAggregate(input_type);
|
784
|
+
return bind_data;
|
785
|
+
}
|
786
|
+
|
787
|
+
static unique_ptr<FunctionData> Bind(ClientContext &context, AggregateFunction &function,
|
788
|
+
vector<unique_ptr<Expression>> &arguments) {
|
789
|
+
function = GetAggregate(function.arguments[0].id() == LogicalTypeId::DECIMAL ? arguments[0]->return_type
|
790
|
+
: function.arguments[0]);
|
791
|
+
return BindQuantile(context, function, arguments);
|
792
|
+
}
|
793
|
+
};
|
1653
794
|
|
1654
|
-
|
1655
|
-
|
1656
|
-
AggregateFunction fun(
|
1657
|
-
|
795
|
+
template <class OP>
|
796
|
+
AggregateFunction EmptyQuantileFunction(LogicalType input, LogicalType result, const LogicalType &extra_arg) {
|
797
|
+
AggregateFunction fun({std::move(input)}, std::move(result), nullptr, nullptr, nullptr, nullptr, nullptr, nullptr,
|
798
|
+
OP::Bind);
|
799
|
+
if (extra_arg.id() != LogicalTypeId::INVALID) {
|
800
|
+
fun.arguments.push_back(extra_arg);
|
801
|
+
}
|
1658
802
|
fun.serialize = QuantileBindData::Serialize;
|
1659
|
-
fun.deserialize =
|
803
|
+
fun.deserialize = OP::Deserialize;
|
1660
804
|
fun.order_dependent = AggregateOrderDependent::NOT_ORDER_DEPENDENT;
|
1661
805
|
return fun;
|
1662
806
|
}
|
1663
807
|
|
1664
|
-
vector<LogicalType> GetQuantileTypes() {
|
1665
|
-
return {LogicalType::TINYINT, LogicalType::SMALLINT,
|
1666
|
-
LogicalType::INTEGER, LogicalType::BIGINT,
|
1667
|
-
LogicalType::HUGEINT, LogicalType::FLOAT,
|
1668
|
-
LogicalType::DOUBLE, LogicalType::DATE,
|
1669
|
-
LogicalType::TIMESTAMP, LogicalType::TIME,
|
1670
|
-
LogicalType::TIMESTAMP_TZ, LogicalType::TIME_TZ,
|
1671
|
-
LogicalType::INTERVAL, LogicalType::ANY_PARAMS(LogicalType::VARCHAR, 150)};
|
1672
|
-
}
|
1673
|
-
|
1674
808
|
AggregateFunctionSet MedianFun::GetFunctions() {
|
1675
|
-
AggregateFunctionSet
|
1676
|
-
|
1677
|
-
|
1678
|
-
for (const auto &type : GetQuantileTypes()) {
|
1679
|
-
median.AddFunction(GetMedianAggregate(type));
|
1680
|
-
}
|
1681
|
-
return median;
|
809
|
+
AggregateFunctionSet set("median");
|
810
|
+
set.AddFunction(EmptyQuantileFunction<MedianFunction>(LogicalType::ANY, LogicalType::ANY, LogicalTypeId::INVALID));
|
811
|
+
return set;
|
1682
812
|
}
|
1683
813
|
|
1684
814
|
AggregateFunctionSet QuantileDiscFun::GetFunctions() {
|
1685
|
-
AggregateFunctionSet
|
1686
|
-
|
1687
|
-
|
1688
|
-
|
1689
|
-
|
1690
|
-
|
1691
|
-
|
1692
|
-
|
1693
|
-
|
1694
|
-
|
1695
|
-
|
1696
|
-
|
815
|
+
AggregateFunctionSet set("quantile_disc");
|
816
|
+
set.AddFunction(
|
817
|
+
EmptyQuantileFunction<DiscreteQuantileFunction>(LogicalType::ANY, LogicalType::ANY, LogicalType::DOUBLE));
|
818
|
+
set.AddFunction(EmptyQuantileFunction<DiscreteQuantileListFunction>(LogicalType::ANY, LogicalType::ANY,
|
819
|
+
LogicalType::LIST(LogicalType::DOUBLE)));
|
820
|
+
// this function is here for deserialization - it cannot be called by users
|
821
|
+
set.AddFunction(
|
822
|
+
EmptyQuantileFunction<DiscreteQuantileFunction>(LogicalType::ANY, LogicalType::ANY, LogicalType::INVALID));
|
823
|
+
return set;
|
824
|
+
}
|
825
|
+
|
826
|
+
vector<LogicalType> GetContinuousQuantileTypes() {
|
827
|
+
return {LogicalType::TINYINT, LogicalType::SMALLINT, LogicalType::INTEGER, LogicalType::BIGINT,
|
828
|
+
LogicalType::HUGEINT, LogicalType::FLOAT, LogicalType::DOUBLE, LogicalType::DATE,
|
829
|
+
LogicalType::TIMESTAMP, LogicalType::TIME, LogicalType::TIMESTAMP_TZ, LogicalType::TIME_TZ};
|
1697
830
|
}
|
1698
831
|
|
1699
832
|
AggregateFunctionSet QuantileContFun::GetFunctions() {
|
1700
833
|
AggregateFunctionSet quantile_cont("quantile_cont");
|
1701
|
-
quantile_cont.AddFunction(
|
1702
|
-
|
1703
|
-
quantile_cont.AddFunction(
|
1704
|
-
|
1705
|
-
|
1706
|
-
|
1707
|
-
|
1708
|
-
|
1709
|
-
quantile_cont.AddFunction(GetContinuousQuantileAggregate(type));
|
1710
|
-
quantile_cont.AddFunction(GetContinuousQuantileListAggregate(type));
|
1711
|
-
}
|
834
|
+
quantile_cont.AddFunction(EmptyQuantileFunction<ContinuousQuantileFunction>(
|
835
|
+
LogicalTypeId::DECIMAL, LogicalTypeId::DECIMAL, LogicalType::DOUBLE));
|
836
|
+
quantile_cont.AddFunction(EmptyQuantileFunction<ContinuousQuantileListFunction>(
|
837
|
+
LogicalTypeId::DECIMAL, LogicalTypeId::DECIMAL, LogicalType::LIST(LogicalType::DOUBLE)));
|
838
|
+
for (const auto &type : GetContinuousQuantileTypes()) {
|
839
|
+
quantile_cont.AddFunction(EmptyQuantileFunction<ContinuousQuantileFunction>(type, type, LogicalType::DOUBLE));
|
840
|
+
quantile_cont.AddFunction(
|
841
|
+
EmptyQuantileFunction<ContinuousQuantileListFunction>(type, type, LogicalType::LIST(LogicalType::DOUBLE)));
|
1712
842
|
}
|
1713
843
|
return quantile_cont;
|
1714
844
|
}
|
1715
845
|
|
1716
|
-
AggregateFunctionSet MadFun::GetFunctions() {
|
1717
|
-
AggregateFunctionSet mad("mad");
|
1718
|
-
mad.AddFunction(AggregateFunction({LogicalTypeId::DECIMAL}, LogicalTypeId::DECIMAL, nullptr, nullptr, nullptr,
|
1719
|
-
nullptr, nullptr, nullptr, BindMedianAbsoluteDeviationDecimal));
|
1720
|
-
|
1721
|
-
const vector<LogicalType> MAD_TYPES = {LogicalType::FLOAT, LogicalType::DOUBLE, LogicalType::DATE,
|
1722
|
-
LogicalType::TIMESTAMP, LogicalType::TIME, LogicalType::TIMESTAMP_TZ,
|
1723
|
-
LogicalType::TIME_TZ};
|
1724
|
-
for (const auto &type : MAD_TYPES) {
|
1725
|
-
mad.AddFunction(GetMedianAbsoluteDeviationAggregateFunction(type));
|
1726
|
-
}
|
1727
|
-
return mad;
|
1728
|
-
}
|
1729
|
-
|
1730
846
|
} // namespace duckdb
|