duckdb 0.7.2-dev1898.0 → 0.7.2-dev2144.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 +2 -0
- package/package.json +1 -1
- package/src/data_chunk.cpp +13 -1
- package/src/duckdb/extension/parquet/include/parquet_writer.hpp +1 -1
- package/src/duckdb/extension/parquet/parquet_metadata.cpp +4 -2
- package/src/duckdb/src/catalog/catalog_entry/duck_index_entry.cpp +1 -1
- package/src/duckdb/src/common/arrow/arrow_appender.cpp +69 -44
- package/src/duckdb/src/common/arrow/arrow_converter.cpp +1 -1
- package/src/duckdb/src/common/arrow/arrow_wrapper.cpp +20 -2
- package/src/duckdb/src/common/box_renderer.cpp +4 -2
- package/src/duckdb/src/common/constants.cpp +10 -1
- package/src/duckdb/src/common/filename_pattern.cpp +41 -0
- package/src/duckdb/src/common/hive_partitioning.cpp +144 -15
- package/src/duckdb/src/common/radix_partitioning.cpp +101 -369
- package/src/duckdb/src/common/row_operations/row_aggregate.cpp +8 -9
- package/src/duckdb/src/common/row_operations/row_external.cpp +1 -1
- package/src/duckdb/src/common/row_operations/row_gather.cpp +5 -3
- package/src/duckdb/src/common/row_operations/row_match.cpp +117 -22
- package/src/duckdb/src/common/row_operations/row_scatter.cpp +2 -2
- package/src/duckdb/src/common/sort/partition_state.cpp +1 -1
- package/src/duckdb/src/common/sort/sort_state.cpp +2 -1
- package/src/duckdb/src/common/sort/sorted_block.cpp +1 -1
- package/src/duckdb/src/common/types/{column_data_allocator.cpp → column/column_data_allocator.cpp} +2 -2
- package/src/duckdb/src/common/types/{column_data_collection.cpp → column/column_data_collection.cpp} +22 -4
- package/src/duckdb/src/common/types/{column_data_collection_segment.cpp → column/column_data_collection_segment.cpp} +2 -1
- package/src/duckdb/src/common/types/{column_data_consumer.cpp → column/column_data_consumer.cpp} +1 -1
- package/src/duckdb/src/common/types/{partitioned_column_data.cpp → column/partitioned_column_data.cpp} +11 -9
- package/src/duckdb/src/common/types/row/partitioned_tuple_data.cpp +316 -0
- package/src/duckdb/src/common/types/{row_data_collection.cpp → row/row_data_collection.cpp} +1 -1
- package/src/duckdb/src/common/types/{row_data_collection_scanner.cpp → row/row_data_collection_scanner.cpp} +2 -2
- package/src/duckdb/src/common/types/{row_layout.cpp → row/row_layout.cpp} +1 -1
- package/src/duckdb/src/common/types/row/tuple_data_allocator.cpp +465 -0
- package/src/duckdb/src/common/types/row/tuple_data_collection.cpp +511 -0
- package/src/duckdb/src/common/types/row/tuple_data_iterator.cpp +96 -0
- package/src/duckdb/src/common/types/row/tuple_data_layout.cpp +119 -0
- package/src/duckdb/src/common/types/row/tuple_data_scatter_gather.cpp +1200 -0
- package/src/duckdb/src/common/types/row/tuple_data_segment.cpp +170 -0
- package/src/duckdb/src/common/types/vector.cpp +1 -1
- package/src/duckdb/src/execution/aggregate_hashtable.cpp +252 -290
- package/src/duckdb/src/execution/join_hashtable.cpp +192 -328
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +4 -4
- package/src/duckdb/src/execution/operator/helper/physical_execute.cpp +3 -3
- package/src/duckdb/src/execution/operator/helper/physical_limit_percent.cpp +2 -3
- package/src/duckdb/src/execution/operator/helper/physical_result_collector.cpp +2 -3
- package/src/duckdb/src/execution/operator/join/perfect_hash_join_executor.cpp +36 -21
- package/src/duckdb/src/execution/operator/join/physical_blockwise_nl_join.cpp +2 -2
- package/src/duckdb/src/execution/operator/join/physical_cross_product.cpp +1 -1
- package/src/duckdb/src/execution/operator/join/physical_delim_join.cpp +2 -2
- package/src/duckdb/src/execution/operator/join/physical_hash_join.cpp +166 -144
- package/src/duckdb/src/execution/operator/join/physical_index_join.cpp +5 -5
- package/src/duckdb/src/execution/operator/join/physical_join.cpp +2 -10
- package/src/duckdb/src/execution/operator/join/physical_positional_join.cpp +0 -1
- package/src/duckdb/src/execution/operator/order/physical_top_n.cpp +2 -2
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +13 -11
- package/src/duckdb/src/execution/operator/persistent/physical_delete.cpp +3 -2
- package/src/duckdb/src/execution/operator/persistent/physical_export.cpp +25 -24
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_update.cpp +4 -3
- package/src/duckdb/src/execution/operator/schema/physical_create_type.cpp +1 -1
- package/src/duckdb/src/execution/operator/set/physical_recursive_cte.cpp +3 -3
- package/src/duckdb/src/execution/partitionable_hashtable.cpp +9 -37
- package/src/duckdb/src/execution/physical_operator.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +19 -18
- package/src/duckdb/src/execution/physical_plan/plan_copy_to_file.cpp +2 -1
- package/src/duckdb/src/execution/physical_plan/plan_execute.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_explain.cpp +5 -6
- package/src/duckdb/src/execution/physical_plan/plan_expression_get.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_recursive_cte.cpp +3 -3
- package/src/duckdb/src/execution/physical_plan_generator.cpp +1 -1
- package/src/duckdb/src/execution/radix_partitioned_hashtable.cpp +39 -17
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +2 -2
- package/src/duckdb/src/function/table/pragma_detailed_profiling_output.cpp +5 -5
- package/src/duckdb/src/function/table/pragma_last_profiling_output.cpp +2 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry/index_catalog_entry.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/arrow/arrow_appender.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/constants.hpp +2 -0
- package/src/duckdb/src/include/duckdb/common/exception.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/fast_mem.hpp +528 -0
- package/src/duckdb/src/include/duckdb/common/filename_pattern.hpp +34 -0
- package/src/duckdb/src/include/duckdb/common/helper.hpp +10 -0
- package/src/duckdb/src/include/duckdb/common/hive_partitioning.hpp +13 -3
- package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +8 -0
- package/src/duckdb/src/include/duckdb/common/perfect_map_set.hpp +34 -0
- package/src/duckdb/src/include/duckdb/common/radix_partitioning.hpp +80 -27
- package/src/duckdb/src/include/duckdb/common/reference_map.hpp +38 -0
- package/src/duckdb/src/include/duckdb/common/row_operations/row_operations.hpp +7 -6
- package/src/duckdb/src/include/duckdb/common/sort/comparators.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/sort/partition_state.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/sort/sort.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/sort/sorted_block.hpp +2 -2
- package/src/duckdb/src/include/duckdb/common/types/batched_data_collection.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/{column_data_allocator.hpp → column/column_data_allocator.hpp} +4 -4
- package/src/duckdb/src/include/duckdb/common/types/{column_data_collection.hpp → column/column_data_collection.hpp} +2 -2
- package/src/duckdb/src/include/duckdb/common/types/{column_data_collection_iterators.hpp → column/column_data_collection_iterators.hpp} +2 -2
- package/src/duckdb/src/include/duckdb/common/types/{column_data_collection_segment.hpp → column/column_data_collection_segment.hpp} +3 -3
- package/src/duckdb/src/include/duckdb/common/types/{column_data_consumer.hpp → column/column_data_consumer.hpp} +8 -4
- package/src/duckdb/src/include/duckdb/common/types/{column_data_scan_states.hpp → column/column_data_scan_states.hpp} +1 -1
- package/src/duckdb/src/include/duckdb/common/types/{partitioned_column_data.hpp → column/partitioned_column_data.hpp} +15 -7
- package/src/duckdb/src/include/duckdb/common/types/row/partitioned_tuple_data.hpp +140 -0
- package/src/duckdb/src/include/duckdb/common/types/{row_data_collection.hpp → row/row_data_collection.hpp} +1 -1
- package/src/duckdb/src/include/duckdb/common/types/{row_data_collection_scanner.hpp → row/row_data_collection_scanner.hpp} +2 -2
- package/src/duckdb/src/include/duckdb/common/types/{row_layout.hpp → row/row_layout.hpp} +3 -1
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_allocator.hpp +116 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_collection.hpp +239 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_iterator.hpp +64 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_layout.hpp +113 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_segment.hpp +124 -0
- package/src/duckdb/src/include/duckdb/common/types/row/tuple_data_states.hpp +74 -0
- package/src/duckdb/src/include/duckdb/common/types/validity_mask.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +4 -12
- package/src/duckdb/src/include/duckdb/execution/aggregate_hashtable.hpp +34 -31
- package/src/duckdb/src/include/duckdb/execution/base_aggregate_hashtable.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/execution_context.hpp +3 -2
- package/src/duckdb/src/include/duckdb/execution/expression_executor.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/join_hashtable.hpp +41 -67
- package/src/duckdb/src/include/duckdb/execution/nested_loop_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_execute.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/helper/physical_result_collector.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/outer_join_marker.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/perfect_hash_join_executor.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_cross_product.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_hash_join.hpp +0 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_index_join.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/join/physical_positional_join.hpp +1 -1
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_copy_to_file.hpp +4 -1
- package/src/duckdb/src/include/duckdb/execution/operator/scan/physical_column_data_scan.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/partitionable_hashtable.hpp +2 -2
- package/src/duckdb/src/include/duckdb/main/materialized_query_result.hpp +1 -1
- package/src/duckdb/src/include/duckdb/main/query_result.hpp +14 -1
- package/src/duckdb/src/include/duckdb/optimizer/expression_rewriter.hpp +3 -3
- package/src/duckdb/src/include/duckdb/optimizer/join_order/cardinality_estimator.hpp +16 -16
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_node.hpp +8 -8
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_order_optimizer.hpp +23 -15
- package/src/duckdb/src/include/duckdb/optimizer/join_order/join_relation.hpp +9 -10
- package/src/duckdb/src/include/duckdb/optimizer/join_order/query_graph.hpp +18 -11
- package/src/duckdb/src/include/duckdb/parallel/meta_pipeline.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/exported_table_data.hpp +5 -1
- package/src/duckdb/src/include/duckdb/parser/parsed_data/vacuum_info.hpp +3 -2
- package/src/duckdb/src/include/duckdb/parser/query_error_context.hpp +4 -2
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +9 -35
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +24 -23
- package/src/duckdb/src/include/duckdb/planner/expression_binder.hpp +3 -3
- package/src/duckdb/src/include/duckdb/planner/operator/logical_column_data_get.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_copy_to_file.hpp +3 -1
- package/src/duckdb/src/include/duckdb/storage/table/table_index_list.hpp +1 -1
- package/src/duckdb/src/main/appender.cpp +6 -6
- package/src/duckdb/src/main/client_context.cpp +1 -1
- package/src/duckdb/src/main/connection.cpp +2 -2
- package/src/duckdb/src/main/query_result.cpp +13 -0
- package/src/duckdb/src/optimizer/expression_rewriter.cpp +4 -4
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +91 -105
- package/src/duckdb/src/optimizer/join_order/join_node.cpp +5 -8
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +163 -160
- package/src/duckdb/src/optimizer/join_order/join_relation_set.cpp +30 -30
- package/src/duckdb/src/optimizer/join_order/query_graph.cpp +37 -38
- package/src/duckdb/src/parallel/executor.cpp +1 -1
- package/src/duckdb/src/parallel/meta_pipeline.cpp +2 -2
- package/src/duckdb/src/parser/transform/helpers/transform_cte.cpp +1 -1
- package/src/duckdb/src/parser/transform/tableref/transform_subquery.cpp +1 -1
- package/src/duckdb/src/parser/transformer.cpp +50 -9
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +15 -5
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +19 -17
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +4 -4
- package/src/duckdb/src/planner/binder/statement/bind_export.cpp +20 -21
- package/src/duckdb/src/planner/binder/tableref/bind_basetableref.cpp +24 -22
- package/src/duckdb/src/planner/binder/tableref/bind_subqueryref.cpp +2 -2
- package/src/duckdb/src/planner/binder.cpp +16 -19
- package/src/duckdb/src/planner/expression_binder.cpp +8 -8
- package/src/duckdb/src/planner/operator/logical_copy_to_file.cpp +3 -3
- package/src/duckdb/src/storage/checkpoint_manager.cpp +23 -23
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +1 -1
- package/src/duckdb/src/storage/table_index_list.cpp +3 -3
- package/src/duckdb/src/verification/statement_verifier.cpp +1 -1
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +5552 -5598
- package/src/duckdb/ub_src_common.cpp +2 -0
- package/src/duckdb/ub_src_common_types.cpp +0 -16
- package/src/duckdb/ub_src_common_types_column.cpp +10 -0
- package/src/duckdb/ub_src_common_types_row.cpp +20 -0
- package/test/udf.test.ts +9 -0
@@ -17,10 +17,10 @@ struct RadixPartitionInfo {
|
|
17
17
|
const idx_t n_partitions;
|
18
18
|
const idx_t radix_bits;
|
19
19
|
const hash_t radix_mask;
|
20
|
-
|
20
|
+
const idx_t radix_shift;
|
21
21
|
|
22
22
|
inline hash_t GetHashPartition(hash_t hash) const {
|
23
|
-
return (hash & radix_mask) >>
|
23
|
+
return (hash & radix_mask) >> radix_shift;
|
24
24
|
}
|
25
25
|
};
|
26
26
|
|
@@ -58,7 +58,16 @@ protected:
|
|
58
58
|
//! The error (in case execution was not successful)
|
59
59
|
PreservedError error;
|
60
60
|
};
|
61
|
-
|
61
|
+
struct CurrentChunk {
|
62
|
+
//! The current data chunk
|
63
|
+
unique_ptr<DataChunk> data_chunk;
|
64
|
+
//! The current position in the data chunk
|
65
|
+
idx_t position;
|
66
|
+
//! If we have a current chunk we must scan for result production
|
67
|
+
bool Valid();
|
68
|
+
//! The remaining size of the current chunk
|
69
|
+
idx_t RemainingSize();
|
70
|
+
};
|
62
71
|
//! The QueryResult object holds the result of a query. It can either be a MaterializedQueryResult, in which case the
|
63
72
|
//! result contains the entire result set, or a StreamQueryResult in which case the Fetch method can be called to
|
64
73
|
//! incrementally fetch data from the database.
|
@@ -75,6 +84,10 @@ public:
|
|
75
84
|
ClientProperties client_properties;
|
76
85
|
//! The next result (if any)
|
77
86
|
unique_ptr<QueryResult> next;
|
87
|
+
//! In case we are converting the result from Native DuckDB to a different library (e.g., Arrow, Polars)
|
88
|
+
//! We might be producing chunks of a pre-determined size.
|
89
|
+
//! To comply, we use the following variable to store the current chunk, and it's position.
|
90
|
+
CurrentChunk current_chunk;
|
78
91
|
|
79
92
|
public:
|
80
93
|
//! Returns the name of the column for the given index
|
@@ -37,11 +37,11 @@ public:
|
|
37
37
|
|
38
38
|
private:
|
39
39
|
//! Apply a set of rules to a specific expression
|
40
|
-
static unique_ptr<Expression> ApplyRules(LogicalOperator &op, const vector<Rule
|
40
|
+
static unique_ptr<Expression> ApplyRules(LogicalOperator &op, const vector<reference<Rule>> &rules,
|
41
41
|
unique_ptr<Expression> expr, bool &changes_made, bool is_root = false);
|
42
42
|
|
43
|
-
LogicalOperator
|
44
|
-
vector<Rule
|
43
|
+
optional_ptr<LogicalOperator> op;
|
44
|
+
vector<reference<Rule>> to_apply_rules;
|
45
45
|
};
|
46
46
|
|
47
47
|
} // namespace duckdb
|
@@ -41,9 +41,9 @@ struct RelationsToTDom {
|
|
41
41
|
|
42
42
|
struct NodeOp {
|
43
43
|
unique_ptr<JoinNode> node;
|
44
|
-
LogicalOperator
|
44
|
+
LogicalOperator &op;
|
45
45
|
|
46
|
-
NodeOp(unique_ptr<JoinNode> node, LogicalOperator
|
46
|
+
NodeOp(unique_ptr<JoinNode> node, LogicalOperator &op) : node(std::move(node)), op(op) {};
|
47
47
|
};
|
48
48
|
|
49
49
|
struct Subgraph2Denominator {
|
@@ -71,7 +71,7 @@ private:
|
|
71
71
|
public:
|
72
72
|
static constexpr double DEFAULT_SELECTIVITY = 0.2;
|
73
73
|
|
74
|
-
static void VerifySymmetry(JoinNode
|
74
|
+
static void VerifySymmetry(JoinNode &result, JoinNode &entry);
|
75
75
|
|
76
76
|
//! given a binding of (relation, column) used for DP, and a (table, column) in that catalog
|
77
77
|
//! Add the key value entry into the relation_column_to_original_column
|
@@ -83,20 +83,20 @@ public:
|
|
83
83
|
// in the child join plan.
|
84
84
|
void CopyRelationMap(column_binding_map_t<ColumnBinding> &child_binding_map);
|
85
85
|
void MergeBindings(idx_t, idx_t relation_id, vector<column_binding_map_t<ColumnBinding>> &child_binding_maps);
|
86
|
-
void AddRelationColumnMapping(LogicalGet
|
86
|
+
void AddRelationColumnMapping(LogicalGet &get, idx_t relation_id);
|
87
87
|
|
88
88
|
void InitTotalDomains();
|
89
|
-
void UpdateTotalDomains(JoinNode
|
90
|
-
void InitEquivalentRelations(vector<unique_ptr<FilterInfo>>
|
89
|
+
void UpdateTotalDomains(JoinNode &node, LogicalOperator &op);
|
90
|
+
void InitEquivalentRelations(vector<unique_ptr<FilterInfo>> &filter_infos);
|
91
91
|
|
92
|
-
void InitCardinalityEstimatorProps(vector<NodeOp>
|
93
|
-
double EstimateCardinalityWithSet(JoinRelationSet
|
94
|
-
void EstimateBaseTableCardinality(JoinNode
|
95
|
-
double EstimateCrossProduct(const JoinNode
|
96
|
-
static double ComputeCost(JoinNode
|
92
|
+
void InitCardinalityEstimatorProps(vector<NodeOp> &node_ops, vector<unique_ptr<FilterInfo>> &filter_infos);
|
93
|
+
double EstimateCardinalityWithSet(JoinRelationSet &new_set);
|
94
|
+
void EstimateBaseTableCardinality(JoinNode &node, LogicalOperator &op);
|
95
|
+
double EstimateCrossProduct(const JoinNode &left, const JoinNode &right);
|
96
|
+
static double ComputeCost(JoinNode &left, JoinNode &right, double expected_cardinality);
|
97
97
|
|
98
98
|
private:
|
99
|
-
bool SingleColumnFilter(FilterInfo
|
99
|
+
bool SingleColumnFilter(FilterInfo &filter_info);
|
100
100
|
//! Filter & bindings -> list of indexes into the equivalent_relations array.
|
101
101
|
// The column binding set at each index is an equivalence set.
|
102
102
|
vector<idx_t> DetermineMatchingEquivalentSets(FilterInfo *filter_info);
|
@@ -106,16 +106,16 @@ private:
|
|
106
106
|
//! If there are multiple equivalence sets, they are merged.
|
107
107
|
void AddToEquivalenceSets(FilterInfo *filter_info, vector<idx_t> matching_equivalent_sets);
|
108
108
|
|
109
|
-
TableFilterSet
|
109
|
+
optional_ptr<TableFilterSet> GetTableFilters(LogicalOperator &op, idx_t table_index);
|
110
110
|
|
111
|
-
void AddRelationTdom(FilterInfo
|
112
|
-
bool EmptyFilter(FilterInfo
|
111
|
+
void AddRelationTdom(FilterInfo &filter_info);
|
112
|
+
bool EmptyFilter(FilterInfo &filter_info);
|
113
113
|
|
114
114
|
idx_t InspectConjunctionAND(idx_t cardinality, idx_t column_index, ConjunctionAndFilter *fil,
|
115
115
|
unique_ptr<BaseStatistics> base_stats);
|
116
116
|
idx_t InspectConjunctionOR(idx_t cardinality, idx_t column_index, ConjunctionOrFilter *fil,
|
117
117
|
unique_ptr<BaseStatistics> base_stats);
|
118
|
-
idx_t InspectTableFilters(idx_t cardinality, LogicalOperator
|
118
|
+
idx_t InspectTableFilters(idx_t cardinality, LogicalOperator &op, TableFilterSet &table_filters, idx_t table_index);
|
119
119
|
};
|
120
120
|
|
121
121
|
} // namespace duckdb
|
@@ -25,27 +25,27 @@ class JoinOrderOptimizer;
|
|
25
25
|
class JoinNode {
|
26
26
|
public:
|
27
27
|
//! Represents a node in the join plan
|
28
|
-
JoinRelationSet
|
29
|
-
NeighborInfo
|
28
|
+
JoinRelationSet &set;
|
29
|
+
optional_ptr<NeighborInfo> info;
|
30
30
|
//! If the JoinNode is a base table, then base_cardinality is the cardinality before filters
|
31
31
|
//! estimated_props.cardinality will be the cardinality after filters. With no filters, the two are equal
|
32
32
|
bool has_filter;
|
33
|
-
JoinNode
|
34
|
-
JoinNode
|
33
|
+
optional_ptr<JoinNode> left;
|
34
|
+
optional_ptr<JoinNode> right;
|
35
35
|
|
36
36
|
unique_ptr<EstimatedProperties> estimated_props;
|
37
37
|
|
38
38
|
//! Create a leaf node in the join tree
|
39
39
|
//! set cost to 0 for leaf nodes
|
40
40
|
//! cost will be the cost to *produce* an intermediate table
|
41
|
-
JoinNode(JoinRelationSet
|
41
|
+
JoinNode(JoinRelationSet &set, const double base_cardinality);
|
42
42
|
|
43
43
|
//! Create an intermediate node in the join tree. base_cardinality = estimated_props.cardinality
|
44
|
-
JoinNode(JoinRelationSet
|
45
|
-
double cost);
|
44
|
+
JoinNode(JoinRelationSet &set, optional_ptr<NeighborInfo> info, JoinNode &left, JoinNode &right,
|
45
|
+
const double base_cardinality, double cost);
|
46
46
|
|
47
47
|
bool operator==(const JoinNode &other) {
|
48
|
-
return other.set
|
48
|
+
return other.set.ToString().compare(set.ToString()) == 0;
|
49
49
|
}
|
50
50
|
|
51
51
|
private:
|
@@ -22,6 +22,14 @@
|
|
22
22
|
|
23
23
|
namespace duckdb {
|
24
24
|
|
25
|
+
struct GenerateJoinRelation {
|
26
|
+
GenerateJoinRelation(JoinRelationSet &set, unique_ptr<LogicalOperator> op_p) : set(set), op(std::move(op_p)) {
|
27
|
+
}
|
28
|
+
|
29
|
+
JoinRelationSet &set;
|
30
|
+
unique_ptr<LogicalOperator> op;
|
31
|
+
};
|
32
|
+
|
25
33
|
class JoinOrderOptimizer {
|
26
34
|
public:
|
27
35
|
explicit JoinOrderOptimizer(ClientContext &context)
|
@@ -31,8 +39,9 @@ public:
|
|
31
39
|
//! Perform join reordering inside a plan
|
32
40
|
unique_ptr<LogicalOperator> Optimize(unique_ptr<LogicalOperator> plan);
|
33
41
|
|
34
|
-
unique_ptr<JoinNode> CreateJoinTree(JoinRelationSet
|
35
|
-
|
42
|
+
unique_ptr<JoinNode> CreateJoinTree(JoinRelationSet &set,
|
43
|
+
const vector<reference<NeighborInfo>> &possible_connections, JoinNode &left,
|
44
|
+
JoinNode &right);
|
36
45
|
|
37
46
|
private:
|
38
47
|
ClientContext &context;
|
@@ -71,23 +80,23 @@ private:
|
|
71
80
|
|
72
81
|
//! Traverse the query tree to find (1) base relations, (2) existing join conditions and (3) filters that can be
|
73
82
|
//! rewritten into joins. Returns true if there are joins in the tree that can be reordered, false otherwise.
|
74
|
-
bool ExtractJoinRelations(LogicalOperator &input_op, vector<LogicalOperator
|
75
|
-
LogicalOperator
|
83
|
+
bool ExtractJoinRelations(LogicalOperator &input_op, vector<reference<LogicalOperator>> &filter_operators,
|
84
|
+
optional_ptr<LogicalOperator> parent = nullptr);
|
76
85
|
|
77
86
|
//! Emit a pair as a potential join candidate. Returns the best plan found for the (left, right) connection (either
|
78
87
|
//! the newly created plan, or an existing plan)
|
79
|
-
JoinNode
|
88
|
+
JoinNode &EmitPair(JoinRelationSet &left, JoinRelationSet &right, const vector<reference<NeighborInfo>> &info);
|
80
89
|
//! Tries to emit a potential join candidate pair. Returns false if too many pairs have already been emitted,
|
81
90
|
//! cancelling the dynamic programming step.
|
82
|
-
bool TryEmitPair(JoinRelationSet
|
91
|
+
bool TryEmitPair(JoinRelationSet &left, JoinRelationSet &right, const vector<reference<NeighborInfo>> &info);
|
83
92
|
|
84
|
-
bool EnumerateCmpRecursive(JoinRelationSet
|
93
|
+
bool EnumerateCmpRecursive(JoinRelationSet &left, JoinRelationSet &right, unordered_set<idx_t> exclusion_set);
|
85
94
|
//! Emit a relation set node
|
86
|
-
bool EmitCSG(JoinRelationSet
|
95
|
+
bool EmitCSG(JoinRelationSet &node);
|
87
96
|
//! Enumerate the possible connected subgraphs that can be joined together in the join graph
|
88
|
-
bool EnumerateCSGRecursive(JoinRelationSet
|
97
|
+
bool EnumerateCSGRecursive(JoinRelationSet &node, unordered_set<idx_t> &exclusion_set);
|
89
98
|
//! Rewrite a logical query plan given the join plan
|
90
|
-
unique_ptr<LogicalOperator> RewritePlan(unique_ptr<LogicalOperator> plan, JoinNode
|
99
|
+
unique_ptr<LogicalOperator> RewritePlan(unique_ptr<LogicalOperator> plan, JoinNode &node);
|
91
100
|
//! Generate cross product edges inside the side
|
92
101
|
void GenerateCrossProducts();
|
93
102
|
//! Perform the join order solving
|
@@ -98,13 +107,12 @@ private:
|
|
98
107
|
//! Solve the join order approximately using a greedy algorithm
|
99
108
|
void SolveJoinOrderApproximately();
|
100
109
|
|
101
|
-
void UpdateDPTree(JoinNode
|
110
|
+
void UpdateDPTree(JoinNode &new_plan);
|
102
111
|
|
103
|
-
void UpdateJoinNodesInFullPlan(JoinNode
|
104
|
-
bool NodeInFullPlan(JoinNode
|
112
|
+
void UpdateJoinNodesInFullPlan(JoinNode &node);
|
113
|
+
bool NodeInFullPlan(JoinNode &node);
|
105
114
|
|
106
|
-
|
107
|
-
GenerateJoins(vector<unique_ptr<LogicalOperator>> &extracted_relations, JoinNode *node);
|
115
|
+
GenerateJoinRelation GenerateJoins(vector<unique_ptr<LogicalOperator>> &extracted_relations, JoinNode &node);
|
108
116
|
};
|
109
117
|
|
110
118
|
} // namespace duckdb
|
@@ -11,18 +11,17 @@
|
|
11
11
|
#include "duckdb/common/common.hpp"
|
12
12
|
#include "duckdb/common/unordered_map.hpp"
|
13
13
|
#include "duckdb/common/unordered_set.hpp"
|
14
|
+
#include "duckdb/common/optional_ptr.hpp"
|
14
15
|
|
15
16
|
namespace duckdb {
|
16
17
|
class LogicalOperator;
|
17
18
|
|
18
19
|
//! Represents a single relation and any metadata accompanying that relation
|
19
20
|
struct SingleJoinRelation {
|
20
|
-
LogicalOperator
|
21
|
-
LogicalOperator
|
21
|
+
LogicalOperator &op;
|
22
|
+
optional_ptr<LogicalOperator> parent;
|
22
23
|
|
23
|
-
SingleJoinRelation() {
|
24
|
-
}
|
25
|
-
SingleJoinRelation(LogicalOperator *op, LogicalOperator *parent) : op(op), parent(parent) {
|
24
|
+
SingleJoinRelation(LogicalOperator &op, optional_ptr<LogicalOperator> parent) : op(op), parent(parent) {
|
26
25
|
}
|
27
26
|
};
|
28
27
|
|
@@ -36,7 +35,7 @@ struct JoinRelationSet {
|
|
36
35
|
unique_ptr<idx_t[]> relations;
|
37
36
|
idx_t count;
|
38
37
|
|
39
|
-
static bool IsSubset(JoinRelationSet
|
38
|
+
static bool IsSubset(JoinRelationSet &super, JoinRelationSet &sub);
|
40
39
|
};
|
41
40
|
|
42
41
|
//! The JoinRelationTree is a structure holding all the created JoinRelationSet objects and allowing fast lookup on to
|
@@ -52,13 +51,13 @@ public:
|
|
52
51
|
|
53
52
|
public:
|
54
53
|
//! Create or get a JoinRelationSet from a single node with the given index
|
55
|
-
JoinRelationSet
|
54
|
+
JoinRelationSet &GetJoinRelation(idx_t index);
|
56
55
|
//! Create or get a JoinRelationSet from a set of relation bindings
|
57
|
-
JoinRelationSet
|
56
|
+
JoinRelationSet &GetJoinRelation(unordered_set<idx_t> &bindings);
|
58
57
|
//! Create or get a JoinRelationSet from a (sorted, duplicate-free!) list of relations
|
59
|
-
JoinRelationSet
|
58
|
+
JoinRelationSet &GetJoinRelation(unique_ptr<idx_t[]> relations, idx_t count);
|
60
59
|
//! Union two sets of relations together and create a new relation set
|
61
|
-
JoinRelationSet
|
60
|
+
JoinRelationSet &Union(JoinRelationSet &left, JoinRelationSet &right);
|
62
61
|
// //! Create the set difference of left \ right (i.e. all elements in left that are not in right)
|
63
62
|
// JoinRelationSet *Difference(JoinRelationSet *left, JoinRelationSet *right);
|
64
63
|
|
@@ -15,6 +15,7 @@
|
|
15
15
|
#include "duckdb/optimizer/join_order/join_relation.hpp"
|
16
16
|
#include "duckdb/common/vector.hpp"
|
17
17
|
#include "duckdb/planner/column_binding.hpp"
|
18
|
+
#include "duckdb/common/optional_ptr.hpp"
|
18
19
|
|
19
20
|
#include <functional>
|
20
21
|
|
@@ -23,22 +24,28 @@ class Expression;
|
|
23
24
|
class LogicalOperator;
|
24
25
|
|
25
26
|
struct FilterInfo {
|
27
|
+
FilterInfo(JoinRelationSet &set, idx_t filter_index) : set(set), filter_index(filter_index) {
|
28
|
+
}
|
29
|
+
|
30
|
+
JoinRelationSet &set;
|
26
31
|
idx_t filter_index;
|
27
|
-
JoinRelationSet
|
28
|
-
JoinRelationSet
|
32
|
+
optional_ptr<JoinRelationSet> left_set;
|
33
|
+
optional_ptr<JoinRelationSet> right_set;
|
29
34
|
ColumnBinding left_binding;
|
30
35
|
ColumnBinding right_binding;
|
31
|
-
JoinRelationSet *set = nullptr;
|
32
36
|
};
|
33
37
|
|
34
38
|
struct FilterNode {
|
35
|
-
vector<FilterInfo
|
39
|
+
vector<reference<FilterInfo>> filters;
|
36
40
|
unordered_map<idx_t, unique_ptr<FilterNode>> children;
|
37
41
|
};
|
38
42
|
|
39
43
|
struct NeighborInfo {
|
40
|
-
JoinRelationSet
|
41
|
-
|
44
|
+
NeighborInfo(JoinRelationSet &neighbor) : neighbor(neighbor) {
|
45
|
+
}
|
46
|
+
|
47
|
+
JoinRelationSet &neighbor;
|
48
|
+
vector<reference<FilterInfo>> filters;
|
42
49
|
};
|
43
50
|
|
44
51
|
//! The QueryGraph contains edges between relations and allows edges to be created/queried
|
@@ -55,18 +62,18 @@ public:
|
|
55
62
|
void Print();
|
56
63
|
|
57
64
|
//! Create an edge in the edge_set
|
58
|
-
void CreateEdge(JoinRelationSet
|
65
|
+
void CreateEdge(JoinRelationSet &left, JoinRelationSet &right, optional_ptr<FilterInfo> info);
|
59
66
|
//! Returns a connection if there is an edge that connects these two sets, or nullptr otherwise
|
60
|
-
vector<NeighborInfo
|
67
|
+
vector<reference<NeighborInfo>> GetConnections(JoinRelationSet &node, JoinRelationSet &other);
|
61
68
|
//! Enumerate the neighbors of a specific node that do not belong to any of the exclusion_set. Note that if a
|
62
69
|
//! neighbor has multiple nodes, this function will return the lowest entry in that set.
|
63
|
-
vector<idx_t> GetNeighbors(JoinRelationSet
|
70
|
+
vector<idx_t> GetNeighbors(JoinRelationSet &node, unordered_set<idx_t> &exclusion_set);
|
64
71
|
//! Enumerate all neighbors of a given JoinRelationSet node
|
65
|
-
void EnumerateNeighbors(JoinRelationSet
|
72
|
+
void EnumerateNeighbors(JoinRelationSet &node, const std::function<bool(NeighborInfo &)> &callback);
|
66
73
|
|
67
74
|
private:
|
68
75
|
//! Get the QueryEdge of a specific node
|
69
|
-
QueryEdge
|
76
|
+
QueryEdge &GetQueryEdge(JoinRelationSet &left);
|
70
77
|
|
71
78
|
QueryEdge root;
|
72
79
|
};
|
@@ -29,7 +29,11 @@ struct ExportedTableData {
|
|
29
29
|
};
|
30
30
|
|
31
31
|
struct ExportedTableInfo {
|
32
|
-
TableCatalogEntry
|
32
|
+
ExportedTableInfo(TableCatalogEntry &entry, ExportedTableData table_data)
|
33
|
+
: entry(entry), table_data(std::move(table_data)) {
|
34
|
+
}
|
35
|
+
|
36
|
+
TableCatalogEntry &entry;
|
33
37
|
ExportedTableData table_data;
|
34
38
|
};
|
35
39
|
|
@@ -12,6 +12,7 @@
|
|
12
12
|
#include "duckdb/parser/tableref.hpp"
|
13
13
|
#include "duckdb/planner/tableref/bound_basetableref.hpp"
|
14
14
|
#include "duckdb/common/unordered_map.hpp"
|
15
|
+
#include "duckdb/common/optional_ptr.hpp"
|
15
16
|
|
16
17
|
namespace duckdb {
|
17
18
|
|
@@ -22,7 +23,7 @@ struct VacuumOptions {
|
|
22
23
|
|
23
24
|
struct VacuumInfo : public ParseInfo {
|
24
25
|
public:
|
25
|
-
explicit VacuumInfo(VacuumOptions options) : options(options), has_table(false)
|
26
|
+
explicit VacuumInfo(VacuumOptions options) : options(options), has_table(false) {};
|
26
27
|
|
27
28
|
unique_ptr<VacuumInfo> Copy() {
|
28
29
|
auto result = make_uniq<VacuumInfo>(options);
|
@@ -38,7 +39,7 @@ public:
|
|
38
39
|
public:
|
39
40
|
bool has_table;
|
40
41
|
unique_ptr<TableRef> ref;
|
41
|
-
TableCatalogEntry
|
42
|
+
optional_ptr<TableCatalogEntry> table;
|
42
43
|
unordered_map<idx_t, idx_t> column_id_map;
|
43
44
|
vector<string> columns;
|
44
45
|
};
|
@@ -11,18 +11,20 @@
|
|
11
11
|
#include "duckdb/common/common.hpp"
|
12
12
|
#include "duckdb/common/vector.hpp"
|
13
13
|
#include "duckdb/common/exception_format_value.hpp"
|
14
|
+
#include "duckdb/common/optional_ptr.hpp"
|
14
15
|
|
15
16
|
namespace duckdb {
|
16
17
|
class SQLStatement;
|
17
18
|
|
18
19
|
class QueryErrorContext {
|
19
20
|
public:
|
20
|
-
explicit QueryErrorContext(SQLStatement
|
21
|
+
explicit QueryErrorContext(optional_ptr<SQLStatement> statement_ = nullptr,
|
22
|
+
idx_t query_location_ = DConstants::INVALID_INDEX)
|
21
23
|
: statement(statement_), query_location(query_location_) {
|
22
24
|
}
|
23
25
|
|
24
26
|
//! The query statement
|
25
|
-
SQLStatement
|
27
|
+
optional_ptr<SQLStatement> statement;
|
26
28
|
//! The location in which the error should be thrown
|
27
29
|
idx_t query_location;
|
28
30
|
|
@@ -49,19 +49,17 @@ class Transformer {
|
|
49
49
|
|
50
50
|
public:
|
51
51
|
explicit Transformer(ParserOptions &options);
|
52
|
-
explicit Transformer(Transformer
|
52
|
+
explicit Transformer(Transformer &parent);
|
53
53
|
~Transformer();
|
54
54
|
|
55
55
|
//! Transforms a Postgres parse tree into a set of SQL Statements
|
56
56
|
bool TransformParseTree(duckdb_libpgquery::PGList *tree, vector<unique_ptr<SQLStatement>> &statements);
|
57
57
|
string NodetypeToString(duckdb_libpgquery::PGNodeTag type);
|
58
58
|
|
59
|
-
idx_t ParamCount()
|
60
|
-
return parent ? parent->ParamCount() : prepared_statement_parameter_index;
|
61
|
-
}
|
59
|
+
idx_t ParamCount() const;
|
62
60
|
|
63
61
|
private:
|
64
|
-
Transformer
|
62
|
+
optional_ptr<Transformer> parent;
|
65
63
|
//! Parser options
|
66
64
|
ParserOptions &options;
|
67
65
|
//! The current prepared statement parameter index
|
@@ -80,36 +78,12 @@ private:
|
|
80
78
|
void Clear();
|
81
79
|
bool InWindowDefinition();
|
82
80
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
}
|
90
|
-
void SetNamedParam(const string &name, int32_t index) {
|
91
|
-
if (parent) {
|
92
|
-
parent->SetNamedParam(name, index);
|
93
|
-
} else {
|
94
|
-
D_ASSERT(!named_param_map.count(name));
|
95
|
-
this->named_param_map[name] = index;
|
96
|
-
}
|
97
|
-
}
|
98
|
-
bool GetNamedParam(const string &name, int32_t &index) {
|
99
|
-
if (parent) {
|
100
|
-
return parent->GetNamedParam(name, index);
|
101
|
-
} else {
|
102
|
-
auto entry = named_param_map.find(name);
|
103
|
-
if (entry == named_param_map.end()) {
|
104
|
-
return false;
|
105
|
-
}
|
106
|
-
index = entry->second;
|
107
|
-
return true;
|
108
|
-
}
|
109
|
-
}
|
110
|
-
bool HasNamedParameters() const {
|
111
|
-
return parent ? parent->HasNamedParameters() : !named_param_map.empty();
|
112
|
-
}
|
81
|
+
Transformer &RootTransformer();
|
82
|
+
const Transformer &RootTransformer() const;
|
83
|
+
void SetParamCount(idx_t new_count);
|
84
|
+
void SetNamedParam(const string &name, int32_t index);
|
85
|
+
bool GetNamedParam(const string &name, int32_t &index);
|
86
|
+
bool HasNamedParameters() const;
|
113
87
|
|
114
88
|
void AddPivotEntry(string enum_name, unique_ptr<SelectNode> source, unique_ptr<ParsedExpression> column);
|
115
89
|
unique_ptr<SQLStatement> GenerateCreateEnumStmt(unique_ptr<CreatePivotEntry> entry);
|
@@ -21,6 +21,7 @@
|
|
21
21
|
#include "duckdb/planner/bound_tokens.hpp"
|
22
22
|
#include "duckdb/planner/expression/bound_columnref_expression.hpp"
|
23
23
|
#include "duckdb/planner/logical_operator.hpp"
|
24
|
+
#include "duckdb/common/reference_map.hpp"
|
24
25
|
|
25
26
|
namespace duckdb {
|
26
27
|
class BoundResultModifier;
|
@@ -76,43 +77,43 @@ class Binder : public std::enable_shared_from_this<Binder> {
|
|
76
77
|
friend class RecursiveSubqueryPlanner;
|
77
78
|
|
78
79
|
public:
|
79
|
-
DUCKDB_API static shared_ptr<Binder> CreateBinder(ClientContext &context, Binder
|
80
|
+
DUCKDB_API static shared_ptr<Binder> CreateBinder(ClientContext &context, optional_ptr<Binder> parent = nullptr,
|
80
81
|
bool inherit_ctes = true);
|
81
82
|
|
82
83
|
//! The client context
|
83
84
|
ClientContext &context;
|
84
85
|
//! A mapping of names to common table expressions
|
85
|
-
case_insensitive_map_t<CommonTableExpressionInfo
|
86
|
+
case_insensitive_map_t<reference<CommonTableExpressionInfo>> CTE_bindings; // NOLINT
|
86
87
|
//! The CTEs that have already been bound
|
87
|
-
|
88
|
+
reference_set_t<CommonTableExpressionInfo> bound_ctes;
|
88
89
|
//! The bind context
|
89
90
|
BindContext bind_context;
|
90
91
|
//! The set of correlated columns bound by this binder (FIXME: this should probably be an unordered_set and not a
|
91
92
|
//! vector)
|
92
93
|
vector<CorrelatedColumnInfo> correlated_columns;
|
93
94
|
//! The set of parameter expressions bound by this binder
|
94
|
-
BoundParameterMap
|
95
|
+
optional_ptr<BoundParameterMap> parameters;
|
95
96
|
//! Statement properties
|
96
97
|
StatementProperties properties;
|
97
98
|
//! The alias for the currently processing subquery, if it exists
|
98
99
|
string alias;
|
99
100
|
//! Macro parameter bindings (if any)
|
100
|
-
DummyBinding
|
101
|
+
optional_ptr<DummyBinding> macro_binding;
|
101
102
|
//! The intermediate lambda bindings to bind nested lambdas (if any)
|
102
|
-
vector<DummyBinding
|
103
|
+
optional_ptr<vector<DummyBinding>> lambda_bindings;
|
103
104
|
|
104
105
|
public:
|
105
106
|
DUCKDB_API BoundStatement Bind(SQLStatement &statement);
|
106
107
|
DUCKDB_API BoundStatement Bind(QueryNode &node);
|
107
108
|
|
108
109
|
unique_ptr<BoundCreateTableInfo> BindCreateTableInfo(unique_ptr<CreateInfo> info);
|
109
|
-
unique_ptr<BoundCreateTableInfo> BindCreateTableInfo(unique_ptr<CreateInfo> info, SchemaCatalogEntry
|
110
|
+
unique_ptr<BoundCreateTableInfo> BindCreateTableInfo(unique_ptr<CreateInfo> info, SchemaCatalogEntry &schema);
|
110
111
|
|
111
112
|
vector<unique_ptr<Expression>> BindCreateIndexExpressions(TableCatalogEntry *table, CreateIndexInfo *info);
|
112
113
|
|
113
114
|
void BindCreateViewInfo(CreateViewInfo &base);
|
114
|
-
SchemaCatalogEntry
|
115
|
-
SchemaCatalogEntry
|
115
|
+
SchemaCatalogEntry &BindSchema(CreateInfo &info);
|
116
|
+
SchemaCatalogEntry &BindCreateFunctionInfo(CreateInfo &info);
|
116
117
|
|
117
118
|
//! Check usage, and cast named parameters to their types
|
118
119
|
static void BindNamedParameters(named_parameter_type_map_t &types, named_parameter_map_t &values,
|
@@ -125,22 +126,22 @@ public:
|
|
125
126
|
idx_t GenerateTableIndex();
|
126
127
|
|
127
128
|
//! Add a common table expression to the binder
|
128
|
-
void AddCTE(const string &name, CommonTableExpressionInfo
|
129
|
+
void AddCTE(const string &name, CommonTableExpressionInfo &cte);
|
129
130
|
//! Find a common table expression by name; returns nullptr if none exists
|
130
|
-
CommonTableExpressionInfo
|
131
|
+
optional_ptr<CommonTableExpressionInfo> FindCTE(const string &name, bool skip = false);
|
131
132
|
|
132
|
-
bool CTEIsAlreadyBound(CommonTableExpressionInfo
|
133
|
+
bool CTEIsAlreadyBound(CommonTableExpressionInfo &cte);
|
133
134
|
|
134
135
|
//! Add the view to the set of currently bound views - used for detecting recursive view definitions
|
135
|
-
void AddBoundView(ViewCatalogEntry
|
136
|
+
void AddBoundView(ViewCatalogEntry &view);
|
136
137
|
|
137
|
-
void PushExpressionBinder(ExpressionBinder
|
138
|
+
void PushExpressionBinder(ExpressionBinder &binder);
|
138
139
|
void PopExpressionBinder();
|
139
|
-
void SetActiveBinder(ExpressionBinder
|
140
|
-
ExpressionBinder
|
140
|
+
void SetActiveBinder(ExpressionBinder &binder);
|
141
|
+
ExpressionBinder &GetActiveBinder();
|
141
142
|
bool HasActiveBinder();
|
142
143
|
|
143
|
-
vector<ExpressionBinder
|
144
|
+
vector<reference<ExpressionBinder>> &GetActiveBinders();
|
144
145
|
|
145
146
|
void MergeCorrelatedColumns(vector<CorrelatedColumnInfo> &other);
|
146
147
|
//! Add a correlated column to this binder (if it does not exist)
|
@@ -184,7 +185,7 @@ public:
|
|
184
185
|
BindingMode GetBindingMode();
|
185
186
|
void AddTableName(string table_name);
|
186
187
|
const unordered_set<string> &GetTableNames();
|
187
|
-
SQLStatement
|
188
|
+
optional_ptr<SQLStatement> GetRootStatement() {
|
188
189
|
return root_statement;
|
189
190
|
}
|
190
191
|
|
@@ -194,7 +195,7 @@ private:
|
|
194
195
|
//! The parent binder (if any)
|
195
196
|
shared_ptr<Binder> parent;
|
196
197
|
//! The vector of active binders
|
197
|
-
vector<ExpressionBinder
|
198
|
+
vector<reference<ExpressionBinder>> active_binders;
|
198
199
|
//! The count of bound_tables
|
199
200
|
idx_t bound_tables;
|
200
201
|
//! Whether or not the binder has any unplanned subqueries that still need to be planned
|
@@ -206,13 +207,13 @@ private:
|
|
206
207
|
//! Whether or not the binder can contain NULLs as the root of expressions
|
207
208
|
bool can_contain_nulls = false;
|
208
209
|
//! The root statement of the query that is currently being parsed
|
209
|
-
SQLStatement
|
210
|
+
optional_ptr<SQLStatement> root_statement;
|
210
211
|
//! Binding mode
|
211
212
|
BindingMode mode = BindingMode::STANDARD_BINDING;
|
212
213
|
//! Table names extracted for BindingMode::EXTRACT_NAMES
|
213
214
|
unordered_set<string> table_names;
|
214
215
|
//! The set of bound views
|
215
|
-
|
216
|
+
reference_set_t<ViewCatalogEntry> bound_views;
|
216
217
|
|
217
218
|
private:
|
218
219
|
//! Bind the expressions of generated columns to check for errors
|
@@ -273,7 +274,7 @@ private:
|
|
273
274
|
|
274
275
|
unique_ptr<BoundTableRef> Bind(BaseTableRef &ref);
|
275
276
|
unique_ptr<BoundTableRef> Bind(JoinRef &ref);
|
276
|
-
unique_ptr<BoundTableRef> Bind(SubqueryRef &ref, CommonTableExpressionInfo
|
277
|
+
unique_ptr<BoundTableRef> Bind(SubqueryRef &ref, optional_ptr<CommonTableExpressionInfo> cte = nullptr);
|
277
278
|
unique_ptr<BoundTableRef> Bind(TableFunctionRef &ref);
|
278
279
|
unique_ptr<BoundTableRef> Bind(EmptyTableRef &ref);
|
279
280
|
unique_ptr<BoundTableRef> Bind(ExpressionListRef &ref);
|
@@ -349,7 +350,7 @@ private:
|
|
349
350
|
|
350
351
|
//! If only a schema name is provided (e.g. "a.b") then figure out if "a" is a schema or a catalog name
|
351
352
|
void BindSchemaOrCatalog(string &catalog_name, string &schema_name);
|
352
|
-
SchemaCatalogEntry
|
353
|
+
SchemaCatalogEntry &BindCreateSchema(CreateInfo &info);
|
353
354
|
|
354
355
|
unique_ptr<BoundQueryNode> BindSelectNode(SelectNode &statement, unique_ptr<BoundTableRef> from_table);
|
355
356
|
|