duckdb 0.7.2-dev1803.0 → 0.7.2-dev1898.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/package.json +1 -1
- package/src/duckdb/src/catalog/catalog.cpp +27 -27
- package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +6 -6
- package/src/duckdb/src/catalog/catalog_set.cpp +27 -25
- package/src/duckdb/src/catalog/default/default_functions.cpp +6 -6
- package/src/duckdb/src/catalog/default/default_types.cpp +4 -4
- package/src/duckdb/src/catalog/default/default_views.cpp +4 -4
- package/src/duckdb/src/catalog/dependency_list.cpp +7 -6
- package/src/duckdb/src/catalog/dependency_manager.cpp +44 -38
- package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +11 -6
- package/src/duckdb/src/common/sort/sorted_block.cpp +9 -4
- package/src/duckdb/src/common/types/batched_data_collection.cpp +2 -1
- package/src/duckdb/src/common/types/column_data_allocator.cpp +1 -0
- package/src/duckdb/src/common/types/vector.cpp +2 -2
- package/src/duckdb/src/common/vector_operations/vector_copy.cpp +14 -11
- package/src/duckdb/src/execution/operator/aggregate/distinct_aggregate_data.cpp +1 -1
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +51 -50
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +4 -0
- package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +14 -13
- package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +20 -20
- package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +3 -3
- package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
- package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +172 -63
- package/src/duckdb/src/function/cast/cast_function_set.cpp +2 -1
- package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +15 -9
- package/src/duckdb/src/function/scalar/sequence/nextval.cpp +29 -29
- package/src/duckdb/src/function/scalar/string/damerau_levenshtein.cpp +106 -0
- package/src/duckdb/src/function/scalar/string/regexp.cpp +145 -28
- package/src/duckdb/src/function/scalar/string_functions.cpp +1 -0
- package/src/duckdb/src/function/table/checkpoint.cpp +4 -4
- package/src/duckdb/src/function/table/system/duckdb_columns.cpp +24 -24
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +7 -6
- package/src/duckdb/src/function/table/system/duckdb_databases.cpp +1 -1
- package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +11 -11
- package/src/duckdb/src/function/table/system/pragma_database_size.cpp +1 -1
- package/src/duckdb/src/function/table/system/pragma_table_info.cpp +17 -18
- package/src/duckdb/src/function/table/table_scan.cpp +8 -11
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +9 -9
- package/src/duckdb/src/include/duckdb/catalog/catalog_entry_map.hpp +38 -0
- package/src/duckdb/src/include/duckdb/catalog/catalog_transaction.hpp +4 -3
- package/src/duckdb/src/include/duckdb/catalog/default/default_functions.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/default/default_types.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/default/default_views.hpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/dependency.hpp +4 -5
- package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +4 -5
- package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +10 -9
- package/src/duckdb/src/include/duckdb/common/allocator.hpp +2 -1
- package/src/duckdb/src/include/duckdb/common/field_writer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/helper.hpp +9 -0
- package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +29 -6
- package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +6 -5
- package/src/duckdb/src/include/duckdb/common/serializer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/common/types/row_data_collection.hpp +1 -0
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +2 -2
- package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +5 -5
- package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +2 -2
- package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +3 -2
- package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +4 -0
- package/src/duckdb/src/include/duckdb/main/client_config.hpp +5 -0
- package/src/duckdb/src/include/duckdb/main/database_manager.hpp +4 -3
- package/src/duckdb/src/include/duckdb/main/query_result.hpp +3 -2
- package/src/duckdb/src/include/duckdb/main/settings.hpp +19 -0
- package/src/duckdb/src/include/duckdb/optimizer/filter_combiner.hpp +7 -7
- package/src/duckdb/src/include/duckdb/optimizer/matcher/expression_matcher.hpp +11 -11
- package/src/duckdb/src/include/duckdb/optimizer/matcher/set_matcher.hpp +8 -8
- package/src/duckdb/src/include/duckdb/optimizer/rule/arithmetic_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/case_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/comparison_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/conjunction_simplification.hpp +2 -2
- package/src/duckdb/src/include/duckdb/optimizer/rule/constant_folding.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/date_part_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/distributivity.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/empty_needle_removal.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/enum_comparison.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/equal_or_null_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/in_clause_simplification.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/like_optimizations.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/move_constants.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/ordered_aggregate_optimizer.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/regex_optimizations.hpp +1 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/base_expression.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/expression_map.hpp +19 -6
- package/src/duckdb/src/include/duckdb/parser/expression_util.hpp +1 -1
- package/src/duckdb/src/include/duckdb/parser/parser.hpp +1 -7
- package/src/duckdb/src/include/duckdb/parser/parser_options.hpp +23 -0
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +5 -3
- package/src/duckdb/src/include/duckdb/planner/expression.hpp +5 -2
- package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -1
- package/src/duckdb/src/include/duckdb/planner/expression_binder/order_binder.hpp +3 -3
- package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +10 -2
- package/src/duckdb/src/include/duckdb/storage/buffer/buffer_pool.hpp +1 -0
- package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +49 -126
- package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +5 -5
- package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +159 -0
- package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +1 -0
- package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +6 -5
- package/src/duckdb/src/main/client_context.cpp +5 -3
- package/src/duckdb/src/main/config.cpp +2 -0
- package/src/duckdb/src/main/database.cpp +2 -1
- package/src/duckdb/src/main/database_manager.cpp +4 -4
- package/src/duckdb/src/main/settings/settings.cpp +36 -0
- package/src/duckdb/src/optimizer/common_aggregate_optimizer.cpp +2 -2
- package/src/duckdb/src/optimizer/cse_optimizer.cpp +4 -4
- package/src/duckdb/src/optimizer/deliminator.cpp +13 -11
- package/src/duckdb/src/optimizer/expression_rewriter.cpp +2 -2
- package/src/duckdb/src/optimizer/filter_combiner.cpp +67 -65
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -0
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +26 -25
- package/src/duckdb/src/optimizer/matcher/expression_matcher.cpp +23 -21
- package/src/duckdb/src/optimizer/rule/arithmetic_simplification.cpp +7 -6
- package/src/duckdb/src/optimizer/rule/case_simplification.cpp +2 -2
- package/src/duckdb/src/optimizer/rule/comparison_simplification.cpp +6 -7
- package/src/duckdb/src/optimizer/rule/conjunction_simplification.cpp +9 -8
- package/src/duckdb/src/optimizer/rule/constant_folding.cpp +7 -7
- package/src/duckdb/src/optimizer/rule/date_part_simplification.cpp +3 -3
- package/src/duckdb/src/optimizer/rule/distributivity.cpp +5 -5
- package/src/duckdb/src/optimizer/rule/empty_needle_removal.cpp +6 -6
- package/src/duckdb/src/optimizer/rule/enum_comparison.cpp +4 -4
- package/src/duckdb/src/optimizer/rule/equal_or_null_simplification.cpp +23 -26
- package/src/duckdb/src/optimizer/rule/in_clause_simplification_rule.cpp +2 -3
- package/src/duckdb/src/optimizer/rule/like_optimizations.cpp +3 -3
- package/src/duckdb/src/optimizer/rule/move_constants.cpp +6 -6
- package/src/duckdb/src/optimizer/rule/ordered_aggregate_optimizer.cpp +2 -2
- package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +3 -3
- package/src/duckdb/src/parser/expression_util.cpp +6 -6
- package/src/duckdb/src/parser/parser.cpp +1 -1
- package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +7 -3
- package/src/duckdb/src/parser/transform/helpers/transform_groupby.cpp +3 -3
- package/src/duckdb/src/parser/transformer.cpp +6 -5
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +2 -2
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +3 -3
- package/src/duckdb/src/planner/binder/query_node/bind_setop_node.cpp +5 -5
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +2 -2
- package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +4 -4
- package/src/duckdb/src/planner/expression_binder/order_binder.cpp +3 -3
- package/src/duckdb/src/storage/buffer/block_handle.cpp +3 -2
- package/src/duckdb/src/storage/buffer/block_manager.cpp +3 -1
- package/src/duckdb/src/storage/buffer/buffer_handle.cpp +1 -0
- package/src/duckdb/src/storage/buffer/buffer_pool_reservation.cpp +3 -0
- package/src/duckdb/src/storage/buffer_manager.cpp +35 -726
- package/src/duckdb/src/storage/checkpoint_manager.cpp +2 -2
- package/src/duckdb/src/storage/meta_block_reader.cpp +6 -5
- package/src/duckdb/src/storage/standard_buffer_manager.cpp +801 -0
- package/src/duckdb/src/storage/wal_replay.cpp +2 -2
- package/src/duckdb/src/transaction/meta_transaction.cpp +13 -13
- package/src/duckdb/src/transaction/transaction.cpp +1 -1
- package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
- package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +949 -947
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +16431 -16385
- package/src/duckdb/third_party/libpg_query/src_backend_parser_scan.cpp +503 -493
- package/src/duckdb/ub_src_function_scalar_string.cpp +2 -0
- package/src/duckdb/ub_src_storage.cpp +2 -0
@@ -14,7 +14,7 @@ ArithmeticSimplificationRule::ArithmeticSimplificationRule(ExpressionRewriter &r
|
|
14
14
|
op->matchers.push_back(make_uniq<ExpressionMatcher>());
|
15
15
|
op->policy = SetMatcher::Policy::SOME;
|
16
16
|
// we only match on simple arithmetic expressions (+, -, *, /)
|
17
|
-
op->function = make_uniq<ManyFunctionMatcher>(unordered_set<string> {"+", "-", "*", "
|
17
|
+
op->function = make_uniq<ManyFunctionMatcher>(unordered_set<string> {"+", "-", "*", "//"});
|
18
18
|
// and only with numeric results
|
19
19
|
op->type = make_uniq<IntegerTypeMatcher>();
|
20
20
|
op->matchers[0]->type = make_uniq<IntegerTypeMatcher>();
|
@@ -22,10 +22,10 @@ ArithmeticSimplificationRule::ArithmeticSimplificationRule(ExpressionRewriter &r
|
|
22
22
|
root = std::move(op);
|
23
23
|
}
|
24
24
|
|
25
|
-
unique_ptr<Expression> ArithmeticSimplificationRule::Apply(LogicalOperator &op, vector<Expression
|
25
|
+
unique_ptr<Expression> ArithmeticSimplificationRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
26
26
|
bool &changes_made, bool is_root) {
|
27
|
-
auto &root = bindings[0]
|
28
|
-
auto &constant = bindings[1]
|
27
|
+
auto &root = bindings[0].get().Cast<BoundFunctionExpression>();
|
28
|
+
auto &constant = bindings[1].get().Cast<BoundConstantExpression>();
|
29
29
|
int constant_child = root.children[0].get() == &constant ? 0 : 1;
|
30
30
|
D_ASSERT(root.children.size() == 2);
|
31
31
|
(void)root;
|
@@ -55,8 +55,7 @@ unique_ptr<Expression> ArithmeticSimplificationRule::Apply(LogicalOperator &op,
|
|
55
55
|
return ExpressionRewriter::ConstantOrNull(std::move(root.children[1 - constant_child]),
|
56
56
|
Value::Numeric(root.return_type, 0));
|
57
57
|
}
|
58
|
-
} else {
|
59
|
-
D_ASSERT(func_name == "/");
|
58
|
+
} else if (func_name == "//") {
|
60
59
|
if (constant_child == 1) {
|
61
60
|
if (constant.value == 1) {
|
62
61
|
// divide by 1, replace with non-constant child
|
@@ -66,6 +65,8 @@ unique_ptr<Expression> ArithmeticSimplificationRule::Apply(LogicalOperator &op,
|
|
66
65
|
return make_uniq<BoundConstantExpression>(Value(root.return_type));
|
67
66
|
}
|
68
67
|
}
|
68
|
+
} else {
|
69
|
+
throw InternalException("Unrecognized function name in ArithmeticSimplificationRule");
|
69
70
|
}
|
70
71
|
return nullptr;
|
71
72
|
}
|
@@ -11,9 +11,9 @@ CaseSimplificationRule::CaseSimplificationRule(ExpressionRewriter &rewriter) : R
|
|
11
11
|
root = std::move(op);
|
12
12
|
}
|
13
13
|
|
14
|
-
unique_ptr<Expression> CaseSimplificationRule::Apply(LogicalOperator &op, vector<Expression
|
14
|
+
unique_ptr<Expression> CaseSimplificationRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
15
15
|
bool &changes_made, bool is_root) {
|
16
|
-
auto &root = bindings[0]
|
16
|
+
auto &root = bindings[0].get().Cast<BoundCaseExpression>();
|
17
17
|
for (idx_t i = 0; i < root.case_checks.size(); i++) {
|
18
18
|
auto &case_check = root.case_checks[i];
|
19
19
|
if (case_check.when_expr->IsFoldable()) {
|
@@ -14,18 +14,17 @@ ComparisonSimplificationRule::ComparisonSimplificationRule(ExpressionRewriter &r
|
|
14
14
|
root = std::move(op);
|
15
15
|
}
|
16
16
|
|
17
|
-
unique_ptr<Expression> ComparisonSimplificationRule::Apply(LogicalOperator &op, vector<Expression
|
17
|
+
unique_ptr<Expression> ComparisonSimplificationRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
18
18
|
bool &changes_made, bool is_root) {
|
19
|
-
|
20
|
-
auto &
|
21
|
-
|
22
|
-
bool column_ref_left = expr.left.get() != constant_expr;
|
19
|
+
auto &expr = bindings[0].get().Cast<BoundComparisonExpression>();
|
20
|
+
auto &constant_expr = bindings[1].get();
|
21
|
+
bool column_ref_left = expr.left.get() != &constant_expr;
|
23
22
|
auto column_ref_expr = !column_ref_left ? expr.right.get() : expr.left.get();
|
24
23
|
// the constant_expr is a scalar expression that we have to fold
|
25
24
|
// use an ExpressionExecutor to execute the expression
|
26
|
-
D_ASSERT(constant_expr
|
25
|
+
D_ASSERT(constant_expr.IsFoldable());
|
27
26
|
Value constant_value;
|
28
|
-
if (!ExpressionExecutor::TryEvaluateScalar(GetContext(),
|
27
|
+
if (!ExpressionExecutor::TryEvaluateScalar(GetContext(), constant_expr, constant_value)) {
|
29
28
|
return nullptr;
|
30
29
|
}
|
31
30
|
if (constant_value.IsNull() && !(expr.type == ExpressionType::COMPARE_NOT_DISTINCT_FROM ||
|
@@ -15,9 +15,9 @@ ConjunctionSimplificationRule::ConjunctionSimplificationRule(ExpressionRewriter
|
|
15
15
|
}
|
16
16
|
|
17
17
|
unique_ptr<Expression> ConjunctionSimplificationRule::RemoveExpression(BoundConjunctionExpression &conj,
|
18
|
-
Expression
|
18
|
+
const Expression &expr) {
|
19
19
|
for (idx_t i = 0; i < conj.children.size(); i++) {
|
20
|
-
if (conj.children[i].get() == expr) {
|
20
|
+
if (conj.children[i].get() == &expr) {
|
21
21
|
// erase the expression
|
22
22
|
conj.children.erase(conj.children.begin() + i);
|
23
23
|
break;
|
@@ -30,15 +30,16 @@ unique_ptr<Expression> ConjunctionSimplificationRule::RemoveExpression(BoundConj
|
|
30
30
|
return nullptr;
|
31
31
|
}
|
32
32
|
|
33
|
-
unique_ptr<Expression> ConjunctionSimplificationRule::Apply(LogicalOperator &op,
|
34
|
-
|
35
|
-
|
36
|
-
auto
|
33
|
+
unique_ptr<Expression> ConjunctionSimplificationRule::Apply(LogicalOperator &op,
|
34
|
+
vector<reference<Expression>> &bindings, bool &changes_made,
|
35
|
+
bool is_root) {
|
36
|
+
auto &conjunction = bindings[0].get().Cast<BoundConjunctionExpression>();
|
37
|
+
auto &constant_expr = bindings[1].get();
|
37
38
|
// the constant_expr is a scalar expression that we have to fold
|
38
39
|
// use an ExpressionExecutor to execute the expression
|
39
|
-
D_ASSERT(constant_expr
|
40
|
+
D_ASSERT(constant_expr.IsFoldable());
|
40
41
|
Value constant_value;
|
41
|
-
if (!ExpressionExecutor::TryEvaluateScalar(GetContext(),
|
42
|
+
if (!ExpressionExecutor::TryEvaluateScalar(GetContext(), constant_expr, constant_value)) {
|
42
43
|
return nullptr;
|
43
44
|
}
|
44
45
|
constant_value = constant_value.DefaultCastAs(LogicalType::BOOLEAN);
|
@@ -10,9 +10,9 @@ namespace duckdb {
|
|
10
10
|
//! The ConstantFoldingExpressionMatcher matches on any scalar expression (i.e. Expression::IsFoldable is true)
|
11
11
|
class ConstantFoldingExpressionMatcher : public FoldableConstantMatcher {
|
12
12
|
public:
|
13
|
-
bool Match(Expression
|
13
|
+
bool Match(Expression &expr, vector<reference<Expression>> &bindings) override {
|
14
14
|
// we also do not match on ConstantExpressions, because we cannot fold those any further
|
15
|
-
if (expr
|
15
|
+
if (expr.type == ExpressionType::VALUE_CONSTANT) {
|
16
16
|
return false;
|
17
17
|
}
|
18
18
|
return FoldableConstantMatcher::Match(expr, bindings);
|
@@ -24,18 +24,18 @@ ConstantFoldingRule::ConstantFoldingRule(ExpressionRewriter &rewriter) : Rule(re
|
|
24
24
|
root = std::move(op);
|
25
25
|
}
|
26
26
|
|
27
|
-
unique_ptr<Expression> ConstantFoldingRule::Apply(LogicalOperator &op, vector<Expression
|
27
|
+
unique_ptr<Expression> ConstantFoldingRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
28
28
|
bool &changes_made, bool is_root) {
|
29
|
-
auto root = bindings[0];
|
29
|
+
auto &root = bindings[0].get();
|
30
30
|
// the root is a scalar expression that we have to fold
|
31
|
-
D_ASSERT(root
|
31
|
+
D_ASSERT(root.IsFoldable() && root.type != ExpressionType::VALUE_CONSTANT);
|
32
32
|
|
33
33
|
// use an ExpressionExecutor to execute the expression
|
34
34
|
Value result_value;
|
35
|
-
if (!ExpressionExecutor::TryEvaluateScalar(GetContext(),
|
35
|
+
if (!ExpressionExecutor::TryEvaluateScalar(GetContext(), root, result_value)) {
|
36
36
|
return nullptr;
|
37
37
|
}
|
38
|
-
D_ASSERT(result_value.type().InternalType() == root
|
38
|
+
D_ASSERT(result_value.type().InternalType() == root.return_type.InternalType());
|
39
39
|
// now get the value from the result vector and insert it back into the plan as a constant expression
|
40
40
|
return make_uniq<BoundConstantExpression>(result_value);
|
41
41
|
}
|
@@ -20,10 +20,10 @@ DatePartSimplificationRule::DatePartSimplificationRule(ExpressionRewriter &rewri
|
|
20
20
|
root = std::move(func);
|
21
21
|
}
|
22
22
|
|
23
|
-
unique_ptr<Expression> DatePartSimplificationRule::Apply(LogicalOperator &op, vector<Expression
|
23
|
+
unique_ptr<Expression> DatePartSimplificationRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
24
24
|
bool &changes_made, bool is_root) {
|
25
|
-
auto &date_part = bindings[0]
|
26
|
-
auto &constant_expr = bindings[1]
|
25
|
+
auto &date_part = bindings[0].get().Cast<BoundFunctionExpression>();
|
26
|
+
auto &constant_expr = bindings[1].get().Cast<BoundConstantExpression>();
|
27
27
|
auto &constant = constant_expr.value;
|
28
28
|
|
29
29
|
if (constant.IsNull()) {
|
@@ -18,10 +18,10 @@ void DistributivityRule::AddExpressionSet(Expression &expr, expression_set_t &se
|
|
18
18
|
if (expr.type == ExpressionType::CONJUNCTION_AND) {
|
19
19
|
auto &and_expr = expr.Cast<BoundConjunctionExpression>();
|
20
20
|
for (auto &child : and_expr.children) {
|
21
|
-
set.insert(child
|
21
|
+
set.insert(*child);
|
22
22
|
}
|
23
23
|
} else {
|
24
|
-
set.insert(
|
24
|
+
set.insert(expr);
|
25
25
|
}
|
26
26
|
}
|
27
27
|
|
@@ -53,9 +53,9 @@ unique_ptr<Expression> DistributivityRule::ExtractExpression(BoundConjunctionExp
|
|
53
53
|
return result;
|
54
54
|
}
|
55
55
|
|
56
|
-
unique_ptr<Expression> DistributivityRule::Apply(LogicalOperator &op, vector<Expression
|
56
|
+
unique_ptr<Expression> DistributivityRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
57
57
|
bool &changes_made, bool is_root) {
|
58
|
-
auto &initial_or = bindings[0]
|
58
|
+
auto &initial_or = bindings[0].get().Cast<BoundConjunctionExpression>();
|
59
59
|
|
60
60
|
// we want to find expressions that occur in each of the children of the OR
|
61
61
|
// i.e. (X AND A) OR (X AND B) => X occurs in all branches
|
@@ -88,7 +88,7 @@ unique_ptr<Expression> DistributivityRule::Apply(LogicalOperator &op, vector<Exp
|
|
88
88
|
D_ASSERT(initial_or.children.size() > 0);
|
89
89
|
|
90
90
|
// extract the expression from the first child of the OR
|
91
|
-
auto result = ExtractExpression(initial_or, 0, (
|
91
|
+
auto result = ExtractExpression(initial_or, 0, expr.get());
|
92
92
|
// now for the subsequent expressions, simply remove the expression
|
93
93
|
for (idx_t i = 1; i < initial_or.children.size(); i++) {
|
94
94
|
ExtractExpression(initial_or, i, *result);
|
@@ -21,25 +21,25 @@ EmptyNeedleRemovalRule::EmptyNeedleRemovalRule(ExpressionRewriter &rewriter) : R
|
|
21
21
|
root = std::move(func);
|
22
22
|
}
|
23
23
|
|
24
|
-
unique_ptr<Expression> EmptyNeedleRemovalRule::Apply(LogicalOperator &op, vector<Expression
|
24
|
+
unique_ptr<Expression> EmptyNeedleRemovalRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
25
25
|
bool &changes_made, bool is_root) {
|
26
|
-
auto &root = bindings[0]
|
26
|
+
auto &root = bindings[0].get().Cast<BoundFunctionExpression>();
|
27
27
|
D_ASSERT(root.children.size() == 2);
|
28
|
-
auto prefix_expr = bindings[2];
|
28
|
+
auto &prefix_expr = bindings[2].get();
|
29
29
|
|
30
30
|
// the constant_expr is a scalar expression that we have to fold
|
31
|
-
if (!prefix_expr
|
31
|
+
if (!prefix_expr.IsFoldable()) {
|
32
32
|
return nullptr;
|
33
33
|
}
|
34
34
|
D_ASSERT(root.return_type.id() == LogicalTypeId::BOOLEAN);
|
35
35
|
|
36
|
-
auto prefix_value = ExpressionExecutor::EvaluateScalar(GetContext(),
|
36
|
+
auto prefix_value = ExpressionExecutor::EvaluateScalar(GetContext(), prefix_expr);
|
37
37
|
|
38
38
|
if (prefix_value.IsNull()) {
|
39
39
|
return make_uniq<BoundConstantExpression>(Value(LogicalType::BOOLEAN));
|
40
40
|
}
|
41
41
|
|
42
|
-
D_ASSERT(prefix_value.type() == prefix_expr
|
42
|
+
D_ASSERT(prefix_value.type() == prefix_expr.return_type);
|
43
43
|
auto &needle_string = StringValue::Get(prefix_value);
|
44
44
|
|
45
45
|
// PREFIX('xyz', '') is TRUE
|
@@ -44,12 +44,12 @@ bool AreMatchesPossible(LogicalType &left, LogicalType &right) {
|
|
44
44
|
}
|
45
45
|
return false;
|
46
46
|
}
|
47
|
-
unique_ptr<Expression> EnumComparisonRule::Apply(LogicalOperator &op, vector<Expression
|
47
|
+
unique_ptr<Expression> EnumComparisonRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
48
48
|
bool &changes_made, bool is_root) {
|
49
49
|
|
50
|
-
auto &root = bindings[0]
|
51
|
-
auto &left_child = bindings[1]
|
52
|
-
auto &right_child = bindings[3]
|
50
|
+
auto &root = bindings[0].get().Cast<BoundComparisonExpression>();
|
51
|
+
auto &left_child = bindings[1].get().Cast<BoundCastExpression>();
|
52
|
+
auto &right_child = bindings[3].get().Cast<BoundCastExpression>();
|
53
53
|
|
54
54
|
if (!AreMatchesPossible(left_child.child->return_type, right_child.child->return_type)) {
|
55
55
|
vector<unique_ptr<Expression>> children;
|
@@ -37,31 +37,30 @@ EqualOrNullSimplification::EqualOrNullSimplification(ExpressionRewriter &rewrite
|
|
37
37
|
}
|
38
38
|
|
39
39
|
// a=b OR (a IS NULL AND b IS NULL) to a IS NOT DISTINCT FROM b
|
40
|
-
static unique_ptr<Expression> TryRewriteEqualOrIsNull(
|
41
|
-
if (equal_expr
|
40
|
+
static unique_ptr<Expression> TryRewriteEqualOrIsNull(Expression &equal_expr, Expression &and_expr) {
|
41
|
+
if (equal_expr.type != ExpressionType::COMPARE_EQUAL || and_expr.type != ExpressionType::CONJUNCTION_AND) {
|
42
42
|
return nullptr;
|
43
43
|
}
|
44
44
|
|
45
|
-
|
46
|
-
|
45
|
+
auto &equal_cast = equal_expr.Cast<BoundComparisonExpression>();
|
46
|
+
auto &and_cast = and_expr.Cast<BoundConjunctionExpression>();
|
47
47
|
|
48
|
-
if (and_cast
|
48
|
+
if (and_cast.children.size() != 2) {
|
49
49
|
return nullptr;
|
50
50
|
}
|
51
51
|
|
52
52
|
// Make sure on the AND conjuction the relevant conditions appear
|
53
|
-
|
54
|
-
|
55
|
-
bool valid = true;
|
53
|
+
auto &a_exp = *equal_cast.left;
|
54
|
+
auto &b_exp = *equal_cast.right;
|
56
55
|
bool a_is_null_found = false;
|
57
56
|
bool b_is_null_found = false;
|
58
57
|
|
59
|
-
for (const auto &item : and_cast
|
60
|
-
|
58
|
+
for (const auto &item : and_cast.children) {
|
59
|
+
auto &next_exp = *item;
|
61
60
|
|
62
|
-
if (next_exp
|
63
|
-
|
64
|
-
|
61
|
+
if (next_exp.type == ExpressionType::OPERATOR_IS_NULL) {
|
62
|
+
auto &next_exp_cast = next_exp.Cast<BoundOperatorExpression>();
|
63
|
+
auto &child = *next_exp_cast.children[0];
|
65
64
|
|
66
65
|
// Test for equality on both 'a' and 'b' expressions
|
67
66
|
if (Expression::Equals(child, a_exp)) {
|
@@ -69,37 +68,35 @@ static unique_ptr<Expression> TryRewriteEqualOrIsNull(const Expression *equal_ex
|
|
69
68
|
} else if (Expression::Equals(child, b_exp)) {
|
70
69
|
b_is_null_found = true;
|
71
70
|
} else {
|
72
|
-
|
73
|
-
break;
|
71
|
+
return nullptr;
|
74
72
|
}
|
75
73
|
} else {
|
76
|
-
|
77
|
-
break;
|
74
|
+
return nullptr;
|
78
75
|
}
|
79
76
|
}
|
80
|
-
if (
|
77
|
+
if (a_is_null_found && b_is_null_found) {
|
81
78
|
return make_uniq<BoundComparisonExpression>(ExpressionType::COMPARE_NOT_DISTINCT_FROM,
|
82
|
-
std::move(equal_cast
|
79
|
+
std::move(equal_cast.left), std::move(equal_cast.right));
|
83
80
|
}
|
84
81
|
return nullptr;
|
85
82
|
}
|
86
83
|
|
87
|
-
unique_ptr<Expression> EqualOrNullSimplification::Apply(LogicalOperator &op, vector<Expression
|
84
|
+
unique_ptr<Expression> EqualOrNullSimplification::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
88
85
|
bool &changes_made, bool is_root) {
|
89
|
-
const Expression
|
86
|
+
const Expression &or_exp = bindings[0].get();
|
90
87
|
|
91
|
-
if (or_exp
|
88
|
+
if (or_exp.type != ExpressionType::CONJUNCTION_OR) {
|
92
89
|
return nullptr;
|
93
90
|
}
|
94
91
|
|
95
|
-
const auto or_exp_cast = (
|
92
|
+
const auto &or_exp_cast = or_exp.Cast<BoundConjunctionExpression>();
|
96
93
|
|
97
|
-
if (or_exp_cast
|
94
|
+
if (or_exp_cast.children.size() != 2) {
|
98
95
|
return nullptr;
|
99
96
|
}
|
100
97
|
|
101
|
-
|
102
|
-
|
98
|
+
auto &left_exp = *or_exp_cast.children[0];
|
99
|
+
auto &right_exp = *or_exp_cast.children[1];
|
103
100
|
// Test for: a=b OR (a IS NULL AND b IS NULL)
|
104
101
|
auto first_try = TryRewriteEqualOrIsNull(left_exp, right_exp);
|
105
102
|
if (first_try) {
|
@@ -12,10 +12,9 @@ InClauseSimplificationRule::InClauseSimplificationRule(ExpressionRewriter &rewri
|
|
12
12
|
root = std::move(op);
|
13
13
|
}
|
14
14
|
|
15
|
-
unique_ptr<Expression> InClauseSimplificationRule::Apply(LogicalOperator &op, vector<Expression
|
15
|
+
unique_ptr<Expression> InClauseSimplificationRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
16
16
|
bool &changes_made, bool is_root) {
|
17
|
-
|
18
|
-
auto &expr = bindings[0]->Cast<BoundOperatorExpression>();
|
17
|
+
auto &expr = bindings[0].get().Cast<BoundOperatorExpression>();
|
19
18
|
if (expr.children[0]->expression_class != ExpressionClass::BOUND_CAST) {
|
20
19
|
return nullptr;
|
21
20
|
}
|
@@ -99,10 +99,10 @@ static bool PatternIsContains(const string &pattern) {
|
|
99
99
|
return true;
|
100
100
|
}
|
101
101
|
|
102
|
-
unique_ptr<Expression> LikeOptimizationRule::Apply(LogicalOperator &op, vector<Expression
|
102
|
+
unique_ptr<Expression> LikeOptimizationRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
103
103
|
bool &changes_made, bool is_root) {
|
104
|
-
auto &root = bindings[0]
|
105
|
-
auto &constant_expr = bindings[2]
|
104
|
+
auto &root = bindings[0].get().Cast<BoundFunctionExpression>();
|
105
|
+
auto &constant_expr = bindings[2].get().Cast<BoundConstantExpression>();
|
106
106
|
D_ASSERT(root.children.size() == 2);
|
107
107
|
|
108
108
|
if (constant_expr.value.IsNull()) {
|
@@ -28,12 +28,12 @@ MoveConstantsRule::MoveConstantsRule(ExpressionRewriter &rewriter) : Rule(rewrit
|
|
28
28
|
root = std::move(op);
|
29
29
|
}
|
30
30
|
|
31
|
-
unique_ptr<Expression> MoveConstantsRule::Apply(LogicalOperator &op, vector<Expression
|
32
|
-
bool is_root) {
|
33
|
-
auto &comparison = bindings[0]
|
34
|
-
auto &outer_constant = bindings[1]
|
35
|
-
auto &arithmetic = bindings[2]
|
36
|
-
auto &inner_constant = bindings[3]
|
31
|
+
unique_ptr<Expression> MoveConstantsRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
32
|
+
bool &changes_made, bool is_root) {
|
33
|
+
auto &comparison = bindings[0].get().Cast<BoundComparisonExpression>();
|
34
|
+
auto &outer_constant = bindings[1].get().Cast<BoundConstantExpression>();
|
35
|
+
auto &arithmetic = bindings[2].get().Cast<BoundFunctionExpression>();
|
36
|
+
auto &inner_constant = bindings[3].get().Cast<BoundConstantExpression>();
|
37
37
|
if (!TypeIsIntegral(arithmetic.return_type.InternalType())) {
|
38
38
|
return nullptr;
|
39
39
|
}
|
@@ -11,9 +11,9 @@ OrderedAggregateOptimizer::OrderedAggregateOptimizer(ExpressionRewriter &rewrite
|
|
11
11
|
root->expr_class = ExpressionClass::BOUND_AGGREGATE;
|
12
12
|
}
|
13
13
|
|
14
|
-
unique_ptr<Expression> OrderedAggregateOptimizer::Apply(LogicalOperator &op, vector<Expression
|
14
|
+
unique_ptr<Expression> OrderedAggregateOptimizer::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
15
15
|
bool &changes_made, bool is_root) {
|
16
|
-
auto &aggr = bindings[0]
|
16
|
+
auto &aggr = bindings[0].get().Cast<BoundAggregateExpression>();
|
17
17
|
if (!aggr.order_bys) {
|
18
18
|
// no ORDER BYs defined
|
19
19
|
return nullptr;
|
@@ -18,10 +18,10 @@ RegexOptimizationRule::RegexOptimizationRule(ExpressionRewriter &rewriter) : Rul
|
|
18
18
|
root = std::move(func);
|
19
19
|
}
|
20
20
|
|
21
|
-
unique_ptr<Expression> RegexOptimizationRule::Apply(LogicalOperator &op, vector<Expression
|
21
|
+
unique_ptr<Expression> RegexOptimizationRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
|
22
22
|
bool &changes_made, bool is_root) {
|
23
|
-
auto &root = bindings[0]
|
24
|
-
auto &constant_expr = bindings[2]
|
23
|
+
auto &root = bindings[0].get().Cast<BoundFunctionExpression>();
|
24
|
+
auto &constant_expr = bindings[2].get().Cast<BoundConstantExpression>();
|
25
25
|
D_ASSERT(root.children.size() == 2);
|
26
26
|
|
27
27
|
if (constant_expr.value.IsNull()) {
|
@@ -18,7 +18,7 @@ bool ExpressionUtil::ExpressionListEquals(const vector<unique_ptr<T>> &a, const
|
|
18
18
|
return true;
|
19
19
|
}
|
20
20
|
|
21
|
-
template <class T>
|
21
|
+
template <class T, class EXPRESSION_MAP>
|
22
22
|
bool ExpressionUtil::ExpressionSetEquals(const vector<unique_ptr<T>> &a, const vector<unique_ptr<T>> &b) {
|
23
23
|
if (a.size() != b.size()) {
|
24
24
|
return false;
|
@@ -26,14 +26,14 @@ bool ExpressionUtil::ExpressionSetEquals(const vector<unique_ptr<T>> &a, const v
|
|
26
26
|
// we create a map of expression -> count for the left side
|
27
27
|
// we keep the count because the same expression can occur multiple times (e.g. "1 AND 1" is legal)
|
28
28
|
// in this case we track the following value: map["Constant(1)"] = 2
|
29
|
-
|
29
|
+
EXPRESSION_MAP map;
|
30
30
|
for (idx_t i = 0; i < a.size(); i++) {
|
31
|
-
map[a[i]
|
31
|
+
map[*a[i]]++;
|
32
32
|
}
|
33
33
|
// now on the right side we reduce the counts again
|
34
34
|
// if the conjunctions are identical, all the counts will be 0 after the
|
35
35
|
for (auto &expr : b) {
|
36
|
-
auto entry = map.find(expr
|
36
|
+
auto entry = map.find(*expr);
|
37
37
|
// first we check if we can find the expression in the map at all
|
38
38
|
if (entry == map.end()) {
|
39
39
|
return false;
|
@@ -62,11 +62,11 @@ bool ExpressionUtil::ListEquals(const vector<unique_ptr<Expression>> &a, const v
|
|
62
62
|
|
63
63
|
bool ExpressionUtil::SetEquals(const vector<unique_ptr<ParsedExpression>> &a,
|
64
64
|
const vector<unique_ptr<ParsedExpression>> &b) {
|
65
|
-
return ExpressionSetEquals<ParsedExpression
|
65
|
+
return ExpressionSetEquals<ParsedExpression, parsed_expression_map_t<idx_t>>(a, b);
|
66
66
|
}
|
67
67
|
|
68
68
|
bool ExpressionUtil::SetEquals(const vector<unique_ptr<Expression>> &a, const vector<unique_ptr<Expression>> &b) {
|
69
|
-
return ExpressionSetEquals<Expression
|
69
|
+
return ExpressionSetEquals<Expression, expression_map_t<idx_t>>(a, b);
|
70
70
|
}
|
71
71
|
|
72
72
|
} // namespace duckdb
|
@@ -125,7 +125,7 @@ end:
|
|
125
125
|
}
|
126
126
|
|
127
127
|
void Parser::ParseQuery(const string &query) {
|
128
|
-
Transformer transformer(options
|
128
|
+
Transformer transformer(options);
|
129
129
|
string parser_error;
|
130
130
|
{
|
131
131
|
// check if there are any unicode spaces in the string
|
@@ -10,6 +10,7 @@
|
|
10
10
|
#include "duckdb/parser/statement/select_statement.hpp"
|
11
11
|
#include "duckdb/parser/query_node/select_node.hpp"
|
12
12
|
#include "duckdb/parser/tableref/emptytableref.hpp"
|
13
|
+
#include "duckdb/parser/parser_options.hpp"
|
13
14
|
#include "duckdb/parser/transformer.hpp"
|
14
15
|
|
15
16
|
namespace duckdb {
|
@@ -24,12 +25,15 @@ unique_ptr<ParsedExpression> Transformer::TransformUnaryOperator(const string &o
|
|
24
25
|
return std::move(result);
|
25
26
|
}
|
26
27
|
|
27
|
-
unique_ptr<ParsedExpression> Transformer::TransformBinaryOperator(
|
28
|
+
unique_ptr<ParsedExpression> Transformer::TransformBinaryOperator(string op, unique_ptr<ParsedExpression> left,
|
28
29
|
unique_ptr<ParsedExpression> right) {
|
29
30
|
vector<unique_ptr<ParsedExpression>> children;
|
30
31
|
children.push_back(std::move(left));
|
31
32
|
children.push_back(std::move(right));
|
32
33
|
|
34
|
+
if (options.integer_division && op == "/") {
|
35
|
+
op = "//";
|
36
|
+
}
|
33
37
|
if (op == "~" || op == "!~") {
|
34
38
|
// rewrite 'asdf' SIMILAR TO '.*sd.*' into regexp_full_match('asdf', '.*sd.*')
|
35
39
|
bool invert_similar = op == "!~";
|
@@ -47,7 +51,7 @@ unique_ptr<ParsedExpression> Transformer::TransformBinaryOperator(const string &
|
|
47
51
|
return make_uniq<ComparisonExpression>(target_type, std::move(children[0]), std::move(children[1]));
|
48
52
|
}
|
49
53
|
// not a special operator: convert to a function expression
|
50
|
-
auto result = make_uniq<FunctionExpression>(op, std::move(children));
|
54
|
+
auto result = make_uniq<FunctionExpression>(std::move(op), std::move(children));
|
51
55
|
result->is_operator = true;
|
52
56
|
return std::move(result);
|
53
57
|
}
|
@@ -197,7 +201,7 @@ unique_ptr<ParsedExpression> Transformer::TransformAExprInternal(duckdb_libpgque
|
|
197
201
|
// postfix operator, only ! is currently supported
|
198
202
|
return TransformUnaryOperator(name + "__postfix", std::move(left_expr));
|
199
203
|
} else {
|
200
|
-
return TransformBinaryOperator(name, std::move(left_expr), std::move(right_expr));
|
204
|
+
return TransformBinaryOperator(std::move(name), std::move(left_expr), std::move(right_expr));
|
201
205
|
}
|
202
206
|
}
|
203
207
|
|
@@ -22,7 +22,7 @@ static void CheckGroupingSetCubes(idx_t current_count, idx_t cube_count) {
|
|
22
22
|
}
|
23
23
|
|
24
24
|
struct GroupingExpressionMap {
|
25
|
-
|
25
|
+
parsed_expression_map_t<idx_t> map;
|
26
26
|
};
|
27
27
|
|
28
28
|
static GroupingSet VectorToGroupingSet(vector<idx_t> &indexes) {
|
@@ -49,11 +49,11 @@ void Transformer::AddGroupByExpression(unique_ptr<ParsedExpression> expression,
|
|
49
49
|
return;
|
50
50
|
}
|
51
51
|
}
|
52
|
-
auto entry = map.map.find(expression
|
52
|
+
auto entry = map.map.find(*expression);
|
53
53
|
idx_t result_idx;
|
54
54
|
if (entry == map.map.end()) {
|
55
55
|
result_idx = result.group_expressions.size();
|
56
|
-
map.map[expression
|
56
|
+
map.map[*expression] = result_idx;
|
57
57
|
result.group_expressions.push_back(std::move(expression));
|
58
58
|
} else {
|
59
59
|
result_idx = entry->second;
|
@@ -4,6 +4,7 @@
|
|
4
4
|
#include "duckdb/parser/statement/list.hpp"
|
5
5
|
#include "duckdb/parser/tableref/emptytableref.hpp"
|
6
6
|
#include "duckdb/parser/query_node/select_node.hpp"
|
7
|
+
#include "duckdb/parser/parser_options.hpp"
|
7
8
|
|
8
9
|
namespace duckdb {
|
9
10
|
|
@@ -21,12 +22,12 @@ StackChecker::StackChecker(StackChecker &&other) noexcept
|
|
21
22
|
other.stack_usage = 0;
|
22
23
|
}
|
23
24
|
|
24
|
-
Transformer::Transformer(
|
25
|
-
: parent(nullptr),
|
25
|
+
Transformer::Transformer(ParserOptions &options)
|
26
|
+
: parent(nullptr), options(options), stack_depth(DConstants::INVALID_INDEX) {
|
26
27
|
}
|
27
28
|
|
28
29
|
Transformer::Transformer(Transformer *parent)
|
29
|
-
: parent(parent),
|
30
|
+
: parent(parent), options(parent->options), stack_depth(DConstants::INVALID_INDEX) {
|
30
31
|
}
|
31
32
|
|
32
33
|
Transformer::~Transformer() {
|
@@ -63,10 +64,10 @@ StackChecker Transformer::StackCheck(idx_t extra_stack) {
|
|
63
64
|
node = node->parent;
|
64
65
|
}
|
65
66
|
D_ASSERT(node->stack_depth != DConstants::INVALID_INDEX);
|
66
|
-
if (node->stack_depth + extra_stack >= max_expression_depth) {
|
67
|
+
if (node->stack_depth + extra_stack >= options.max_expression_depth) {
|
67
68
|
throw ParserException("Max expression depth limit of %lld exceeded. Use \"SET max_expression_depth TO x\" to "
|
68
69
|
"increase the maximum expression depth.",
|
69
|
-
max_expression_depth);
|
70
|
+
options.max_expression_depth);
|
70
71
|
}
|
71
72
|
return StackChecker(*node, extra_stack);
|
72
73
|
}
|
@@ -233,11 +233,11 @@ BindResult BaseSelectBinder::BindAggregate(FunctionExpression &aggr, AggregateFu
|
|
233
233
|
|
234
234
|
// check for all the aggregates if this aggregate already exists
|
235
235
|
idx_t aggr_index;
|
236
|
-
auto entry = node.aggregate_map.find(aggregate
|
236
|
+
auto entry = node.aggregate_map.find(*aggregate);
|
237
237
|
if (entry == node.aggregate_map.end()) {
|
238
238
|
// new aggregate: insert into aggregate list
|
239
239
|
aggr_index = node.aggregates.size();
|
240
|
-
node.aggregate_map
|
240
|
+
node.aggregate_map[*aggregate] = aggr_index;
|
241
241
|
node.aggregates.push_back(std::move(aggregate));
|
242
242
|
} else {
|
243
243
|
// duplicate aggregate: simplify refer to this aggregate
|
@@ -329,7 +329,7 @@ unique_ptr<BoundQueryNode> Binder::BindSelectNode(SelectNode &statement, unique_
|
|
329
329
|
|
330
330
|
// create a mapping of (alias -> index) and a mapping of (Expression -> index) for the SELECT list
|
331
331
|
case_insensitive_map_t<idx_t> alias_map;
|
332
|
-
|
332
|
+
parsed_expression_map_t<idx_t> projection_map;
|
333
333
|
for (idx_t i = 0; i < statement.select_list.size(); i++) {
|
334
334
|
auto &expr = statement.select_list[i];
|
335
335
|
result->names.push_back(expr->GetName());
|
@@ -338,7 +338,7 @@ unique_ptr<BoundQueryNode> Binder::BindSelectNode(SelectNode &statement, unique_
|
|
338
338
|
alias_map[expr->alias] = i;
|
339
339
|
result->names[i] = expr->alias;
|
340
340
|
}
|
341
|
-
projection_map[expr
|
341
|
+
projection_map[*expr] = i;
|
342
342
|
result->original_expressions.push_back(expr->Copy());
|
343
343
|
}
|
344
344
|
result->column_count = statement.select_list.size();
|
@@ -391,7 +391,7 @@ unique_ptr<BoundQueryNode> Binder::BindSelectNode(SelectNode &statement, unique_
|
|
391
391
|
// hence we convert "a" -> "test.a" in the unbound expression
|
392
392
|
unbound_groups[i] = std::move(group_binder.unbound_expression);
|
393
393
|
ExpressionBinder::QualifyColumnNames(*this, unbound_groups[i]);
|
394
|
-
info.map[unbound_groups[i]
|
394
|
+
info.map[*unbound_groups[i]] = i;
|
395
395
|
}
|
396
396
|
}
|
397
397
|
result->groups.grouping_sets = std::move(statement.groups.grouping_sets);
|