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::Expression Class Referenceabstract

The Expression class represents a bound Expression with a return type. More...

#include <duckdb.hpp>

Inheritance diagram for duckdb::Expression:
Collaboration diagram for duckdb::Expression:

Public Member Functions

 Expression (ExpressionType type, ExpressionClass expression_class, LogicalType return_type)
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.
virtual bool IsVolatile () const
virtual bool IsConsistent () const
virtual bool PropagatesNullValues () const
virtual bool IsFoldable () const
virtual bool CanThrow () const
hash_t Hash () const override
bool Equals (const BaseExpression &other) const override
 Returns true if this expression is equal to another expression.
virtual unique_ptr< Expression > Copy () const =0
 Create a copy of this expression.
virtual void Serialize (Serializer &serializer) const
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.
virtual string ToString () const =0
 Convert the Expression to a String.
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 Equals (const Expression &left, const Expression &right)
static bool Equals (const unique_ptr< Expression > &left, const unique_ptr< Expression > &right)
static bool ListEquals (const vector< unique_ptr< Expression > > &left, const vector< unique_ptr< Expression > > &right)
static unique_ptr< Expression > Deserialize (Deserializer &deserializer)
Static Public Member Functions inherited from duckdb::BaseExpression
static bool Equals (const BaseExpression &left, const BaseExpression &right)

Public Attributes

LogicalType return_type
 The return type of the expression.
unique_ptr< BaseStatistics > verification_stats
 Expression statistics (if any) - ONLY USED FOR VERIFICATION.
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).

Protected Member Functions

void CopyProperties (const Expression &other)

Detailed Description

The Expression class represents a bound Expression with a return type.

Constructor & Destructor Documentation

◆ Expression()

duckdb::Expression::Expression ( ExpressionType type,
ExpressionClass expression_class,
LogicalType return_type )
377111}
ExpressionClass expression_class
The expression class of the node.
Definition duckdb.hpp:13290
ExpressionType type
Type of the expression.
Definition duckdb.hpp:13287
BaseExpression(ExpressionType type, ExpressionClass expression_class)
Create an Expression.
Definition duckdb.hpp:13226
LogicalType return_type
The return type of the expression.
Definition duckdb.hpp:17743

◆ ~Expression()

duckdb::Expression::~Expression ( )
override
377113 {
377114}

Member Function Documentation

◆ IsAggregate()

bool duckdb::Expression::IsAggregate ( ) const
overridevirtual

Returns true if this expression is an aggregate or not.

Examples:

(1) SUM(a) + 1 – True

(2) a + 1 – False

Implements duckdb::BaseExpression.

377116 {
377117 bool is_aggregate = false;
377118 ExpressionIterator::EnumerateChildren(*this, [&](const Expression &child) { is_aggregate |= child.IsAggregate(); });
377119 return is_aggregate;
377120}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsWindow()

bool duckdb::Expression::IsWindow ( ) const
overridevirtual

Returns true if the expression has a window function or not.

Implements duckdb::BaseExpression.

377122 {
377123 bool is_window = false;
377124 ExpressionIterator::EnumerateChildren(*this, [&](const Expression &child) { is_window |= child.IsWindow(); });
377125 return is_window;
377126}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasSubquery()

bool duckdb::Expression::HasSubquery ( ) const
overridevirtual

Returns true if the query contains a subquery.

Implements duckdb::BaseExpression.

377197 {
377198 bool has_subquery = false;
377199 ExpressionIterator::EnumerateChildren(*this, [&](const Expression &child) { has_subquery |= child.HasSubquery(); });
377200 return has_subquery;
377201}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsScalar()

bool duckdb::Expression::IsScalar ( ) const
overridevirtual

Returns true if expression does not contain a group ref or col ref or parameter.

Implements duckdb::BaseExpression.

377128 {
377129 bool is_scalar = true;
377130 ExpressionIterator::EnumerateChildren(*this, [&](const Expression &child) {
377131 if (!child.IsScalar()) {
377132 is_scalar = false;
377133 }
377134 });
377135 return is_scalar;
377136}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasParameter()

bool duckdb::Expression::HasParameter ( ) const
overridevirtual

Returns true if the expression has a parameter.

Implements duckdb::BaseExpression.

377190 {
377191 bool has_parameter = false;
377192 ExpressionIterator::EnumerateChildren(*this,
377193 [&](const Expression &child) { has_parameter |= child.HasParameter(); });
377194 return has_parameter;
377195}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsVolatile()

