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.
Files changed (158) hide show
  1. package/package.json +1 -1
  2. package/src/duckdb/src/catalog/catalog.cpp +27 -27
  3. package/src/duckdb/src/catalog/catalog_entry/duck_schema_entry.cpp +6 -6
  4. package/src/duckdb/src/catalog/catalog_set.cpp +27 -25
  5. package/src/duckdb/src/catalog/default/default_functions.cpp +6 -6
  6. package/src/duckdb/src/catalog/default/default_types.cpp +4 -4
  7. package/src/duckdb/src/catalog/default/default_views.cpp +4 -4
  8. package/src/duckdb/src/catalog/dependency_list.cpp +7 -6
  9. package/src/duckdb/src/catalog/dependency_manager.cpp +44 -38
  10. package/src/duckdb/src/common/serializer/buffered_file_reader.cpp +11 -6
  11. package/src/duckdb/src/common/sort/sorted_block.cpp +9 -4
  12. package/src/duckdb/src/common/types/batched_data_collection.cpp +2 -1
  13. package/src/duckdb/src/common/types/column_data_allocator.cpp +1 -0
  14. package/src/duckdb/src/common/types/vector.cpp +2 -2
  15. package/src/duckdb/src/common/vector_operations/vector_copy.cpp +14 -11
  16. package/src/duckdb/src/execution/operator/aggregate/distinct_aggregate_data.cpp +1 -1
  17. package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +51 -50
  18. package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +4 -0
  19. package/src/duckdb/src/execution/operator/persistent/physical_batch_insert.cpp +14 -13
  20. package/src/duckdb/src/execution/operator/persistent/physical_insert.cpp +20 -20
  21. package/src/duckdb/src/execution/operator/schema/physical_create_table.cpp +2 -2
  22. package/src/duckdb/src/execution/physical_plan/plan_create_index.cpp +1 -1
  23. package/src/duckdb/src/execution/physical_plan/plan_create_table.cpp +3 -3
  24. package/src/duckdb/src/execution/physical_plan/plan_delete.cpp +1 -1
  25. package/src/duckdb/src/execution/physical_plan/plan_insert.cpp +1 -1
  26. package/src/duckdb/src/execution/physical_plan/plan_update.cpp +1 -1
  27. package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +172 -63
  28. package/src/duckdb/src/function/cast/cast_function_set.cpp +2 -1
  29. package/src/duckdb/src/function/scalar/operators/arithmetic.cpp +15 -9
  30. package/src/duckdb/src/function/scalar/sequence/nextval.cpp +29 -29
  31. package/src/duckdb/src/function/scalar/string/damerau_levenshtein.cpp +106 -0
  32. package/src/duckdb/src/function/scalar/string/regexp.cpp +145 -28
  33. package/src/duckdb/src/function/scalar/string_functions.cpp +1 -0
  34. package/src/duckdb/src/function/table/checkpoint.cpp +4 -4
  35. package/src/duckdb/src/function/table/system/duckdb_columns.cpp +24 -24
  36. package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +7 -6
  37. package/src/duckdb/src/function/table/system/duckdb_databases.cpp +1 -1
  38. package/src/duckdb/src/function/table/system/duckdb_dependencies.cpp +11 -11
  39. package/src/duckdb/src/function/table/system/pragma_database_size.cpp +1 -1
  40. package/src/duckdb/src/function/table/system/pragma_table_info.cpp +17 -18
  41. package/src/duckdb/src/function/table/table_scan.cpp +8 -11
  42. package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
  43. package/src/duckdb/src/include/duckdb/catalog/catalog.hpp +9 -9
  44. package/src/duckdb/src/include/duckdb/catalog/catalog_entry_map.hpp +38 -0
  45. package/src/duckdb/src/include/duckdb/catalog/catalog_transaction.hpp +4 -3
  46. package/src/duckdb/src/include/duckdb/catalog/default/default_functions.hpp +2 -2
  47. package/src/duckdb/src/include/duckdb/catalog/default/default_types.hpp +2 -2
  48. package/src/duckdb/src/include/duckdb/catalog/default/default_views.hpp +2 -2
  49. package/src/duckdb/src/include/duckdb/catalog/dependency.hpp +4 -5
  50. package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +4 -5
  51. package/src/duckdb/src/include/duckdb/catalog/dependency_manager.hpp +10 -9
  52. package/src/duckdb/src/include/duckdb/common/allocator.hpp +2 -1
  53. package/src/duckdb/src/include/duckdb/common/field_writer.hpp +1 -1
  54. package/src/duckdb/src/include/duckdb/common/helper.hpp +9 -0
  55. package/src/duckdb/src/include/duckdb/common/optional_ptr.hpp +29 -6
  56. package/src/duckdb/src/include/duckdb/common/serializer/buffered_file_reader.hpp +6 -5
  57. package/src/duckdb/src/include/duckdb/common/serializer.hpp +1 -1
  58. package/src/duckdb/src/include/duckdb/common/types/row_data_collection.hpp +1 -0
  59. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_batch_insert.hpp +2 -2
  60. package/src/duckdb/src/include/duckdb/execution/operator/persistent/physical_insert.hpp +5 -5
  61. package/src/duckdb/src/include/duckdb/execution/operator/schema/physical_create_table.hpp +2 -2
  62. package/src/duckdb/src/include/duckdb/function/cast/default_casts.hpp +3 -2
  63. package/src/duckdb/src/include/duckdb/function/scalar/string_functions.hpp +4 -0
  64. package/src/duckdb/src/include/duckdb/main/client_config.hpp +5 -0
  65. package/src/duckdb/src/include/duckdb/main/database_manager.hpp +4 -3
  66. package/src/duckdb/src/include/duckdb/main/query_result.hpp +3 -2
  67. package/src/duckdb/src/include/duckdb/main/settings.hpp +19 -0
  68. package/src/duckdb/src/include/duckdb/optimizer/filter_combiner.hpp +7 -7
  69. package/src/duckdb/src/include/duckdb/optimizer/matcher/expression_matcher.hpp +11 -11
  70. package/src/duckdb/src/include/duckdb/optimizer/matcher/set_matcher.hpp +8 -8
  71. package/src/duckdb/src/include/duckdb/optimizer/rule/arithmetic_simplification.hpp +1 -1
  72. package/src/duckdb/src/include/duckdb/optimizer/rule/case_simplification.hpp +1 -1
  73. package/src/duckdb/src/include/duckdb/optimizer/rule/comparison_simplification.hpp +1 -1
  74. package/src/duckdb/src/include/duckdb/optimizer/rule/conjunction_simplification.hpp +2 -2
  75. package/src/duckdb/src/include/duckdb/optimizer/rule/constant_folding.hpp +1 -1
  76. package/src/duckdb/src/include/duckdb/optimizer/rule/date_part_simplification.hpp +1 -1
  77. package/src/duckdb/src/include/duckdb/optimizer/rule/distributivity.hpp +1 -1
  78. package/src/duckdb/src/include/duckdb/optimizer/rule/empty_needle_removal.hpp +1 -1
  79. package/src/duckdb/src/include/duckdb/optimizer/rule/enum_comparison.hpp +1 -1
  80. package/src/duckdb/src/include/duckdb/optimizer/rule/equal_or_null_simplification.hpp +1 -1
  81. package/src/duckdb/src/include/duckdb/optimizer/rule/in_clause_simplification.hpp +1 -1
  82. package/src/duckdb/src/include/duckdb/optimizer/rule/like_optimizations.hpp +1 -1
  83. package/src/duckdb/src/include/duckdb/optimizer/rule/move_constants.hpp +1 -1
  84. package/src/duckdb/src/include/duckdb/optimizer/rule/ordered_aggregate_optimizer.hpp +1 -1
  85. package/src/duckdb/src/include/duckdb/optimizer/rule/regex_optimizations.hpp +1 -1
  86. package/src/duckdb/src/include/duckdb/optimizer/rule.hpp +2 -2
  87. package/src/duckdb/src/include/duckdb/parser/base_expression.hpp +1 -1
  88. package/src/duckdb/src/include/duckdb/parser/expression_map.hpp +19 -6
  89. package/src/duckdb/src/include/duckdb/parser/expression_util.hpp +1 -1
  90. package/src/duckdb/src/include/duckdb/parser/parser.hpp +1 -7
  91. package/src/duckdb/src/include/duckdb/parser/parser_options.hpp +23 -0
  92. package/src/duckdb/src/include/duckdb/parser/transformer.hpp +5 -3
  93. package/src/duckdb/src/include/duckdb/planner/expression.hpp +5 -2
  94. package/src/duckdb/src/include/duckdb/planner/expression_binder/base_select_binder.hpp +1 -1
  95. package/src/duckdb/src/include/duckdb/planner/expression_binder/order_binder.hpp +3 -3
  96. package/src/duckdb/src/include/duckdb/storage/buffer/block_handle.hpp +10 -2
  97. package/src/duckdb/src/include/duckdb/storage/buffer/buffer_pool.hpp +1 -0
  98. package/src/duckdb/src/include/duckdb/storage/buffer_manager.hpp +49 -126
  99. package/src/duckdb/src/include/duckdb/storage/meta_block_reader.hpp +5 -5
  100. package/src/duckdb/src/include/duckdb/storage/standard_buffer_manager.hpp +159 -0
  101. package/src/duckdb/src/include/duckdb/storage/table/column_segment.hpp +1 -0
  102. package/src/duckdb/src/include/duckdb/transaction/meta_transaction.hpp +6 -5
  103. package/src/duckdb/src/main/client_context.cpp +5 -3
  104. package/src/duckdb/src/main/config.cpp +2 -0
  105. package/src/duckdb/src/main/database.cpp +2 -1
  106. package/src/duckdb/src/main/database_manager.cpp +4 -4
  107. package/src/duckdb/src/main/settings/settings.cpp +36 -0
  108. package/src/duckdb/src/optimizer/common_aggregate_optimizer.cpp +2 -2
  109. package/src/duckdb/src/optimizer/cse_optimizer.cpp +4 -4
  110. package/src/duckdb/src/optimizer/deliminator.cpp +13 -11
  111. package/src/duckdb/src/optimizer/expression_rewriter.cpp +2 -2
  112. package/src/duckdb/src/optimizer/filter_combiner.cpp +67 -65
  113. package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +1 -0
  114. package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +26 -25
  115. package/src/duckdb/src/optimizer/matcher/expression_matcher.cpp +23 -21
  116. package/src/duckdb/src/optimizer/rule/arithmetic_simplification.cpp +7 -6
  117. package/src/duckdb/src/optimizer/rule/case_simplification.cpp +2 -2
  118. package/src/duckdb/src/optimizer/rule/comparison_simplification.cpp +6 -7
  119. package/src/duckdb/src/optimizer/rule/conjunction_simplification.cpp +9 -8
  120. package/src/duckdb/src/optimizer/rule/constant_folding.cpp +7 -7
  121. package/src/duckdb/src/optimizer/rule/date_part_simplification.cpp +3 -3
  122. package/src/duckdb/src/optimizer/rule/distributivity.cpp +5 -5
  123. package/src/duckdb/src/optimizer/rule/empty_needle_removal.cpp +6 -6
  124. package/src/duckdb/src/optimizer/rule/enum_comparison.cpp +4 -4
  125. package/src/duckdb/src/optimizer/rule/equal_or_null_simplification.cpp +23 -26
  126. package/src/duckdb/src/optimizer/rule/in_clause_simplification_rule.cpp +2 -3
  127. package/src/duckdb/src/optimizer/rule/like_optimizations.cpp +3 -3
  128. package/src/duckdb/src/optimizer/rule/move_constants.cpp +6 -6
  129. package/src/duckdb/src/optimizer/rule/ordered_aggregate_optimizer.cpp +2 -2
  130. package/src/duckdb/src/optimizer/rule/regex_optimizations.cpp +3 -3
  131. package/src/duckdb/src/parser/expression_util.cpp +6 -6
  132. package/src/duckdb/src/parser/parser.cpp +1 -1
  133. package/src/duckdb/src/parser/transform/expression/transform_operator.cpp +7 -3
  134. package/src/duckdb/src/parser/transform/helpers/transform_groupby.cpp +3 -3
  135. package/src/duckdb/src/parser/transformer.cpp +6 -5
  136. package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +2 -2
  137. package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +3 -3
  138. package/src/duckdb/src/planner/binder/query_node/bind_setop_node.cpp +5 -5
  139. package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +2 -2
  140. package/src/duckdb/src/planner/expression_binder/base_select_binder.cpp +4 -4
  141. package/src/duckdb/src/planner/expression_binder/order_binder.cpp +3 -3
  142. package/src/duckdb/src/storage/buffer/block_handle.cpp +3 -2
  143. package/src/duckdb/src/storage/buffer/block_manager.cpp +3 -1
  144. package/src/duckdb/src/storage/buffer/buffer_handle.cpp +1 -0
  145. package/src/duckdb/src/storage/buffer/buffer_pool_reservation.cpp +3 -0
  146. package/src/duckdb/src/storage/buffer_manager.cpp +35 -726
  147. package/src/duckdb/src/storage/checkpoint_manager.cpp +2 -2
  148. package/src/duckdb/src/storage/meta_block_reader.cpp +6 -5
  149. package/src/duckdb/src/storage/standard_buffer_manager.cpp +801 -0
  150. package/src/duckdb/src/storage/wal_replay.cpp +2 -2
  151. package/src/duckdb/src/transaction/meta_transaction.cpp +13 -13
  152. package/src/duckdb/src/transaction/transaction.cpp +1 -1
  153. package/src/duckdb/src/transaction/transaction_context.cpp +1 -1
  154. package/src/duckdb/third_party/libpg_query/include/parser/gram.hpp +949 -947
  155. package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +16431 -16385
  156. package/src/duckdb/third_party/libpg_query/src_backend_parser_scan.cpp +503 -493
  157. package/src/duckdb/ub_src_function_scalar_string.cpp +2 -0
  158. 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 *> &bindings,
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]->Cast<BoundFunctionExpression>();
28
- auto &constant = bindings[1]->Cast<BoundConstantExpression>();
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 *> &bindings,
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]->Cast<BoundCaseExpression>();
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 *> &bindings,
17
+ unique_ptr<Expression> ComparisonSimplificationRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
18
18
  bool &changes_made, bool is_root) {
19
- D_ASSERT(bindings[0]->expression_class == ExpressionClass::BOUND_COMPARISON);
20
- auto &expr = bindings[0]->Cast<BoundComparisonExpression>();
21
- auto constant_expr = bindings[1];
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->IsFoldable());
25
+ D_ASSERT(constant_expr.IsFoldable());
27
26
  Value constant_value;
