Autonomy Software C++ 24.5.1
Welcome to the Autonomy Software repository of the Mars Rover Design Team (MRDT) at Missouri University of Science and Technology (Missouri S&T)! API reference contains the source code and other resources for the development of the autonomy software for our Mars rover. The Autonomy Software project aims to compete in the University Rover Challenge (URC) by demonstrating advanced autonomous capabilities and robust navigation algorithms.
Loading...
Searching...
No Matches
duckdb::EqualOrNullSimplification Class Reference
Inheritance diagram for duckdb::EqualOrNullSimplification:
Collaboration diagram for duckdb::EqualOrNullSimplification:

Public Member Functions

 EqualOrNullSimplification (ExpressionRewriter &rewriter)
unique_ptr< Expression > Apply (LogicalOperator &op, vector< reference< Expression > > &bindings, bool &changes_made, bool is_root) override
Public Member Functions inherited from duckdb::Rule
 Rule (ExpressionRewriter &rewriter)
ClientContext & GetContext () const

Additional Inherited Members

Public Attributes inherited from duckdb::Rule
ExpressionRewriter & rewriter
 The expression rewriter this rule belongs to.
unique_ptr< ExpressionMatcher > root
 The expression matcher of the rule.

Constructor & Destructor Documentation

◆ EqualOrNullSimplification()

duckdb::EqualOrNullSimplification::EqualOrNullSimplification ( ExpressionRewriter & rewriter)
explicit
321049 : Rule(rewriter) {
321050 // match on OR conjunction
321051 auto op = make_uniq<ConjunctionExpressionMatcher>();
321052 op->expr_type = make_uniq<SpecificExpressionTypeMatcher>(ExpressionType::CONJUNCTION_OR);
321053 op->policy = SetMatcher::Policy::SOME;
321054
321055 // equi comparison on one side
321056 auto equal_child = make_uniq<ComparisonExpressionMatcher>();
321057 equal_child->expr_type = make_uniq<SpecificExpressionTypeMatcher>(ExpressionType::COMPARE_EQUAL);
321058 equal_child->policy = SetMatcher::Policy::SOME;
321059 op->matchers.push_back(std::move(equal_child));
321060
321061 // AND conjunction on the other
321062 auto and_child = make_uniq<ConjunctionExpressionMatcher>();
321063 and_child->expr_type = make_uniq<SpecificExpressionTypeMatcher>(ExpressionType::CONJUNCTION_AND);
321064 and_child->policy = SetMatcher::Policy::SOME;
321065
321066 // IS NULL tests inside AND
321067 auto isnull_child = make_uniq<ExpressionMatcher>();
321068 isnull_child->expr_type = make_uniq<SpecificExpressionTypeMatcher>(ExpressionType::OPERATOR_IS_NULL);
321069 // I could try to use std::make_uniq for a copy, but it's available from C++14 only
321070 auto isnull_child2 = make_uniq<ExpressionMatcher>();
321071 isnull_child2->expr_type = make_uniq<SpecificExpressionTypeMatcher>(ExpressionType::OPERATOR_IS_NULL);
321072 and_child->matchers.push_back(std::move(isnull_child));
321073 and_child->matchers.push_back(std::move(isnull_child2));
321074
321075 op->matchers.push_back(std::move(and_child));
321076 root = std::move(op);
321077}
ExpressionRewriter & rewriter
The expression rewriter this rule belongs to.
Definition duckdb.cpp:69564
unique_ptr< ExpressionMatcher > root
The expression matcher of the rule.
Definition duckdb.cpp:69566
@ SOME
Only some entries have to be matched, the order of the matches does not matter.
Definition duckdb.cpp:69125

Member Function Documentation

◆ Apply()

unique_ptr< Expression > duckdb::EqualOrNullSimplification::Apply ( LogicalOperator & op,
vector< reference< Expression > > & bindings,
bool & changes_made,
bool is_root )
overridevirtual

Implements duckdb::Rule.

321126 {
321127 const Expression &or_exp = bindings[0].get();
321128
321129 if (or_exp.GetExpressionType() != ExpressionType::CONJUNCTION_OR) {
321130 return nullptr;
321131 }
321132
321133 const auto &or_exp_cast = or_exp.Cast<BoundConjunctionExpression>();
321134
321135 if (or_exp_cast.children.size() != 2) {
321136 return nullptr;
321137 }
321138
321139 auto &left_exp = *or_exp_cast.children[0];
321140 auto &right_exp = *or_exp_cast.children[1];
321141 // Test for: a=b OR (a IS NULL AND b IS NULL)
321142 auto first_try = TryRewriteEqualOrIsNull(left_exp, right_exp);
321143 if (first_try) {
321144 return first_try;
321145 }
321146 // Test for: (a IS NULL AND b IS NULL) OR a=b
321147 return TryRewriteEqualOrIsNull(right_exp, left_exp);
321148}

The documentation for this class was generated from the following file: