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::OperatorExpression Class Reference

Represents a built-in operator expression. More...

Inheritance diagram for duckdb::OperatorExpression:
Collaboration diagram for duckdb::OperatorExpression:

Public Member Functions

DUCKDB_API OperatorExpression (ExpressionType type, unique_ptr< ParsedExpression > left=nullptr, unique_ptr< ParsedExpression > right=nullptr)
DUCKDB_API OperatorExpression (ExpressionType type, vector< unique_ptr< ParsedExpression > > children)
string ToString () const override
 Convert the Expression to a String.
unique_ptr< ParsedExpression > Copy () const override
 Create a copy of this expression.
void Serialize (Serializer &serializer) const override
Public Member Functions inherited from duckdb::ParsedExpression
 ParsedExpression (ExpressionType type, ExpressionClass expression_class)
 Create an Expression.
bool IsAggregate () const override
 Returns true if this expression is an aggregate or not.
bool IsWindow () const override
 Returns true if the expression has a window function or not.
bool HasSubquery () const override
 Returns true if the query contains a subquery.
bool IsScalar () const override
 Returns true if expression does not contain a group ref or col ref or parameter.
bool HasParameter () const override
 Returns true if the expression has a parameter.
bool Equals (const BaseExpression &other) const override
 Returns true if this expression is equal to another expression.
hash_t Hash () const override
Public Member Functions inherited from duckdb::BaseExpression
 BaseExpression (ExpressionType type, ExpressionClass expression_class)
 Create an Expression.
ExpressionClass GetExpressionClass () const
 Returns the class of the expression.
ExpressionType GetExpressionType () const
 Returns the type of the expression.
void SetExpressionTypeUnsafe (ExpressionType new_type)
optional_idx GetQueryLocation () const
 Returns the location in the query (if any).
void SetQueryLocation (optional_idx location)
 Sets the location in the query.
bool HasAlias () const
 Returns true if the expression has a non-empty alias.
const string & GetAlias () const
 Returns the alias of the expression.
void SetAlias (const string &alias_p)
 Sets the alias of the expression.
void SetAlias (string &&alias_p)
 Sets the alias of the expression.
void ClearAlias ()
 Clears the alias of the expression.
virtual string GetName () const
 Get the name of the expression.
void Print () const
 Print the expression to stdout.
bool operator== (const BaseExpression &rhs) const
virtual void Verify () const
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static bool Equal (const OperatorExpression &a, const OperatorExpression &b)
static unique_ptr< ParsedExpression > Deserialize (Deserializer &deserializer)
template<class T, class BASE>
static string ToString (const T &entry)
Static Public Member Functions inherited from duckdb::ParsedExpression
static unique_ptr< ParsedExpression > Deserialize (Deserializer &deserializer)
static bool Equals (const unique_ptr< ParsedExpression > &left, const unique_ptr< ParsedExpression > &right)
static bool ListEquals (const vector< unique_ptr< ParsedExpression > > &left, const vector< unique_ptr< ParsedExpression > > &right)
Static Public Member Functions inherited from duckdb::BaseExpression
static bool Equals (const BaseExpression &left, const BaseExpression &right)

Public Attributes

vector< unique_ptr< ParsedExpression > > children
Public Attributes inherited from duckdb::BaseExpression
ExpressionType type
 Type of the expression.
ExpressionClass expression_class
 The expression class of the node.
string alias
 The alias of the expression,.
optional_idx query_location
 The location in the query (if any).

Static Public Attributes

static constexpr const ExpressionClass TYPE = ExpressionClass::OPERATOR

Additional Inherited Members

Protected Member Functions inherited from duckdb::ParsedExpression
void CopyProperties (const ParsedExpression &other)

Detailed Description

Represents a built-in operator expression.

Constructor & Destructor Documentation

◆ OperatorExpression() [1/2]

duckdb::OperatorExpression::OperatorExpression ( ExpressionType type,
unique_ptr< ParsedExpression > left = nullptr,
unique_ptr< ParsedExpression > right = nullptr )
explicit
337202 : ParsedExpression(type, ExpressionClass::OPERATOR) {
337203 if (left) {
337204 children.push_back(std::move(left));
337205 }
337206 if (right) {
337207 children.push_back(std::move(right));
337208 }
337209}
ExpressionType type
Type of the expression.
Definition duckdb.hpp:13287
ParsedExpression(ExpressionType type, ExpressionClass expression_class)
Create an Expression.
Definition duckdb.hpp:13557

◆ OperatorExpression() [2/2]

duckdb::OperatorExpression::OperatorExpression ( ExpressionType type,
vector< unique_ptr< ParsedExpression > > children )
337212 : ParsedExpression(type, ExpressionClass::OPERATOR), children(std::move(children)) {
337213}

Member Function Documentation

◆ ToString() [1/2]

string duckdb::OperatorExpression::ToString ( ) const
overridevirtual

Convert the Expression to a String.

Implements duckdb::BaseExpression.

337215 {
337217}
string ToString() const override
Convert the Expression to a String.
Definition duckdb.cpp:337215
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Equal()

bool duckdb::OperatorExpression::Equal ( const OperatorExpression & a,
const OperatorExpression & b )
static
337219 {
337220 if (a.children.size() != b.children.size()) {
337221 return false;
337222 }
337223 for (idx_t i = 0; i < a.children.size(); i++) {
337224 if (!a.children[i]->Equals(*b.children[i])) {
337225 return false;
337226 }
337227 }
337228 return true;
337229}
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ Copy()

unique_ptr< ParsedExpression > duckdb::OperatorExpression::Copy ( ) const
overridevirtual

Create a copy of this expression.