28
- if (!ExpressionExecutor::TryEvaluateScalar(GetContext(), *constant_expr, constant_value)) {
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 *expr) {
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, vector<Expression *> &bindings,
34
- bool &changes_made, bool is_root) {
35
- auto &conjunction = bindings[0]->Cast<BoundConjunctionExpression>();
36
- auto constant_expr = bindings[1];
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->IsFoldable());
40
+ D_ASSERT(constant_expr.IsFoldable());
40
41
  Value constant_value;
41
- if (!ExpressionExecutor::TryEvaluateScalar(GetContext(), *constant_expr, constant_value)) {
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 *expr, vector<Expression *> &bindings) override {
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->type == ExpressionType::VALUE_CONSTANT) {
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 *> &bindings,
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->IsFoldable() && root->type != ExpressionType::VALUE_CONSTANT);
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(), *root, result_value)) {
35
+ if (!ExpressionExecutor::TryEvaluateScalar(GetContext(), root, result_value)) {
36
36
  return nullptr;
37
37
  }
38
- D_ASSERT(result_value.type().InternalType() == root->return_type.InternalType());
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 *> &bindings,
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]->Cast<BoundFunctionExpression>();
26
- auto &constant_expr = bindings[1]->Cast<BoundConstantExpression>();
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.get());
21
+ set.insert(*child);
22
22
  }