bool duckdb::Expression::IsVolatile ( ) const
virtual
377138 {
377139 bool is_volatile = false;
377140 ExpressionIterator::EnumerateChildren(*this, [&](const Expression &child) {
377141 if (child.IsVolatile()) {
377142 is_volatile = true;
377143 }
377144 });
377145 return is_volatile;
377146}

◆ IsConsistent()

bool duckdb::Expression::IsConsistent ( ) const
virtual
377148 {
377149 bool is_consistent = true;
377150 ExpressionIterator::EnumerateChildren(*this, [&](const Expression &child) {
377151 if (!child.IsConsistent()) {
377152 is_consistent = false;
377153 }
377154 });
377155 return is_consistent;
377156}

◆ PropagatesNullValues()

bool duckdb::Expression::PropagatesNullValues ( ) const
virtual
377164 {
377165 if (type == ExpressionType::OPERATOR_IS_NULL || type == ExpressionType::OPERATOR_IS_NOT_NULL ||
377166 type == ExpressionType::COMPARE_NOT_DISTINCT_FROM || type == ExpressionType::COMPARE_DISTINCT_FROM ||
377167 type == ExpressionType::CONJUNCTION_OR || type == ExpressionType::CONJUNCTION_AND ||
377168 type == ExpressionType::OPERATOR_COALESCE || type == ExpressionType::CASE_EXPR) {
377169 return false;
377170 }
377171 bool propagate_null_values = true;
377172 ExpressionIterator::EnumerateChildren(*this, [&](const Expression &child) {
377173 if (!child.PropagatesNullValues()) {
377174 propagate_null_values = false;
377175 }
377176 });
377177 return propagate_null_values;
377178}

◆ IsFoldable()

bool duckdb::Expression::IsFoldable ( ) const
virtual
377180 {
377181 bool is_foldable = true;
377182 ExpressionIterator::EnumerateChildren(*this, [&](const Expression &child) {
377183 if (!child.IsFoldable()) {
377184 is_foldable = false;
377185 }
377186 });
377187 return is_foldable;
377188}

◆ CanThrow()

bool duckdb::Expression::CanThrow ( ) const
virtual
377158 {
377159 bool can_throw = false;
377160 ExpressionIterator::EnumerateChildren(*this, [&](const Expression &child) { can_throw |= child.CanThrow(); });
377161 return can_throw;
377162}

◆ Hash()

hash_t duckdb::Expression::Hash ( ) const
overridevirtual

Creates a hash value of this expression. It is important that if two expressions are identical (i.e. Expression::Equals() returns true), that their hash value is identical as well.

Implements duckdb::BaseExpression.

377203 {
377204 hash_t hash = duckdb::Hash<uint32_t>(static_cast<uint32_t>(type));
377205 hash = CombineHash(hash, return_type.Hash());
377206 ExpressionIterator::EnumerateChildren(*this,
377207 [&](const Expression &child) { hash = CombineHash(child.Hash(), hash); });
377208 return hash;
377209}
::uint32_t uint32_t
uint64_t hash_t
The type used for hashes.
Definition duckdb.hpp:243
hash_t CombineHash(hash_t left, hash_t right)
Combine two hashes by XORing them.
Definition duckdb.hpp:4635
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Equals() [1/3]

bool duckdb::Expression::Equals ( const BaseExpression & other) const
inlineoverridevirtual

Returns true if this expression is equal to another expression.

Reimplemented from duckdb::BaseExpression.

17762 {
17763 if (!BaseExpression::Equals(other)) {
17764 return false;
17765 }
17766 return return_type == reinterpret_cast<const Expression &>(other).return_type;
17767 }
virtual bool Equals(const BaseExpression &other) const
Returns true if this expression is equal to another expression.
Definition duckdb.cpp:335560
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Equals() [2/3]

bool duckdb::Expression::Equals ( const Expression & left,
const Expression & right )
inlinestatic
17768 {
17769 return left.Equals(right);
17770 }

◆ Equals() [3/3]

bool duckdb::Expression::Equals ( const unique_ptr< Expression > & left,
const unique_ptr< Expression > & right )
static
377211 {
377212 if (left.get() == right.get()) {
377213 return true;
377214 }
377215 if (!left || !right) {
377216 return false;
377217 }
377218 return left->Equals(*right);
377219}

◆ ListEquals()

bool duckdb::Expression::ListEquals ( const vector< unique_ptr< Expression > > & left,
const vector< unique_ptr< Expression > > & right )
static
377221 {
377222 return ExpressionUtil::ListEquals(left, right);
377223}
static bool ListEquals(const vector< unique_ptr< ParsedExpression > > &a, const vector< unique_ptr< ParsedExpression > > &b)
ListEquals: check if a list of two expressions is equal (order is important).
Definition duckdb.cpp:337970

