duckdb 0.7.2-dev1457.0 → 0.7.2-dev1533.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/binding.gyp +8 -8
- package/package.json +1 -1
- package/src/duckdb/extension/icu/icu-dateadd.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datepart.cpp +3 -3
- package/src/duckdb/extension/icu/icu-datesub.cpp +2 -2
- package/src/duckdb/extension/icu/icu-datetrunc.cpp +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +3 -3
- package/src/duckdb/extension/icu/icu-list-range.cpp +1 -1
- package/src/duckdb/extension/icu/icu-makedate.cpp +1 -1
- package/src/duckdb/extension/icu/icu-strptime.cpp +7 -7
- package/src/duckdb/extension/icu/icu-timebucket.cpp +6 -6
- package/src/duckdb/extension/icu/icu-timezone.cpp +4 -4
- package/src/duckdb/extension/json/include/json_executors.hpp +2 -2
- package/src/duckdb/extension/json/json_functions/copy_json.cpp +4 -4
- package/src/duckdb/extension/json/json_functions/json_create.cpp +3 -3
- package/src/duckdb/extension/json/json_functions/json_serialize_sql.cpp +3 -3
- package/src/duckdb/extension/json/json_functions.cpp +2 -2
- package/src/duckdb/extension/parquet/parquet-extension.cpp +28 -28
- package/src/duckdb/extension/parquet/parquet_metadata.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +9 -9
- package/src/duckdb/src/catalog/catalog_entry/duck_table_entry.cpp +17 -17
- package/src/duckdb/src/catalog/catalog_entry/index_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry/scalar_macro_catalog_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_entry/schema_catalog_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_entry/sequence_catalog_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +5 -5
- package/src/duckdb/src/catalog/catalog_entry/type_catalog_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_entry/view_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/catalog_entry.cpp +2 -2
- package/src/duckdb/src/catalog/catalog_set.cpp +28 -28
- package/src/duckdb/src/catalog/default/default_functions.cpp +2 -1
- package/src/duckdb/src/catalog/dependency_manager.cpp +4 -4
- package/src/duckdb/src/common/enums/logical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/enums/physical_operator_type.cpp +2 -0
- package/src/duckdb/src/common/hive_partitioning.cpp +1 -1
- package/src/duckdb/src/common/multi_file_reader.cpp +1 -1
- package/src/duckdb/src/common/row_operations/row_aggregate.cpp +3 -0
- package/src/duckdb/src/common/string_util.cpp +24 -2
- package/src/duckdb/src/common/tree_renderer.cpp +2 -4
- package/src/duckdb/src/common/types.cpp +3 -1
- package/src/duckdb/src/execution/column_binding_resolver.cpp +5 -5
- package/src/duckdb/src/execution/expression_executor.cpp +4 -3
- package/src/duckdb/src/execution/expression_executor_state.cpp +1 -1
- package/src/duckdb/src/execution/index/art/art.cpp +6 -8
- package/src/duckdb/src/execution/operator/aggregate/distinct_aggregate_data.cpp +7 -7
- package/src/duckdb/src/execution/operator/aggregate/grouped_aggregate_data.cpp +2 -2
- package/src/duckdb/src/execution/operator/aggregate/physical_hash_aggregate.cpp +33 -33
- package/src/duckdb/src/execution/operator/aggregate/physical_perfecthash_aggregate.cpp +13 -13
- package/src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp +3 -3
- package/src/duckdb/src/execution/operator/aggregate/physical_ungrouped_aggregate.cpp +20 -20
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +12 -12
- package/src/duckdb/src/execution/operator/helper/physical_batch_collector.cpp +5 -5
- package/src/duckdb/src/execution/operator/helper/physical_explain_analyze.cpp +2 -2
- package/src/duckdb/src/execution/operator/helper/physical_limit.cpp +5 -5
- package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +4 -4
- package/src/duckdb/src/execution/operator/helper/physical_materialized_collector.cpp +4 -4
- package/src/duckdb/src/execution/operator/helper/physical_reservoir_sample.cpp +2 -2
- package/src/duckdb/src/execution/operator/helper/physical_streaming_limit.cpp +2 -2
- package/src/duckdb/src/execution/operator/helper/physical_streaming_sample.cpp +2 -2
- package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +4 -4
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +8 -8
- package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +3 -3
- package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +3 -3
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +12 -12
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +12 -12
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +6 -5
- package/src/duckdb/src/execution/operator/join/physical_join.cpp +2 -2
- package/src/duckdb/src/execution/operator/join/physical_nested_loop_join.cpp +13 -13
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +10 -10
- package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +3 -3
- package/src/duckdb/src/execution/operator/order/physical_order.cpp +11 -11
- package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +6 -6
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +7 -7
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +8 -8
- package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +5 -5
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +8 -8
- package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +7 -7
- package/src/duckdb/src/execution/operator/projection/physical_pivot.cpp +81 -0
- package/src/duckdb/src/execution/operator/projection/physical_tableinout_function.cpp +5 -5
- package/src/duckdb/src/execution/operator/projection/physical_unnest.cpp +4 -5
- package/src/duckdb/src/execution/operator/scan/physical_column_data_scan.cpp +1 -1
- package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +4 -4
- package/src/duckdb/src/execution/operator/scan/physical_table_scan.cpp +7 -7
- package/src/duckdb/src/execution/operator/schema/physical_alter.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_attach.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_function.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_index.cpp +8 -7
- package/src/duckdb/src/execution/operator/schema/physical_create_schema.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_sequence.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +3 -3
- package/src/duckdb/src/execution/operator/schema/physical_create_view.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_detach.cpp +1 -1
- package/src/duckdb/src/execution/operator/schema/physical_drop.cpp +1 -1
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +2 -2
- package/src/duckdb/src/execution/physical_operator.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +4 -4
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_delim_join.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_distinct.cpp +4 -1
- package/src/duckdb/src/execution/physical_plan/plan_pivot.cpp +14 -0
- package/src/duckdb/src/execution/physical_plan/plan_projection.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_window.cpp +8 -8
- package/src/duckdb/src/execution/physical_plan_generator.cpp +49 -42
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +14 -14
- package/src/duckdb/src/function/aggregate/algebraic/avg.cpp +2 -2
- package/src/duckdb/src/function/aggregate/distributive/bitstring_agg.cpp +1 -1
- package/src/duckdb/src/function/aggregate/distributive/string_agg.cpp +2 -2
- package/src/duckdb/src/function/aggregate/holistic/approximate_quantile.cpp +1 -1
- package/src/duckdb/src/function/aggregate/holistic/quantile.cpp +1 -1
- package/src/duckdb/src/function/aggregate/holistic/reservoir_quantile.cpp +1 -1
- package/src/duckdb/src/function/aggregate/nested/list.cpp +3 -3
- package/src/duckdb/src/function/cast/enum_casts.cpp +3 -3
- package/src/duckdb/src/function/cast/list_casts.cpp +2 -2
- package/src/duckdb/src/function/cast/string_cast.cpp +6 -6
- package/src/duckdb/src/function/cast/struct_cast.cpp +4 -4
- package/src/duckdb/src/function/cast/union_casts.cpp +6 -6
- package/src/duckdb/src/function/function.cpp +4 -4
- package/src/duckdb/src/function/function_binder.cpp +2 -1
- package/src/duckdb/src/function/macro_function.cpp +3 -3
- package/src/duckdb/src/function/pragma/pragma_queries.cpp +1 -1
- package/src/duckdb/src/function/pragma_function.cpp +1 -1
- package/src/duckdb/src/function/scalar/date/date_part.cpp +1 -1
- package/src/duckdb/src/function/scalar/date/strftime.cpp +6 -6
- package/src/duckdb/src/function/scalar/generic/alias.cpp +1 -1
- package/src/duckdb/src/function/scalar/generic/constant_or_null.cpp +3 -3
- package/src/duckdb/src/function/scalar/generic/current_setting.cpp +2 -2
- package/src/duckdb/src/function/scalar/generic/stats.cpp +3 -3
- package/src/duckdb/src/function/scalar/list/list_aggregates.cpp +5 -5
- package/src/duckdb/src/function/scalar/list/list_lambdas.cpp +3 -3
- package/src/duckdb/src/function/scalar/list/list_sort.cpp +3 -3
- package/src/duckdb/src/function/scalar/math/numeric.cpp +3 -3
- package/src/duckdb/src/function/scalar/math/random.cpp +2 -2
- package/src/duckdb/src/function/scalar/math/setseed.cpp +2 -2
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +2 -2
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +4 -4
- package/src/duckdb/src/function/scalar/string/like.cpp +1 -1
- package/src/duckdb/src/function/scalar/string/regexp/regexp_extract_all.cpp +5 -5
- package/src/duckdb/src/function/scalar/string/regexp.cpp +11 -11
- package/src/duckdb/src/function/scalar/string/string_split.cpp +3 -3
- package/src/duckdb/src/function/scalar/struct/struct_extract.cpp +3 -3
- package/src/duckdb/src/function/scalar/struct/struct_pack.cpp +2 -2
- package/src/duckdb/src/function/scalar/system/aggregate_export.cpp +2 -2
- package/src/duckdb/src/function/scalar/union/union_extract.cpp +2 -2
- package/src/duckdb/src/function/scalar_macro_function.cpp +3 -3
- package/src/duckdb/src/function/table/arrow.cpp +5 -5
- package/src/duckdb/src/function/table/checkpoint.cpp +1 -1
- package/src/duckdb/src/function/table/glob.cpp +1 -1
- package/src/duckdb/src/function/table/pragma_detailed_profiling_output.cpp +1 -1
- package/src/duckdb/src/function/table/pragma_last_profiling_output.cpp +1 -1
- package/src/duckdb/src/function/table/range.cpp +5 -5
- package/src/duckdb/src/function/table/read_csv.cpp +10 -10
- package/src/duckdb/src/function/table/repeat.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +12 -12
- package/src/duckdb/src/function/table/system/duckdb_databases.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_functions.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_indexes.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_sequences.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_tables.cpp +2 -2
- package/src/duckdb/src/function/table/system/duckdb_views.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_storage_info.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +3 -3
- package/src/duckdb/src/function/table/system/test_vector_types.cpp +1 -1
- package/src/duckdb/src/function/table/table_scan.cpp +31 -31
- package/src/duckdb/src/function/table/unnest.cpp +4 -4
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/function/table_macro_function.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +13 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_index_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/duck_table_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +4 -4
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/macro_catalog_entry.hpp +3 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/scalar_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/schema_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/sequence_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/table_macro_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/type_catalog_entry.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/view_catalog_entry.hpp +3 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry.hpp +14 -3
- package/src/duckdb/src/include/duckdb/catalog/catalog_set.hpp +5 -5
- package/src/duckdb/src/include/duckdb/common/case_insensitive_map.hpp +2 -3
- package/src/duckdb/src/include/duckdb/common/enums/logical_operator_type.hpp +1 -0
- package/src/duckdb/src/include/duckdb/common/enums/physical_operator_type.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/multi_file_reader_options.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/string_util.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/index/art/art.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_hash_aggregate.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_perfecthash_aggregate.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_streaming_window.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_window.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/filter/physical_filter.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_execute.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_explain_analyze.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_limit_percent.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_load.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_pragma.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_prepare.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_reset.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_set.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_streaming_limit.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_streaming_sample.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_transaction.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_vacuum.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_blockwise_nl_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_delim_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_iejoin.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_index_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_nested_loop_join.hpp +3 -4
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_piecewise_merge_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_order.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/order/physical_top_n.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_delete.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_export.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_update.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_pivot.hpp +38 -0
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_projection.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_tableinout_function.hpp +4 -2
- package/src/duckdb/src/include/duckdb/execution/operator/projection/physical_unnest.hpp +3 -1
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_dummy_scan.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_empty_result.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_expression_scan.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_positional_scan.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_table_scan.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_alter.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_attach.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_function.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_index.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_schema.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_sequence.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_type.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_view.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_detach.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_drop.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_recursive_cte.hpp +3 -0
- package/src/duckdb/src/include/duckdb/execution/operator/set/physical_union.hpp +4 -0
- package/src/duckdb/src/include/duckdb/execution/physical_operator.hpp +18 -57
- package/src/duckdb/src/include/duckdb/execution/physical_operator_states.hpp +150 -0
- package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +1 -0
- package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +11 -0
- package/src/duckdb/src/include/duckdb/function/copy_function.hpp +22 -0
- package/src/duckdb/src/include/duckdb/function/function.hpp +20 -4
- package/src/duckdb/src/include/duckdb/function/macro_function.hpp +3 -3
- package/src/duckdb/src/include/duckdb/function/pragma_function.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar/nested_functions.hpp +1 -1
- package/src/duckdb/src/include/duckdb/function/scalar_function.hpp +11 -0
- package/src/duckdb/src/include/duckdb/function/scalar_macro_function.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/table_function.hpp +22 -0
- package/src/duckdb/src/include/duckdb/function/table_macro_function.hpp +3 -3
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +3 -2
- package/src/duckdb/src/include/duckdb/main/settings.hpp +10 -0
- package/src/duckdb/src/include/duckdb/optimizer/rule/like_optimizations.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/base_expression.hpp +18 -0
- package/src/duckdb/src/include/duckdb/parser/constraint.hpp +18 -0
- package/src/duckdb/src/include/duckdb/parser/constraints/check_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/constraints/foreign_key_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/constraints/not_null_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/constraints/unique_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/between_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/bound_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/case_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/cast_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/collate_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/columnref_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/comparison_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/conjunction_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/constant_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/default_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/lambda_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/operator_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/parameter_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/positional_reference_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/subquery_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/expression/window_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/list.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/recursive_cte_node.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/select_node.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/query_node/set_operation_node.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/query_node.hpp +18 -0
- package/src/duckdb/src/include/duckdb/parser/sql_statement.hpp +18 -0
- package/src/duckdb/src/include/duckdb/parser/statement/alter_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/attach_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/call_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/copy_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/create_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/delete_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/detach_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/drop_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/execute_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/explain_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/export_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/extension_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/insert_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/parser/statement/load_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/logical_plan_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/multi_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/pragma_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/prepare_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/relation_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/select_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/set_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/show_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/transaction_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/update_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/statement/vacuum_statement.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/basetableref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/emptytableref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/expressionlistref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/joinref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/pivotref.hpp +14 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/subqueryref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref/table_function_ref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/parser/tableref.hpp +17 -0
- package/src/duckdb/src/include/duckdb/planner/bind_context.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/bound_constraint.hpp +18 -0
- package/src/duckdb/src/include/duckdb/planner/bound_query_node.hpp +17 -0
- package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +5 -1
- package/src/duckdb/src/include/duckdb/planner/bound_tableref.hpp +17 -0
- package/src/duckdb/src/include/duckdb/planner/bound_tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/constraints/bound_check_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/constraints/bound_foreign_key_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/constraints/bound_not_null_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/constraints/bound_unique_constraint.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_aggregate_expression.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_between_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_case_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_cast_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_columnref_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_comparison_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_conjunction_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_constant_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_default_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_function_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_lambda_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_lambdaref_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_operator_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_parameter_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_reference_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_subquery_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_unnest_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_window_expression.hpp +4 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/table_function_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/logical_operator.hpp +17 -0
- package/src/duckdb/src/include/duckdb/planner/logical_tokens.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_aggregate.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_any_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_asof_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_comparison_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create_index.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_create_table.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cross_product.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_cteref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delete.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_get.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_delim_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_distinct.hpp +12 -4
- package/src/duckdb/src/include/duckdb/planner/operator/logical_dummy_scan.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_empty_result.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_execute.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_explain.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_export.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_expression_get.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_extension_operator.hpp +4 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_filter.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_get.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_insert.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_limit.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_limit_percent.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_order.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_pivot.hpp +36 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_positional_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_pragma.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_prepare.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_projection.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_recursive_cte.hpp +9 -5
- package/src/duckdb/src/include/duckdb/planner/operator/logical_reset.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_sample.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_set.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_set_operation.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_show.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_simple.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_top_n.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_unconditional_join.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_unnest.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_update.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/operator/logical_window.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/query_node/bound_recursive_cte_node.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/query_node/bound_select_node.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/query_node/bound_set_operation_node.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/query_node/list.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_basetableref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_cteref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_dummytableref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_expressionlistref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_joinref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_pivotref.hpp +43 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_pos_join_ref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_subqueryref.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/bound_table_function.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/tableref/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/index.hpp +15 -2
- package/src/duckdb/src/include/duckdb/storage/write_ahead_log.hpp +17 -17
- package/src/duckdb/src/include/duckdb/transaction/commit_state.hpp +1 -1
- package/src/duckdb/src/main/capi/table_function-c.cpp +9 -9
- package/src/duckdb/src/main/client_context.cpp +1 -1
- package/src/duckdb/src/main/config.cpp +1 -0
- package/src/duckdb/src/main/query_profiler.cpp +2 -2
- package/src/duckdb/src/main/relation/aggregate_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/filter_relation.cpp +1 -1
- package/src/duckdb/src/main/relation/projection_relation.cpp +1 -1
- package/src/duckdb/src/main/relation.cpp +1 -1
- package/src/duckdb/src/main/settings/settings.cpp +17 -1
- package/src/duckdb/src/optimizer/column_lifetime_analyzer.cpp +3 -3
- package/src/duckdb/src/optimizer/common_aggregate_optimizer.cpp +1 -1
- package/src/duckdb/src/optimizer/cse_optimizer.cpp +1 -1
- package/src/duckdb/src/optimizer/deliminator.cpp +11 -11
- package/src/duckdb/src/optimizer/expression_heuristics.cpp +11 -11
- package/src/duckdb/src/optimizer/expression_rewriter.cpp +1 -1
- package/src/duckdb/src/optimizer/filter_combiner.cpp +40 -38
- package/src/duckdb/src/optimizer/filter_pullup.cpp +2 -2
- package/src/duckdb/src/optimizer/filter_pushdown.cpp +1 -1
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +8 -8
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +24 -24
- package/src/duckdb/src/optimizer/matcher/expression_matcher.cpp +12 -12
- package/src/duckdb/src/optimizer/pullup/pullup_filter.cpp +1 -1
- package/src/duckdb/src/optimizer/pullup/pullup_projection.cpp +2 -2
- package/src/duckdb/src/optimizer/pullup/pullup_set_operation.cpp +3 -3
- package/src/duckdb/src/optimizer/pushdown/pushdown_aggregate.cpp +3 -3
- package/src/duckdb/src/optimizer/pushdown/pushdown_filter.cpp +1 -1
- package/src/duckdb/src/optimizer/pushdown/pushdown_get.cpp +1 -1
- package/src/duckdb/src/optimizer/pushdown/pushdown_inner_join.cpp +3 -3
- package/src/duckdb/src/optimizer/pushdown/pushdown_left_join.cpp +3 -3
- package/src/duckdb/src/optimizer/pushdown/pushdown_limit.cpp +1 -1
- package/src/duckdb/src/optimizer/pushdown/pushdown_mark_join.cpp +3 -3
- package/src/duckdb/src/optimizer/pushdown/pushdown_projection.cpp +2 -2
- package/src/duckdb/src/optimizer/pushdown/pushdown_set_operation.cpp +4 -4
- package/src/duckdb/src/optimizer/pushdown/pushdown_single_join.cpp +1 -1
- package/src/duckdb/src/optimizer/regex_range_filter.cpp +2 -2
- package/src/duckdb/src/optimizer/remove_unused_columns.cpp +13 -9
- package/src/duckdb/src/optimizer/rule/arithmetic_simplification.cpp +20 -20
- package/src/duckdb/src/optimizer/rule/case_simplification.cpp +8 -8
- package/src/duckdb/src/optimizer/rule/comparison_simplification.cpp +14 -14
- package/src/duckdb/src/optimizer/rule/conjunction_simplification.cpp +5 -5
- package/src/duckdb/src/optimizer/rule/date_part_simplification.cpp +2 -2
- package/src/duckdb/src/optimizer/rule/distributivity.cpp +16 -16
- package/src/duckdb/src/optimizer/rule/empty_needle_removal.cpp +4 -5
- package/src/duckdb/src/optimizer/rule/enum_comparison.cpp +8 -9
- package/src/duckdb/src/optimizer/rule/in_clause_simplification_rule.cpp +13 -13
- package/src/duckdb/src/optimizer/rule/like_optimizations.cpp +12 -12
- package/src/duckdb/src/optimizer/rule/move_constants.cpp +31 -31
- package/src/duckdb/src/optimizer/rule/ordered_aggregate_optimizer.cpp +4 -4
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +10 -10
- package/src/duckdb/src/optimizer/statistics/operator/propagate_filter.cpp +9 -8
- package/src/duckdb/src/optimizer/statistics/operator/propagate_join.cpp +2 -2
- package/src/duckdb/src/optimizer/statistics_propagator.cpp +31 -20
- package/src/duckdb/src/optimizer/topn_optimizer.cpp +2 -2
- package/src/duckdb/src/optimizer/unnest_rewriter.cpp +13 -13
- package/src/duckdb/src/parser/column_definition.cpp +3 -3
- package/src/duckdb/src/parser/expression/columnref_expression.cpp +2 -5
- package/src/duckdb/src/parser/expression/conjunction_expression.cpp +1 -1
- package/src/duckdb/src/parser/expression/constant_expression.cpp +1 -1
- package/src/duckdb/src/parser/parsed_data/create_view_info.cpp +1 -1
- package/src/duckdb/src/parser/parsed_expression_iterator.cpp +20 -20
- package/src/duckdb/src/parser/parser.cpp +10 -10
- package/src/duckdb/src/parser/query_node/recursive_cte_node.cpp +4 -4
- package/src/duckdb/src/parser/query_node/select_node.cpp +10 -10
- package/src/duckdb/src/parser/query_node/set_operation_node.cpp +4 -4
- package/src/duckdb/src/parser/statement/insert_statement.cpp +1 -1
- package/src/duckdb/src/parser/statement/select_statement.cpp +2 -2
- package/src/duckdb/src/parser/transform/expression/transform_array_access.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +3 -3
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +2 -42
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +1 -1
- package/src/duckdb/src/parser/transform/helpers/transform_groupby.cpp +1 -1
- package/src/duckdb/src/parser/transform/statement/transform_create_type.cpp +0 -1
- package/src/duckdb/src/parser/transform/statement/transform_pivot_stmt.cpp +5 -2
- package/src/duckdb/src/parser/transform/statement/transform_pragma.cpp +5 -5
- package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +20 -20
- package/src/duckdb/src/parser/transform/tableref/transform_pivot.cpp +3 -3
- package/src/duckdb/src/planner/bind_context.cpp +11 -0
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +47 -4
- package/src/duckdb/src/planner/binder/expression/bind_function_expression.cpp +5 -6
- package/src/duckdb/src/planner/binder/expression/bind_lambda.cpp +2 -2
- package/src/duckdb/src/planner/binder/expression/bind_macro_expression.cpp +3 -3
- package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +8 -8
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +23 -29
- package/src/duckdb/src/planner/binder/query_node/bind_setop_node.cpp +2 -2
- package/src/duckdb/src/planner/binder/query_node/bind_table_macro_node.cpp +1 -1
- package/src/duckdb/src/planner/binder/query_node/plan_query_node.cpp +3 -3
- package/src/duckdb/src/planner/binder/query_node/plan_recursive_cte_node.cpp +2 -3
- package/src/duckdb/src/planner/binder/query_node/plan_select_node.cpp +0 -2
- package/src/duckdb/src/planner/binder/query_node/plan_subquery.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_call.cpp +3 -2
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +17 -16
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +7 -6
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +3 -2
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_extension.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_set.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +2 -1
- package/src/duckdb/src/planner/binder/statement/bind_vacuum.cpp +2 -2
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +4 -3
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +303 -78
- package/src/duckdb/src/planner/binder/tableref/bind_subqueryref.cpp +4 -4
- package/src/duckdb/src/planner/binder/tableref/bind_table_function.cpp +10 -10
- package/src/duckdb/src/planner/binder/tableref/plan_joinref.cpp +6 -6
- package/src/duckdb/src/planner/binder/tableref/plan_pivotref.cpp +13 -0
- package/src/duckdb/src/planner/binder.cpp +52 -48
- package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +8 -8
- package/src/duckdb/src/planner/expression/bound_between_expression.cpp +5 -5
- package/src/duckdb/src/planner/expression/bound_case_expression.cpp +1 -1
- package/src/duckdb/src/planner/expression/bound_cast_expression.cpp +5 -5
- package/src/duckdb/src/planner/expression/bound_columnref_expression.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_comparison_expression.cpp +3 -4
- package/src/duckdb/src/planner/expression/bound_conjunction_expression.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_constant_expression.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_function_expression.cpp +4 -4
- package/src/duckdb/src/planner/expression/bound_lambda_expression.cpp +4 -4
- package/src/duckdb/src/planner/expression/bound_lambdaref_expression.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_operator_expression.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_parameter_expression.cpp +3 -3
- package/src/duckdb/src/planner/expression/bound_reference_expression.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_unnest_expression.cpp +2 -2
- package/src/duckdb/src/planner/expression/bound_window_expression.cpp +16 -16
- package/src/duckdb/src/planner/expression_binder/alter_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/check_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/constant_binder.cpp +11 -1
- package/src/duckdb/src/planner/expression_binder/group_binder.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/index_binder.cpp +1 -1
- package/src/duckdb/src/planner/expression_binder/lateral_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/order_binder.cpp +3 -3
- package/src/duckdb/src/planner/expression_binder/qualify_binder.cpp +2 -1
- package/src/duckdb/src/planner/expression_binder/table_function_binder.cpp +7 -3
- package/src/duckdb/src/planner/expression_binder.cpp +24 -32
- package/src/duckdb/src/planner/expression_iterator.cpp +17 -17
- package/src/duckdb/src/planner/joinside.cpp +2 -2
- package/src/duckdb/src/planner/logical_operator.cpp +3 -0
- package/src/duckdb/src/planner/logical_operator_visitor.cpp +26 -26
- package/src/duckdb/src/planner/operator/logical_distinct.cpp +3 -1
- package/src/duckdb/src/planner/operator/logical_filter.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_join.cpp +1 -1
- package/src/duckdb/src/planner/operator/logical_pivot.cpp +35 -0
- package/src/duckdb/src/planner/operator/logical_recursive_cte.cpp +1 -1
- package/src/duckdb/src/planner/pragma_handler.cpp +2 -2
- package/src/duckdb/src/planner/subquery/flatten_dependent_join.cpp +25 -23
- package/src/duckdb/src/planner/subquery/rewrite_correlated_expressions.cpp +2 -2
- package/src/duckdb/src/planner/table_binding.cpp +8 -8
- package/src/duckdb/src/storage/checkpoint/table_data_writer.cpp +1 -1
- package/src/duckdb/src/storage/data_table.cpp +2 -1
- package/src/duckdb/src/storage/index.cpp +4 -5
- package/src/duckdb/src/storage/local_storage.cpp +2 -1
- package/src/duckdb/src/storage/table/row_group_collection.cpp +1 -1
- package/src/duckdb/src/storage/write_ahead_log.cpp +42 -42
- package/src/duckdb/src/transaction/commit_state.cpp +35 -35
- package/src/duckdb/src/transaction/duck_transaction.cpp +1 -1
- package/src/duckdb/src/transaction/rollback_state.cpp +1 -1
- package/src/duckdb/src/verification/deserialized_statement_verifier.cpp +1 -1
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +773 -793
- package/src/duckdb/third_party/libpg_query/include/parser/kwlist.hpp +1 -11
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +17408 -17751
- package/src/duckdb/ub_extension_icu_third_party_icu_i18n.cpp +5 -5
- package/src/duckdb/ub_src_execution_operator_projection.cpp +2 -0
- package/src/duckdb/ub_src_execution_physical_plan.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_tableref.cpp +2 -0
- package/src/duckdb/ub_src_planner_operator.cpp +2 -0
@@ -3,6 +3,7 @@
|
|
3
3
|
#include "duckdb/parser/tableref/subqueryref.hpp"
|
4
4
|
#include "duckdb/parser/query_node/select_node.hpp"
|
5
5
|
#include "duckdb/parser/expression/case_expression.hpp"
|
6
|
+
#include "duckdb/parser/expression/cast_expression.hpp"
|
6
7
|
#include "duckdb/parser/expression/columnref_expression.hpp"
|
7
8
|
#include "duckdb/parser/expression/comparison_expression.hpp"
|
8
9
|
#include "duckdb/parser/expression/conjunction_expression.hpp"
|
@@ -14,30 +15,23 @@
|
|
14
15
|
#include "duckdb/parser/parsed_expression_iterator.hpp"
|
15
16
|
#include "duckdb/parser/expression/operator_expression.hpp"
|
16
17
|
#include "duckdb/planner/tableref/bound_subqueryref.hpp"
|
18
|
+
#include "duckdb/planner/tableref/bound_pivotref.hpp"
|
19
|
+
#include "duckdb/planner/expression/bound_aggregate_expression.hpp"
|
20
|
+
#include "duckdb/main/client_config.hpp"
|
17
21
|
|
18
22
|
namespace duckdb {
|
19
23
|
|
20
|
-
static void ConstructPivots(PivotRef &ref, idx_t pivot_idx
|
21
|
-
|
22
|
-
const string ¤t_name = string()) {
|
24
|
+
static void ConstructPivots(PivotRef &ref, vector<PivotValueElement> &pivot_values, idx_t pivot_idx = 0,
|
25
|
+
const PivotValueElement ¤t_value = PivotValueElement()) {
|
23
26
|
auto &pivot = ref.pivots[pivot_idx];
|
24
27
|
bool last_pivot = pivot_idx + 1 == ref.pivots.size();
|
25
28
|
for (auto &entry : pivot.entries) {
|
26
|
-
|
29
|
+
PivotValueElement new_value = current_value;
|
27
30
|
string name = entry.alias;
|
28
31
|
D_ASSERT(entry.values.size() == pivot.pivot_expressions.size());
|
29
32
|
for (idx_t v = 0; v < entry.values.size(); v++) {
|
30
33
|
auto &value = entry.values[v];
|
31
|
-
|
32
|
-
auto constant_value = make_uniq<ConstantExpression>(value);
|
33
|
-
auto comp_expr = make_uniq<ComparisonExpression>(ExpressionType::COMPARE_NOT_DISTINCT_FROM,
|
34
|
-
std::move(column_ref), std::move(constant_value));
|
35
|
-
if (expr) {
|
36
|
-
expr = make_uniq<ConjunctionExpression>(ExpressionType::CONJUNCTION_AND, std::move(expr),
|
37
|
-
std::move(comp_expr));
|
38
|
-
} else {
|
39
|
-
expr = std::move(comp_expr);
|
40
|
-
}
|
34
|
+
new_value.values.push_back(value);
|
41
35
|
if (entry.alias.empty()) {
|
42
36
|
if (name.empty()) {
|
43
37
|
name = value.ToString();
|
@@ -46,34 +40,23 @@ static void ConstructPivots(PivotRef &ref, idx_t pivot_idx, vector<unique_ptr<Pa
|
|
46
40
|
}
|
47
41
|
}
|
48
42
|
}
|
49
|
-
if (!
|
50
|
-
name =
|
43
|
+
if (!current_value.name.empty()) {
|
44
|
+
new_value.name = current_value.name + "_" + name;
|
45
|
+
} else {
|
46
|
+
new_value.name = std::move(name);
|
51
47
|
}
|
52
48
|
if (last_pivot) {
|
53
|
-
|
54
|
-
for (auto &aggr : ref.aggregates) {
|
55
|
-
auto copy = aggr->Copy();
|
56
|
-
auto &function = (FunctionExpression &)*copy;
|
57
|
-
// add the filter and alias to the aggregate function
|
58
|
-
function.filter = expr->Copy();
|
59
|
-
if (ref.aggregates.size() > 1 || !function.alias.empty()) {
|
60
|
-
// if there are multiple aggregates specified we add the name of the aggregate as well
|
61
|
-
function.alias = name + "_" + function.GetName();
|
62
|
-
} else {
|
63
|
-
function.alias = name;
|
64
|
-
}
|
65
|
-
pivot_expressions.push_back(std::move(copy));
|
66
|
-
}
|
49
|
+
pivot_values.push_back(std::move(new_value));
|
67
50
|
} else {
|
68
51
|
// need to recurse
|
69
|
-
ConstructPivots(ref, pivot_idx + 1,
|
52
|
+
ConstructPivots(ref, pivot_values, pivot_idx + 1, new_value);
|
70
53
|
}
|
71
54
|
}
|
72
55
|
}
|
73
56
|
|
74
57
|
static void ExtractPivotExpressions(ParsedExpression &expr, case_insensitive_set_t &handled_columns) {
|
75
58
|
if (expr.type == ExpressionType::COLUMN_REF) {
|
76
|
-
auto &child_colref = (
|
59
|
+
auto &child_colref = expr.Cast<ColumnRefExpression>();
|
77
60
|
if (child_colref.IsQualified()) {
|
78
61
|
throw BinderException("PIVOT expression cannot contain qualified columns");
|
79
62
|
}
|
@@ -83,8 +66,237 @@ static void ExtractPivotExpressions(ParsedExpression &expr, case_insensitive_set
|
|
83
66
|
expr, [&](ParsedExpression &child) { ExtractPivotExpressions(child, handled_columns); });
|
84
67
|
}
|
85
68
|
|
69
|
+
struct PivotBindState {
|
70
|
+
vector<string> internal_group_names;
|
71
|
+
vector<string> group_names;
|
72
|
+
vector<string> aggregate_names;
|
73
|
+
vector<string> internal_aggregate_names;
|
74
|
+
};
|
75
|
+
|
76
|
+
static unique_ptr<SelectNode> PivotInitialAggregate(PivotBindState &bind_state, PivotRef &ref,
|
77
|
+
vector<unique_ptr<ParsedExpression>> all_columns,
|
78
|
+
const case_insensitive_set_t &handled_columns) {
|
79
|
+
auto subquery_stage1 = make_uniq<SelectNode>();
|
80
|
+
subquery_stage1->from_table = std::move(ref.source);
|
81
|
+
if (ref.groups.empty()) {
|
82
|
+
// if rows are not specified any columns that are not pivoted/aggregated on are added to the GROUP BY clause
|
83
|
+
for (auto &entry : all_columns) {
|
84
|
+
if (entry->type != ExpressionType::COLUMN_REF) {
|
85
|
+
throw InternalException("Unexpected child of pivot source - not a ColumnRef");
|
86
|
+
}
|
87
|
+
auto &columnref = (ColumnRefExpression &)*entry;
|
88
|
+
if (handled_columns.find(columnref.GetColumnName()) == handled_columns.end()) {
|
89
|
+
// not handled - add to grouping set
|
90
|
+
subquery_stage1->groups.group_expressions.push_back(
|
91
|
+
make_uniq<ConstantExpression>(Value::INTEGER(subquery_stage1->select_list.size() + 1)));
|
92
|
+
subquery_stage1->select_list.push_back(make_uniq<ColumnRefExpression>(columnref.GetColumnName()));
|
93
|
+
}
|
94
|
+
}
|
95
|
+
} else {
|
96
|
+
// if rows are specified only the columns mentioned in rows are added as groups
|
97
|
+
for (auto &row : ref.groups) {
|
98
|
+
subquery_stage1->groups.group_expressions.push_back(
|
99
|
+
make_uniq<ConstantExpression>(Value::INTEGER(subquery_stage1->select_list.size() + 1)));
|
100
|
+
subquery_stage1->select_list.push_back(make_uniq<ColumnRefExpression>(row));
|
101
|
+
}
|
102
|
+
}
|
103
|
+
idx_t group_count = 0;
|
104
|
+
for (auto &expr : subquery_stage1->select_list) {
|
105
|
+
bind_state.group_names.push_back(expr->GetName());
|
106
|
+
if (expr->alias.empty()) {
|
107
|
+
expr->alias = "__internal_pivot_group" + std::to_string(++group_count);
|
108
|
+
}
|
109
|
+
bind_state.internal_group_names.push_back(expr->alias);
|
110
|
+
}
|
111
|
+
// group by all of the pivot values
|
112
|
+
idx_t pivot_count = 0;
|
113
|
+
for (auto &pivot_column : ref.pivots) {
|
114
|
+
for (auto &pivot_expr : pivot_column.pivot_expressions) {
|
115
|
+
if (pivot_expr->alias.empty()) {
|
116
|
+
pivot_expr->alias = "__internal_pivot_ref" + std::to_string(++pivot_count);
|
117
|
+
}
|
118
|
+
auto pivot_alias = pivot_expr->alias;
|
119
|
+
subquery_stage1->groups.group_expressions.push_back(
|
120
|
+
make_uniq<ConstantExpression>(Value::INTEGER(subquery_stage1->select_list.size() + 1)));
|
121
|
+
subquery_stage1->select_list.push_back(std::move(pivot_expr));
|
122
|
+
pivot_expr = make_uniq<ColumnRefExpression>(std::move(pivot_alias));
|
123
|
+
}
|
124
|
+
}
|
125
|
+
idx_t aggregate_count = 0;
|
126
|
+
// finally add the aggregates
|
127
|
+
for (auto &aggregate : ref.aggregates) {
|
128
|
+
auto aggregate_alias = "__internal_pivot_aggregate" + std::to_string(++aggregate_count);
|
129
|
+
bind_state.aggregate_names.push_back(aggregate->alias);
|
130
|
+
bind_state.internal_aggregate_names.push_back(aggregate_alias);
|
131
|
+
aggregate->alias = std::move(aggregate_alias);
|
132
|
+
subquery_stage1->select_list.push_back(std::move(aggregate));
|
133
|
+
}
|
134
|
+
return subquery_stage1;
|
135
|
+
}
|
136
|
+
|
137
|
+
static unique_ptr<SelectNode> PivotListAggregate(PivotBindState &bind_state, PivotRef &ref,
|
138
|
+
unique_ptr<SelectNode> subquery_stage1) {
|
139
|
+
auto subquery_stage2 = make_uniq<SelectNode>();
|
140
|
+
// wrap the subquery of stage 1
|
141
|
+
auto subquery_select = make_uniq<SelectStatement>();
|
142
|
+
subquery_select->node = std::move(subquery_stage1);
|
143
|
+
auto subquery_ref = make_uniq<SubqueryRef>(std::move(subquery_select));
|
144
|
+
|
145
|
+
// add all of the groups
|
146
|
+
for (idx_t gr = 0; gr < bind_state.internal_group_names.size(); gr++) {
|
147
|
+
subquery_stage2->groups.group_expressions.push_back(
|
148
|
+
make_uniq<ConstantExpression>(Value::INTEGER(subquery_stage2->select_list.size() + 1)));
|
149
|
+
auto group_reference = make_uniq<ColumnRefExpression>(bind_state.internal_group_names[gr]);
|
150
|
+
group_reference->alias = bind_state.internal_group_names[gr];
|
151
|
+
subquery_stage2->select_list.push_back(std::move(group_reference));
|
152
|
+
}
|
153
|
+
|
154
|
+
// construct the list aggregates
|
155
|
+
for (idx_t aggr = 0; aggr < bind_state.internal_aggregate_names.size(); aggr++) {
|
156
|
+
auto colref = make_uniq<ColumnRefExpression>(bind_state.internal_aggregate_names[aggr]);
|
157
|
+
vector<unique_ptr<ParsedExpression>> list_children;
|
158
|
+
list_children.push_back(std::move(colref));
|
159
|
+
auto aggregate = make_uniq<FunctionExpression>("list", std::move(list_children));
|
160
|
+
aggregate->alias = bind_state.internal_aggregate_names[aggr];
|
161
|
+
subquery_stage2->select_list.push_back(std::move(aggregate));
|
162
|
+
}
|
163
|
+
// construct the pivot list
|
164
|
+
auto pivot_name = "__internal_pivot_name";
|
165
|
+
unique_ptr<ParsedExpression> expr;
|
166
|
+
for (auto &pivot : ref.pivots) {
|
167
|
+
for (auto &pivot_expr : pivot.pivot_expressions) {
|
168
|
+
// coalesce(pivot::VARCHAR, 'NULL')
|
169
|
+
auto cast = make_uniq<CastExpression>(LogicalType::VARCHAR, std::move(pivot_expr));
|
170
|
+
vector<unique_ptr<ParsedExpression>> coalesce_children;
|
171
|
+
coalesce_children.push_back(std::move(cast));
|
172
|
+
coalesce_children.push_back(make_uniq<ConstantExpression>(Value("NULL")));
|
173
|
+
auto coalesce =
|
174
|
+
make_uniq<OperatorExpression>(ExpressionType::OPERATOR_COALESCE, std::move(coalesce_children));
|
175
|
+
|
176
|
+
if (!expr) {
|
177
|
+
expr = std::move(coalesce);
|
178
|
+
} else {
|
179
|
+
// string concat
|
180
|
+
vector<unique_ptr<ParsedExpression>> concat_children;
|
181
|
+
concat_children.push_back(std::move(expr));
|
182
|
+
concat_children.push_back(make_uniq<ConstantExpression>(Value("_")));
|
183
|
+
concat_children.push_back(std::move(coalesce));
|
184
|
+
auto concat = make_uniq<FunctionExpression>("concat", std::move(concat_children));
|
185
|
+
expr = std::move(concat);
|
186
|
+
}
|
187
|
+
}
|
188
|
+
}
|
189
|
+
// list(coalesce)
|
190
|
+
vector<unique_ptr<ParsedExpression>> list_children;
|
191
|
+
list_children.push_back(std::move(expr));
|
192
|
+
auto aggregate = make_uniq<FunctionExpression>("list", std::move(list_children));
|
193
|
+
|
194
|
+
aggregate->alias = pivot_name;
|
195
|
+
subquery_stage2->select_list.push_back(std::move(aggregate));
|
196
|
+
|
197
|
+
subquery_stage2->from_table = std::move(subquery_ref);
|
198
|
+
return subquery_stage2;
|
199
|
+
}
|
200
|
+
|
201
|
+
static unique_ptr<SelectNode> PivotFinalOperator(PivotBindState &bind_state, PivotRef &ref,
|
202
|
+
unique_ptr<SelectNode> subquery,
|
203
|
+
vector<PivotValueElement> pivot_values) {
|
204
|
+
auto final_pivot_operator = make_uniq<SelectNode>();
|
205
|
+
// wrap the subquery of stage 1
|
206
|
+
auto subquery_select = make_uniq<SelectStatement>();
|
207
|
+
subquery_select->node = std::move(subquery);
|
208
|
+
auto subquery_ref = make_uniq<SubqueryRef>(std::move(subquery_select));
|
209
|
+
|
210
|
+
auto bound_pivot = make_uniq<PivotRef>();
|
211
|
+
bound_pivot->bound_pivot_values = std::move(pivot_values);
|
212
|
+
bound_pivot->bound_group_names = std::move(bind_state.group_names);
|
213
|
+
bound_pivot->bound_aggregate_names = std::move(bind_state.aggregate_names);
|
214
|
+
bound_pivot->source = std::move(subquery_ref);
|
215
|
+
|
216
|
+
final_pivot_operator->select_list.push_back(make_uniq<StarExpression>());
|
217
|
+
final_pivot_operator->from_table = std::move(bound_pivot);
|
218
|
+
return final_pivot_operator;
|
219
|
+
}
|
220
|
+
|
221
|
+
void ExtractPivotAggregates(BoundTableRef &node, vector<unique_ptr<Expression>> &aggregates) {
|
222
|
+
if (node.type != TableReferenceType::SUBQUERY) {
|
223
|
+
throw InternalException("Pivot - Expected a subquery");
|
224
|
+
}
|
225
|
+
auto &subq = node.Cast<BoundSubqueryRef>();
|
226
|
+
if (subq.subquery->type != QueryNodeType::SELECT_NODE) {
|
227
|
+
throw InternalException("Pivot - Expected a select node");
|
228
|
+
}
|
229
|
+
auto &select = subq.subquery->Cast<BoundSelectNode>();
|
230
|
+
if (select.from_table->type != TableReferenceType::SUBQUERY) {
|
231
|
+
throw InternalException("Pivot - Expected another subquery");
|
232
|
+
}
|
233
|
+
auto &subq2 = select.from_table->Cast<BoundSubqueryRef>();
|
234
|
+
if (subq2.subquery->type != QueryNodeType::SELECT_NODE) {
|
235
|
+
throw InternalException("Pivot - Expected another select node");
|
236
|
+
}
|
237
|
+
auto &select2 = subq2.subquery->Cast<BoundSelectNode>();
|
238
|
+
for (auto &aggr : select2.aggregates) {
|
239
|
+
aggregates.push_back(aggr->Copy());
|
240
|
+
}
|
241
|
+
}
|
242
|
+
|
243
|
+
unique_ptr<BoundTableRef> Binder::BindBoundPivot(PivotRef &ref) {
|
244
|
+
// bind the child table in a child binder
|
245
|
+
auto result = make_uniq<BoundPivotRef>();
|
246
|
+
result->bind_index = GenerateTableIndex();
|
247
|
+
result->child_binder = Binder::CreateBinder(context, this);
|
248
|
+
result->child = result->child_binder->Bind(*ref.source);
|
249
|
+
|
250
|
+
auto &aggregates = result->bound_pivot.aggregates;
|
251
|
+
ExtractPivotAggregates(*result->child, aggregates);
|
252
|
+
if (aggregates.size() != ref.bound_aggregate_names.size()) {
|
253
|
+
throw InternalException("Pivot - aggregate count mismatch");
|
254
|
+
}
|
255
|
+
|
256
|
+
vector<string> child_names;
|
257
|
+
vector<LogicalType> child_types;
|
258
|
+
result->child_binder->bind_context.GetTypesAndNames(child_names, child_types);
|
259
|
+
|
260
|
+
vector<string> names;
|
261
|
+
vector<LogicalType> types;
|
262
|
+
// emit the groups
|
263
|
+
for (idx_t i = 0; i < ref.bound_group_names.size(); i++) {
|
264
|
+
names.push_back(ref.bound_group_names[i]);
|
265
|
+
types.push_back(child_types[i]);
|
266
|
+
}
|
267
|
+
// emit the pivot columns
|
268
|
+
for (auto &pivot_value : ref.bound_pivot_values) {
|
269
|
+
for (idx_t aggr_idx = 0; aggr_idx < ref.bound_aggregate_names.size(); aggr_idx++) {
|
270
|
+
auto &aggr = aggregates[aggr_idx];
|
271
|
+
auto &aggr_name = ref.bound_aggregate_names[aggr_idx];
|
272
|
+
auto name = pivot_value.name;
|
273
|
+
if (aggregates.size() > 1 || !aggr_name.empty()) {
|
274
|
+
// if there are multiple aggregates specified we add the name of the aggregate as well
|
275
|
+
name += "_" + (aggr_name.empty() ? aggr->GetName() : aggr_name);
|
276
|
+
}
|
277
|
+
string pivot_str;
|
278
|
+
for (auto &value : pivot_value.values) {
|
279
|
+
auto str = value.ToString();
|
280
|
+
if (pivot_str.empty()) {
|
281
|
+
pivot_str = std::move(str);
|
282
|
+
} else {
|
283
|
+
pivot_str += "_" + str;
|
284
|
+
}
|
285
|
+
}
|
286
|
+
result->bound_pivot.pivot_values.push_back(std::move(pivot_str));
|
287
|
+
names.push_back(std::move(name));
|
288
|
+
types.push_back(aggr->return_type);
|
289
|
+
}
|
290
|
+
}
|
291
|
+
result->bound_pivot.group_count = ref.bound_group_names.size();
|
292
|
+
result->bound_pivot.types = types;
|
293
|
+
auto subquery_alias = ref.alias.empty() ? "__unnamed_pivot" : ref.alias;
|
294
|
+
bind_context.AddGenericBinding(result->bind_index, subquery_alias, names, types);
|
295
|
+
MoveCorrelatedExpressions(*result->child_binder);
|
296
|
+
return std::move(result);
|
297
|
+
}
|
298
|
+
|
86
299
|
unique_ptr<SelectNode> Binder::BindPivot(PivotRef &ref, vector<unique_ptr<ParsedExpression>> all_columns) {
|
87
|
-
const static idx_t PIVOT_EXPRESSION_LIMIT = 10000;
|
88
300
|
// keep track of the columns by which we pivot/aggregate
|
89
301
|
// any columns which are not pivoted/aggregated on are added to the GROUP BY clause
|
90
302
|
case_insensitive_set_t handled_columns;
|
@@ -103,8 +315,6 @@ unique_ptr<SelectNode> Binder::BindPivot(PivotRef &ref, vector<unique_ptr<Parsed
|
|
103
315
|
}
|
104
316
|
value_set_t pivots;
|
105
317
|
|
106
|
-
// now handle the pivots
|
107
|
-
auto select_node = make_uniq<SelectNode>();
|
108
318
|
// first add all pivots to the set of handled columns, and check for duplicates
|
109
319
|
idx_t total_pivots = 1;
|
110
320
|
for (auto &pivot : ref.pivots) {
|
@@ -150,42 +360,41 @@ unique_ptr<SelectNode> Binder::BindPivot(PivotRef &ref, vector<unique_ptr<Parsed
|
|
150
360
|
pivots.insert(val);
|
151
361
|
}
|
152
362
|
}
|
153
|
-
|
154
|
-
|
363
|
+
auto pivot_limit = ClientConfig::GetConfig(context).pivot_limit;
|
364
|
+
if (total_pivots >= pivot_limit) {
|
365
|
+
throw BinderException("Pivot column limit of %llu exceeded. Use SET pivot_limit=X to increase the limit.",
|
366
|
+
ClientConfig::GetConfig(context).pivot_limit);
|
155
367
|
}
|
156
|
-
// now construct the actual aggregates
|
157
|
-
// note that we construct a cross-product of all pivots
|
158
|
-
// we do this recursively
|
159
|
-
vector<unique_ptr<ParsedExpression>> pivot_expressions;
|
160
|
-
ConstructPivots(ref, 0, pivot_expressions);
|
161
368
|
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
//
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
369
|
+
// construct the required pivot values recursively
|
370
|
+
vector<PivotValueElement> pivot_values;
|
371
|
+
ConstructPivots(ref, pivot_values);
|
372
|
+
|
373
|
+
// pivots have three components
|
374
|
+
// - the pivots (i.e. future column names)
|
375
|
+
// - the groups (i.e. the future row names
|
376
|
+
// - the aggregates (i.e. the values of the pivot columns)
|
377
|
+
|
378
|
+
// executing a pivot statement happens in three stages
|
379
|
+
// 1) execute the query "SELECT {groups}, {pivots}, {aggregates} FROM {from_clause} GROUP BY {groups}, {pivots}
|
380
|
+
// this computes all values that are required in the final result, but not yet in the correct orientation
|
381
|
+
// 2) execute the query "SELECT {groups}, LIST({pivots}), LIST({aggregates}) FROM [Q1] GROUP BY {groups}
|
382
|
+
// this pushes all pivots and aggregates that belong to a specific group together in an aligned manner
|
383
|
+
// 3) push a PIVOT operator, that performs the actual pivoting of the values into the different columns
|
384
|
+
|
385
|
+
PivotBindState bind_state;
|
386
|
+
// Pivot Stage 1
|
387
|
+
// SELECT {groups}, {pivots}, {aggregates} FROM {from_clause} GROUP BY {groups}, {pivots}
|
388
|
+
auto subquery_stage1 = PivotInitialAggregate(bind_state, ref, std::move(all_columns), handled_columns);
|
389
|
+
|
390
|
+
// Pivot stage 2
|
391
|
+
// SELECT {groups}, LIST({pivots}), LIST({aggregates}) FROM [Q1] GROUP BY {groups}
|
392
|
+
auto subquery_stage2 = PivotListAggregate(bind_state, ref, std::move(subquery_stage1));
|
393
|
+
|
394
|
+
// Pivot stage 3
|
395
|
+
// construct the final pivot operator
|
396
|
+
auto pivot_node = PivotFinalOperator(bind_state, ref, std::move(subquery_stage2), std::move(pivot_values));
|
397
|
+
return pivot_node;
|
189
398
|
}
|
190
399
|
|
191
400
|
unique_ptr<SelectNode> Binder::BindUnpivot(Binder &child_binder, PivotRef &ref,
|
@@ -196,6 +405,7 @@ unique_ptr<SelectNode> Binder::BindUnpivot(Binder &child_binder, PivotRef &ref,
|
|
196
405
|
|
197
406
|
unique_ptr<ParsedExpression> expr;
|
198
407
|
auto select_node = make_uniq<SelectNode>();
|
408
|
+
select_node->from_table = std::move(ref.source);
|
199
409
|
|
200
410
|
// handle the pivot
|
201
411
|
auto &unpivot = ref.pivots[0];
|
@@ -212,7 +422,7 @@ unique_ptr<SelectNode> Binder::BindUnpivot(Binder &child_binder, PivotRef &ref,
|
|
212
422
|
if (col->type != ExpressionType::COLUMN_REF) {
|
213
423
|
throw InternalException("Unexpected child of unpivot star - not a ColumnRef");
|
214
424
|
}
|
215
|
-
auto &columnref = (
|
425
|
+
auto &columnref = col->Cast<ColumnRefExpression>();
|
216
426
|
PivotColumnEntry new_entry;
|
217
427
|
new_entry.values.emplace_back(columnref.GetColumnName());
|
218
428
|
new_entry.alias = columnref.GetColumnName();
|
@@ -236,7 +446,7 @@ unique_ptr<SelectNode> Binder::BindUnpivot(Binder &child_binder, PivotRef &ref,
|
|
236
446
|
if (col_expr->type != ExpressionType::COLUMN_REF) {
|
237
447
|
throw InternalException("Unexpected child of pivot source - not a ColumnRef");
|
238
448
|
}
|
239
|
-
auto &columnref = (
|
449
|
+
auto &columnref = col_expr->Cast<ColumnRefExpression>();
|
240
450
|
auto &column_name = columnref.GetColumnName();
|
241
451
|
auto entry = handled_columns.find(column_name);
|
242
452
|
if (entry == handled_columns.end()) {
|
@@ -269,6 +479,14 @@ unique_ptr<SelectNode> Binder::BindUnpivot(Binder &child_binder, PivotRef &ref,
|
|
269
479
|
unpivot_names.emplace_back(!entry.alias.empty() ? entry.alias : generated_name);
|
270
480
|
}
|
271
481
|
vector<vector<unique_ptr<ParsedExpression>>> unpivot_expressions;
|
482
|
+
for (idx_t v_idx = 1; v_idx < unpivot.entries.size(); v_idx++) {
|
483
|
+
if (unpivot.entries[v_idx].values.size() != unpivot.entries[0].values.size()) {
|
484
|
+
throw BinderException(
|
485
|
+
"UNPIVOT value count mismatch - entry has %llu values, but expected all entries to have %llu values",
|
486
|
+
unpivot.entries[v_idx].values.size(), unpivot.entries[0].values.size());
|
487
|
+
}
|
488
|
+
}
|
489
|
+
|
272
490
|
for (idx_t v_idx = 0; v_idx < unpivot.entries[0].values.size(); v_idx++) {
|
273
491
|
vector<unique_ptr<ParsedExpression>> expressions;
|
274
492
|
expressions.reserve(unpivot.entries.size());
|
@@ -319,32 +537,39 @@ unique_ptr<BoundTableRef> Binder::Bind(PivotRef &ref) {
|
|
319
537
|
if (!ref.source) {
|
320
538
|
throw InternalException("Pivot without a source!?");
|
321
539
|
}
|
540
|
+
if (!ref.bound_pivot_values.empty() || !ref.bound_group_names.empty() || !ref.bound_aggregate_names.empty()) {
|
541
|
+
// bound pivot
|
542
|
+
return BindBoundPivot(ref);
|
543
|
+
}
|
322
544
|
|
323
545
|
// bind the source of the pivot
|
324
|
-
|
325
|
-
auto
|
546
|
+
// we need to do this to be able to expand star expressions
|
547
|
+
auto copied_source = ref.source->Copy();
|
548
|
+
auto star_binder = Binder::CreateBinder(context, this);
|
549
|
+
star_binder->Bind(*copied_source);
|
326
550
|
|
327
551
|
// figure out the set of column names that are in the source of the pivot
|
328
552
|
vector<unique_ptr<ParsedExpression>> all_columns;
|
329
|
-
|
553
|
+
star_binder->ExpandStarExpression(make_uniq<StarExpression>(), all_columns);
|
330
554
|
|
331
555
|
unique_ptr<SelectNode> select_node;
|
332
556
|
unique_ptr<ParsedExpression> where_clause;
|
333
557
|
if (!ref.aggregates.empty()) {
|
334
558
|
select_node = BindPivot(ref, std::move(all_columns));
|
335
559
|
} else {
|
336
|
-
select_node = BindUnpivot(*
|
560
|
+
select_node = BindUnpivot(*star_binder, ref, std::move(all_columns), where_clause);
|
337
561
|
}
|
338
562
|
// bind the generated select node
|
339
|
-
auto
|
563
|
+
auto child_binder = Binder::CreateBinder(context, this);
|
564
|
+
auto bound_select_node = child_binder->BindNode(*select_node);
|
340
565
|
auto root_index = bound_select_node->GetRootIndex();
|
341
566
|
BoundQueryNode *bound_select_ptr = bound_select_node.get();
|
342
567
|
|
343
568
|
unique_ptr<BoundTableRef> result;
|
344
569
|
MoveCorrelatedExpressions(*child_binder);
|
345
570
|
result = make_uniq<BoundSubqueryRef>(std::move(child_binder), std::move(bound_select_node));
|
346
|
-
auto
|
347
|
-
SubqueryRef subquery_ref(nullptr,
|
571
|
+
auto subquery_alias = ref.alias.empty() ? "__unnamed_pivot" : ref.alias;
|
572
|
+
SubqueryRef subquery_ref(nullptr, subquery_alias);
|
348
573
|
subquery_ref.column_name_alias = std::move(ref.column_name_alias);
|
349
574
|
if (where_clause) {
|
350
575
|
// if a WHERE clause was provided - bind a subquery holding the WHERE clause
|
@@ -13,14 +13,14 @@ unique_ptr<BoundTableRef> Binder::Bind(SubqueryRef &ref, CommonTableExpressionIn
|
|
13
13
|
binder->alias = ref.alias.empty() ? "unnamed_subquery" : ref.alias;
|
14
14
|
auto subquery = binder->BindNode(*ref.subquery->node);
|
15
15
|
idx_t bind_index = subquery->GetRootIndex();
|
16
|
-
string
|
16
|
+
string subquery_alias;
|
17
17
|
if (ref.alias.empty()) {
|
18
|
-
|
18
|
+
subquery_alias = "unnamed_subquery" + to_string(bind_index);
|
19
19
|
} else {
|
20
|
-
|
20
|
+
subquery_alias = ref.alias;
|
21
21
|
}
|
22
22
|
auto result = make_uniq<BoundSubqueryRef>(std::move(binder), std::move(subquery));
|
23
|
-
bind_context.AddSubquery(bind_index,
|
23
|
+
bind_context.AddSubquery(bind_index, subquery_alias, ref, *result->subquery);
|
24
24
|
MoveCorrelatedExpressions(*result->binder);
|
25
25
|
return std::move(result);
|
26
26
|
}
|
@@ -34,7 +34,7 @@ bool Binder::BindTableInTableOutFunction(vector<unique_ptr<ParsedExpression>> &e
|
|
34
34
|
unique_ptr<QueryNode> subquery_node;
|
35
35
|
if (expressions.size() == 1 && expressions[0]->type == ExpressionType::SUBQUERY) {
|
36
36
|
// general case: argument is a subquery, bind it as part of the node
|
37
|
-
auto &se =
|
37
|
+
auto &se = expressions[0]->Cast<SubqueryExpression>();
|
38
38
|
subquery_node = std::move(se.subquery->node);
|
39
39
|
} else {
|
40
40
|
// special case: non-subquery parameter to table-in table-out function
|
@@ -67,9 +67,9 @@ bool Binder::BindTableFunctionParameters(TableFunctionCatalogEntry &table_functi
|
|
67
67
|
// hack to make named parameters work
|
68
68
|
if (child->type == ExpressionType::COMPARE_EQUAL) {
|
69
69
|
// comparison, check if the LHS is a columnref
|
70
|
-
auto &comp = (
|
70
|
+
auto &comp = child->Cast<ComparisonExpression>();
|
71
71
|
if (comp.left->type == ExpressionType::COLUMN_REF) {
|
72
|
-
auto &colref =
|
72
|
+
auto &colref = comp.left->Cast<ColumnRefExpression>();
|
73
73
|
if (!colref.IsQualified()) {
|
74
74
|
parameter_name = colref.GetColumnName();
|
75
75
|
child = std::move(comp.right);
|
@@ -82,7 +82,7 @@ bool Binder::BindTableFunctionParameters(TableFunctionCatalogEntry &table_functi
|
|
82
82
|
return false;
|
83
83
|
}
|
84
84
|
auto binder = Binder::CreateBinder(this->context, this, true);
|
85
|
-
auto &se = (
|
85
|
+
auto &se = child->Cast<SubqueryExpression>();
|
86
86
|
auto node = binder->BindNode(*se.subquery->node);
|
87
87
|
subquery = make_uniq<BoundSubqueryRef>(std::move(binder), std::move(node));
|
88
88
|
seen_subquery = true;
|
@@ -194,19 +194,19 @@ unique_ptr<BoundTableRef> Binder::Bind(TableFunctionRef &ref) {
|
|
194
194
|
QueryErrorContext error_context(root_statement, ref.query_location);
|
195
195
|
|
196
196
|
D_ASSERT(ref.function->type == ExpressionType::FUNCTION);
|
197
|
-
auto fexpr =
|
197
|
+
auto &fexpr = ref.function->Cast<FunctionExpression>();
|
198
198
|
|
199
199
|
TableFunctionCatalogEntry *function = nullptr;
|
200
200
|
|
201
201
|
// fetch the function from the catalog
|
202
|
-
auto func_catalog = Catalog::GetEntry(context, CatalogType::TABLE_FUNCTION_ENTRY, fexpr
|
203
|
-
fexpr
|
202
|
+
auto func_catalog = Catalog::GetEntry(context, CatalogType::TABLE_FUNCTION_ENTRY, fexpr.catalog, fexpr.schema,
|
203
|
+
fexpr.function_name, false, error_context);
|
204
204
|
|
205
205
|
if (func_catalog->type == CatalogType::TABLE_FUNCTION_ENTRY) {
|
206
206
|
function = (TableFunctionCatalogEntry *)func_catalog;
|
207
207
|
} else if (func_catalog->type == CatalogType::TABLE_MACRO_ENTRY) {
|
208
208
|
auto macro_func = (TableMacroCatalogEntry *)func_catalog;
|
209
|
-
auto query_node = BindTableMacro(
|
209
|
+
auto query_node = BindTableMacro(fexpr, macro_func, 0);
|
210
210
|
D_ASSERT(query_node);
|
211
211
|
|
212
212
|
auto binder = Binder::CreateBinder(context, this);
|
@@ -232,7 +232,7 @@ unique_ptr<BoundTableRef> Binder::Bind(TableFunctionRef &ref) {
|
|
232
232
|
named_parameter_map_t named_parameters;
|
233
233
|
unique_ptr<BoundSubqueryRef> subquery;
|
234
234
|
string error;
|
235
|
-
if (!BindTableFunctionParameters(*function, fexpr
|
235
|
+
if (!BindTableFunctionParameters(*function, fexpr.children, arguments, parameters, named_parameters, subquery,
|
236
236
|
error)) {
|
237
237
|
throw BinderException(FormatError(ref, error));
|
238
238
|
}
|
@@ -264,7 +264,7 @@ unique_ptr<BoundTableRef> Binder::Bind(TableFunctionRef &ref) {
|
|
264
264
|
input_table_types = subquery->subquery->types;
|
265
265
|
input_table_names = subquery->subquery->names;
|
266
266
|
}
|
267
|
-
auto get = BindTableFunctionInternal(table_function, ref.alias.empty() ? fexpr
|
267
|
+
auto get = BindTableFunctionInternal(table_function, ref.alias.empty() ? fexpr.function_name : ref.alias,
|
268
268
|
std::move(parameters), std::move(named_parameters),
|
269
269
|
std::move(input_table_types), std::move(input_table_names),
|
270
270
|
ref.column_name_alias, std::move(ref.external_dependency));
|
@@ -22,7 +22,7 @@ namespace duckdb {
|
|
22
22
|
static bool CreateJoinCondition(Expression &expr, const unordered_set<idx_t> &left_bindings,
|
23
23
|
const unordered_set<idx_t> &right_bindings, vector<JoinCondition> &conditions) {
|
24
24
|
// comparison
|
25
|
-
auto &comparison = (
|
25
|
+
auto &comparison = expr.Cast<BoundComparisonExpression>();
|
26
26
|
auto left_side = JoinSide::GetJoinSide(*comparison.left, left_bindings, right_bindings);
|
27
27
|
auto right_side = JoinSide::GetJoinSide(*comparison.right, left_bindings, right_bindings);
|
28
28
|
if (left_side != JoinSide::BOTH && right_side != JoinSide::BOTH) {
|
@@ -64,7 +64,7 @@ void LogicalComparisonJoin::ExtractJoinConditions(JoinType type, unique_ptr<Logi
|
|
64
64
|
right_child = std::move(filter);
|
65
65
|
}
|
66
66
|
// push the expression into the filter
|
67
|
-
auto &filter = (
|
67
|
+
auto &filter = right_child->Cast<LogicalFilter>();
|
68
68
|
filter.expressions.push_back(std::move(expr));
|
69
69
|
continue;
|
70
70
|
}
|
@@ -202,7 +202,7 @@ unique_ptr<LogicalOperator> LogicalComparisonJoin::CreateJoin(JoinType type, Joi
|
|
202
202
|
|
203
203
|
static bool HasCorrelatedColumns(Expression &expression) {
|
204
204
|
if (expression.type == ExpressionType::BOUND_COLUMN_REF) {
|
205
|
-
auto &colref = (
|
205
|
+
auto &colref = expression.Cast<BoundColumnRefExpression>();
|
206
206
|
if (colref.depth > 0) {
|
207
207
|
return true;
|
208
208
|
}
|
@@ -286,7 +286,7 @@ unique_ptr<LogicalOperator> Binder::CreatePlan(BoundJoinRef &ref) {
|
|
286
286
|
}
|
287
287
|
for (auto &child : join->children) {
|
288
288
|
if (child->type == LogicalOperatorType::LOGICAL_FILTER) {
|
289
|
-
auto &filter = (
|
289
|
+
auto &filter = child->Cast<LogicalFilter>();
|
290
290
|
for (auto &expr : filter.expressions) {
|
291
291
|
PlanSubqueries(&expr, &filter.children[0]);
|
292
292
|
}
|
@@ -300,7 +300,7 @@ unique_ptr<LogicalOperator> Binder::CreatePlan(BoundJoinRef &ref) {
|
|
300
300
|
// comparison join
|
301
301
|
// in this join we visit the expressions on the LHS with the LHS as root node
|
302
302
|
// and the expressions on the RHS with the RHS as root node
|
303
|
-
auto &comp_join = (
|
303
|
+
auto &comp_join = join->Cast<LogicalComparisonJoin>();
|
304
304
|
for (idx_t i = 0; i < comp_join.conditions.size(); i++) {
|
305
305
|
PlanSubqueries(&comp_join.conditions[i].left, &comp_join.children[0]);
|
306
306
|
PlanSubqueries(&comp_join.conditions[i].right, &comp_join.children[1]);
|
@@ -308,7 +308,7 @@ unique_ptr<LogicalOperator> Binder::CreatePlan(BoundJoinRef &ref) {
|
|
308
308
|
break;
|
309
309
|
}
|
310
310
|
case LogicalOperatorType::LOGICAL_ANY_JOIN: {
|
311
|
-
auto &any_join = (
|
311
|
+
auto &any_join = join->Cast<LogicalAnyJoin>();
|
312
312
|
// for the any join we just visit the condition
|
313
313
|
if (any_join.condition->HasSubquery()) {
|
314
314
|
throw NotImplementedException("Cannot perform non-inner join on subquery!");
|
@@ -0,0 +1,13 @@
|
|
1
|
+
#include "duckdb/planner/tableref/bound_pivotref.hpp"
|
2
|
+
#include "duckdb/planner/operator/logical_pivot.hpp"
|
3
|
+
|
4
|
+
namespace duckdb {
|
5
|
+
|
6
|
+
unique_ptr<LogicalOperator> Binder::CreatePlan(BoundPivotRef &ref) {
|
7
|
+
auto subquery = ref.child_binder->CreatePlan(*ref.child);
|
8
|
+
|
9
|
+
auto result = make_uniq<LogicalPivot>(ref.bind_index, std::move(subquery), std::move(ref.bound_pivot));
|
10
|
+
return std::move(result);
|
11
|
+
}
|
12
|
+
|
13
|
+
} // namespace duckdb
|