23
23
  } else {
24
- set.insert(&expr);
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 *> &bindings,
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]->Cast<BoundConjunctionExpression>();
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, (Expression &)*expr);
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 *> &bindings,
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]->Cast<BoundFunctionExpression>();
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->IsFoldable()) {
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(), *prefix_expr);
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->return_type);
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 *> &bindings,
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]->Cast<BoundComparisonExpression>();
51
- auto &left_child = bindings[1]->Cast<BoundCastExpression>();
52
- auto &right_child = bindings[3]->Cast<BoundCastExpression>();
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(const Expression *equal_expr, const Expression *and_expr) {
41
- if (equal_expr->type != ExpressionType::COMPARE_EQUAL || and_expr->type != ExpressionType::CONJUNCTION_AND) {
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
- const auto equal_cast = (BoundComparisonExpression *)equal_expr;
46
- const auto and_cast = (BoundConjunctionExpression *)and_expr;
45
+ auto &equal_cast = equal_expr.Cast<BoundComparisonExpression>();
46
+ auto &and_cast = and_expr.Cast<BoundConjunctionExpression>();
47
47
 
48
- if (and_cast->children.size() != 2) {
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
- const auto a_exp = equal_cast->left.get();
54
- const auto b_exp = equal_cast->right.get();
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->children) {
60
- const auto next_exp = item.get();
58
+ for (const auto &item : and_cast.children) {
59
+ auto &next_exp = *item;
61
60
 
62
- if (next_exp->type == ExpressionType::OPERATOR_IS_NULL) {
63
- const auto next_exp_cast = (BoundOperatorExpression *)next_exp;
64
- const auto child = next_exp_cast->children[0].get();
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
- valid = false;
73
- break;
71
+ return nullptr;
74
72
  }
75
73
  } else {
76
- valid = false;
77
- break;
74
+ return nullptr;
78
75
  }
79
76
  }
80
- if (valid && a_is_null_found && b_is_null_found) {
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->left), std::move(equal_cast->right));
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 *> &bindings,
84
+ unique_ptr<Expression> EqualOrNullSimplification::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
88
85
  bool &changes_made, bool is_root) {
89
- const Expression *or_exp = bindings[0];
86
+ const Expression &or_exp = bindings[0].get();
90
87
 
91
- if (or_exp->type != ExpressionType::CONJUNCTION_OR) {
88
+ if (or_exp.type != ExpressionType::CONJUNCTION_OR) {
92
89
  return nullptr;
93
90
  }
94
91
 
95
- const auto or_exp_cast = (BoundConjunctionExpression *)or_exp;
92
+ const auto &or_exp_cast = or_exp.Cast<BoundConjunctionExpression>();
96
93
 
97
- if (or_exp_cast->children.size() != 2) {
94
+ if (or_exp_cast.children.size() != 2) {
98
95
  return nullptr;
99
96
  }
100
97
 
101
- const auto left_exp = or_exp_cast->children[0].get();
102
- const auto right_exp = or_exp_cast->children[1].get();
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 *> &bindings,
15
+ unique_ptr<Expression> InClauseSimplificationRule::Apply(LogicalOperator &op, vector<reference<Expression>> &bindings,
16
16
  bool &changes_made, bool is_root) {
17
- D_ASSERT(bindings[0]->expression_class == ExpressionClass::BOUND_OPERATOR);
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 *> &bindings,
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]->Cast<BoundFunctionExpression>();
105
- auto &constant_expr = bindings[2]->Cast<BoundConstantExpression>();
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 *> &bindings, bool &changes_made,
32
- bool is_root) {
33
- auto &comparison = bindings[0]->Cast<BoundComparisonExpression>();
34
- auto &outer_constant = bindings[1]->Cast<BoundConstantExpression>();
35
- auto &arithmetic = bindings[2]->Cast<BoundFunctionExpression>();
36
- auto &inner_constant = bindings[3]->Cast<BoundConstantExpression>();
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 *> &bindings,
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]->Cast<BoundAggregateExpression>();
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 *> &bindings,
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]->Cast<BoundFunctionExpression>();
24
- auto &constant_expr = bindings[2]->Cast<BoundConstantExpression>();
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
- expression_map_t<idx_t> map;
29
+ EXPRESSION_MAP map;
30
30
  for (idx_t i = 0; i < a.size(); i++) {
31
- map[a[i].get()]++;
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.get());
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>(a, b);
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>(a, b);
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.max_expression_depth);
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(const string &op, unique_ptr<ParsedExpression> left,
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
- expression_map_t<idx_t> map;
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.get());
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.get()] = result_idx;
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(idx_t max_expression_depth_p)
25
- : parent(nullptr), max_expression_depth(max_expression_depth_p), stack_depth(DConstants::INVALID_INDEX) {
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), max_expression_depth(parent->max_expression_depth), stack_depth(DConstants::INVALID_INDEX) {
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.get());
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.insert(make_pair(aggregate.get(), aggr_index));
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
- expression_map_t<idx_t> projection_map;
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.get()] = i;
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].get()] = i;
394
+ info.map[*unbound_groups[i]] = i;
395
395
  }
396
396
  }
397
397
  result->groups.grouping_sets = std::move(statement.groups.grouping_sets);