◆ Copy()

◆ Serialize()

void duckdb::Expression::Serialize ( Serializer & serializer) const
virtual
415925 {
415926 serializer.WriteProperty<ExpressionClass>(100, "expression_class", expression_class);
415927 serializer.WriteProperty<ExpressionType>(101, "type", type);
415928 serializer.WritePropertyWithDefault<string>(102, "alias", alias);
415929 serializer.WritePropertyWithDefault<optional_idx>(103, "query_location", query_location, optional_idx());
415930}
string alias
The alias of the expression,.
Definition duckdb.hpp:13293
optional_idx query_location
The location in the query (if any).
Definition duckdb.hpp:13296

◆ Deserialize()

unique_ptr< Expression > duckdb::Expression::Deserialize ( Deserializer & deserializer)
static
415932 {
415933 auto expression_class = deserializer.ReadProperty<ExpressionClass>(100, "expression_class");
415934 auto type = deserializer.ReadProperty<ExpressionType>(101, "type");
415935 auto alias = deserializer.ReadPropertyWithDefault<string>(102, "alias");
415936 auto query_location = deserializer.ReadPropertyWithExplicitDefault<optional_idx>(103, "query_location", optional_idx());
415937 deserializer.Set<ExpressionType>(type);
415938 unique_ptr<Expression> result;
415939 switch (expression_class) {
415940 case ExpressionClass::BOUND_AGGREGATE:
415941 result = BoundAggregateExpression::Deserialize(deserializer);
415942 break;
415943 case ExpressionClass::BOUND_BETWEEN:
415944 result = BoundBetweenExpression::Deserialize(deserializer);
415945 break;
415946 case ExpressionClass::BOUND_CASE:
415947 result = BoundCaseExpression::Deserialize(deserializer);
415948 break;
415949 case ExpressionClass::BOUND_CAST:
415950 result = BoundCastExpression::Deserialize(deserializer);
415951 break;
415952 case ExpressionClass::BOUND_COLUMN_REF:
415953 result = BoundColumnRefExpression::Deserialize(deserializer);
415954 break;
415955 case ExpressionClass::BOUND_COMPARISON:
415956 result = BoundComparisonExpression::Deserialize(deserializer);
415957 break;
415958 case ExpressionClass::BOUND_CONJUNCTION:
415959 result = BoundConjunctionExpression::Deserialize(deserializer);
415960 break;
415961 case ExpressionClass::BOUND_CONSTANT:
415962 result = BoundConstantExpression::Deserialize(deserializer);
415963 break;
415964 case ExpressionClass::BOUND_DEFAULT:
415965 result = BoundDefaultExpression::Deserialize(deserializer);
415966 break;
415967 case ExpressionClass::BOUND_FUNCTION:
415968 result = BoundFunctionExpression::Deserialize(deserializer);
415969 break;
415970 case ExpressionClass::BOUND_LAMBDA:
415971 result = BoundLambdaExpression::Deserialize(deserializer);
415972 break;
415973 case ExpressionClass::BOUND_LAMBDA_REF:
415974 result = BoundLambdaRefExpression::Deserialize(deserializer);
415975 break;
415976 case ExpressionClass::BOUND_OPERATOR:
415977 result = BoundOperatorExpression::Deserialize(deserializer);
415978 break;
415979 case ExpressionClass::BOUND_PARAMETER:
415980 result = BoundParameterExpression::Deserialize(deserializer);
415981 break;
415982 case ExpressionClass::BOUND_REF:
415983 result = BoundReferenceExpression::Deserialize(deserializer);
415984 break;
415985 case ExpressionClass::BOUND_UNNEST:
415986 result = BoundUnnestExpression::Deserialize(deserializer);
415987 break;
415988 case ExpressionClass::BOUND_WINDOW:
415989 result = BoundWindowExpression::Deserialize(deserializer);
415990 break;
415991 default:
415992 throw SerializationException("Unsupported type for deserialization of Expression!");
415993 }
415994 deserializer.Unset<ExpressionType>();
415995 result->alias = std::move(alias);
415996 result->query_location = query_location;
415997 return result;
415998}

◆ CopyProperties()

void duckdb::Expression::CopyProperties ( const Expression & other)
inlineprotected

Copy base Expression properties from another expression to this one, used in Copy method

17782 {
17783 type = other.type;
17784 expression_class = other.expression_class;
17785 alias = other.alias;
17786 return_type = other.return_type;
17787 query_location = other.query_location;
17788 }

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