Implements duckdb::ParsedExpression.

337231 {
337232 auto copy = make_uniq<OperatorExpression>(type);
337233 copy->CopyProperties(*this);
337234 for (auto &it : children) {
337235 copy->children.push_back(it->Copy());
337236 }
337237 return std::move(copy);
337238}

◆ Serialize()

void duckdb::OperatorExpression::Serialize ( Serializer & serializer) const
overridevirtual

Reimplemented from duckdb::ParsedExpression.

418894 {
418895 ParsedExpression::Serialize(serializer);
418896 serializer.WritePropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(200, "children", children);
418897}

◆ Deserialize()

unique_ptr< ParsedExpression > duckdb::OperatorExpression::Deserialize ( Deserializer & deserializer)
static
418899 {
418900 auto result = duckdb::unique_ptr<OperatorExpression>(new OperatorExpression(deserializer.Get<ExpressionType>()));
418901 deserializer.ReadPropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(200, "children", result->children);
418902 return std::move(result);
418903}

◆ ToString() [2/2]

template<class T, class BASE>
string duckdb::OperatorExpression::ToString ( const T & entry)
inlinestatic
337099 {
337100 auto op = ExpressionTypeToOperator(entry.GetExpressionType());
337101 if (!op.empty()) {
337102 // use the operator string to represent the operator
337103 D_ASSERT(entry.children.size() == 2);
337104 return entry.children[0]->ToString() + " " + op + " " + entry.children[1]->ToString();
337105 }
337106 switch (entry.GetExpressionType()) {
337107 case ExpressionType::COMPARE_IN:
337108 case ExpressionType::COMPARE_NOT_IN: {
337109 string op_type = entry.GetExpressionType() == ExpressionType::COMPARE_IN ? " IN " : " NOT IN ";
337110 string in_child = entry.children[0]->ToString();
337111 string child_list = "(";
337112 for (idx_t i = 1; i < entry.children.size(); i++) {
337113 if (i > 1) {
337114 child_list += ", ";
337115 }
337116 child_list += entry.children[i]->ToString();
337117 }
337118 child_list += ")";
337119 return "(" + in_child + op_type + child_list + ")";
337120 }
337121 case ExpressionType::OPERATOR_UNPACK: {
337122 return StringUtil::Format("UNPACK(%s)", entry.children[0]->ToString());
337123 }
337124 case ExpressionType::OPERATOR_TRY: {
337125 return StringUtil::Format("TRY(%s)", entry.children[0]->ToString());
337126 }
337127 case ExpressionType::OPERATOR_NOT: {
337128 string result = "(";
337129 result += ExpressionTypeToString(entry.GetExpressionType());
337130 result += " ";
337131 result += StringUtil::Join(entry.children, entry.children.size(), ", ",
337132 [](const unique_ptr<BASE> &child) { return child->ToString(); });
337133 result += ")";
337134 return result;
337135 }
337136 case ExpressionType::GROUPING_FUNCTION:
337137 case ExpressionType::OPERATOR_COALESCE: {
337138 string result = ExpressionTypeToString(entry.GetExpressionType());
337139 result += "(";
337140 result += StringUtil::Join(entry.children, entry.children.size(), ", ",
337141 [](const unique_ptr<BASE> &child) { return child->ToString(); });
337142 result += ")";
337143 return result;
337144 }
337145 case ExpressionType::OPERATOR_IS_NULL:
337146 return "(" + entry.children[0]->ToString() + " IS NULL)";
337147 case ExpressionType::OPERATOR_IS_NOT_NULL:
337148 return "(" + entry.children[0]->ToString() + " IS NOT NULL)";
337149 case ExpressionType::ARRAY_EXTRACT:
337150 return entry.children[0]->ToString() + "[" + entry.children[1]->ToString() + "]";
337151 case ExpressionType::ARRAY_SLICE: {
337152 string begin = entry.children[1]->ToString();
337153 if (begin == "[]") {
337154 begin = "";
337155 }
337156 string end = entry.children[2]->ToString();
337157 if (end == "[]") {
337158 if (entry.children.size() == 4) {
337159 end = "-";
337160 } else {
337161 end = "";
337162 }
337163 }
337164 if (entry.children.size() == 4) {
337165 return entry.children[0]->ToString() + "[" + begin + ":" + end + ":" + entry.children[3]->ToString() +
337166 "]";
337167 }
337168 return entry.children[0]->ToString() + "[" + begin + ":" + end + "]";
337169 }
337170 case ExpressionType::STRUCT_EXTRACT: {
337171 if (entry.children[1]->GetExpressionType() != ExpressionType::VALUE_CONSTANT) {
337172 return string();
337173 }
337174 auto child_string = entry.children[1]->ToString();
337175 D_ASSERT(child_string.size() >= 3);
337176 D_ASSERT(child_string[0] == '\'' && child_string[child_string.size() - 1] == '\'');
337177 return StringUtil::Format("(%s).%s", entry.children[0]->ToString(),
337178 SQLIdentifier(child_string.substr(1, child_string.size() - 2)));
337179 }
337180 case ExpressionType::ARRAY_CONSTRUCTOR: {
337181 string result = "(ARRAY[";
337182 result += StringUtil::Join(entry.children, entry.children.size(), ", ",
337183 [](const unique_ptr<BASE> &child) { return child->ToString(); });
337184 result += "])";
337185 return result;
337186 }
337187 default:
337188 throw InternalException("Unrecognized operator type");
337189 }
337190 }
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002
static DUCKDB_API string Join(const vector< string > &input, const string &separator)
Join multiple strings into one string. Components are concatenated by the given separator.
Definition duckdb.cpp:109497

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