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::EnumComparisonRule Class Reference
Inheritance diagram for duckdb::EnumComparisonRule:
Collaboration diagram for duckdb::EnumComparisonRule:

Public Member Functions

 EnumComparisonRule (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

◆ EnumComparisonRule()

duckdb::EnumComparisonRule::EnumComparisonRule ( ExpressionRewriter & rewriter)
explicit
320982 : Rule(rewriter) {
320983 // match on a ComparisonExpression that is an Equality and has a VARCHAR and ENUM as its children
320984 auto op = make_uniq<ComparisonExpressionMatcher>();
320985 // Enum requires expression to be root
320986 op->expr_type = make_uniq<SpecificExpressionTypeMatcher>(ExpressionType::COMPARE_EQUAL);
320987 for (idx_t i = 0; i < 2; i++) {
320988 auto child = make_uniq<CastExpressionMatcher>();
320989 child->type = make_uniq<TypeMatcherId>(LogicalTypeId::VARCHAR);
320990 child->matcher = make_uniq<ExpressionMatcher>();
320991 child->matcher->type = make_uniq<TypeMatcherId>(LogicalTypeId::ENUM);
320992 op->matchers.push_back(std::move(child));
320993 }
320994 root = std::move(op);
320995}
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
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

Member Function Documentation

◆ Apply()

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

Implements duckdb::Rule.

321018 {
321019 auto &root = bindings[0].get().Cast<BoundComparisonExpression>();
321020 auto &left_child = bindings[1].get().Cast<BoundCastExpression>();
321021 auto &right_child = bindings[3].get().Cast<BoundCastExpression>();
321022
321023 if (!AreMatchesPossible(left_child.child->return_type, right_child.child->return_type)) {
321024 vector<unique_ptr<Expression>> children;
321025 children.push_back(std::move(root.left));
321026 children.push_back(std::move(root.right));
321027 return ExpressionRewriter::ConstantOrNull(std::move(children), Value::BOOLEAN(false));
321028 }
321029
321030 if (!is_root || op.type != LogicalOperatorType::LOGICAL_FILTER) {
321031 return nullptr;
321032 }
321033
321034 auto cast_left_to_right =
321035 BoundCastExpression::AddDefaultCastToType(std::move(left_child.child), right_child.child->return_type, true);
321036 return make_uniq<BoundComparisonExpression>(root.GetExpressionType(), std::move(cast_left_to_right),
321037 std::move(right_child.child));
321038}
static unique_ptr< Expression > AddDefaultCastToType(unique_ptr< Expression > expr, const LogicalType &target_type, bool try_cast=false)
Cast an expression to the specified SQL type, using only the built-in SQL casts.
Definition duckdb.cpp:375861
static DUCKDB_API Value BOOLEAN(bool value)
Create a boolean Value from a specified value.
Definition duckdb.cpp:132118

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