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

#include <duckdb.hpp>

Inheritance diagram for duckdb::ParsedExpression:
Collaboration diagram for duckdb::ParsedExpression:

Public Member Functions

 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
virtual unique_ptr< ParsedExpression > 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 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)

Protected Member Functions

void CopyProperties (const ParsedExpression &other)

Additional Inherited Members

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).

Detailed Description

The ParsedExpression class is a base class that can represent any expression part of a SQL statement.

The ParsedExpression class is a base class that can represent any expression part of a SQL statement. This is, for example, a column reference in a SELECT clause, but also operators, aggregates or filters. The Expression is emitted by the parser and does not contain any information about bindings to the catalog or to the types. ParsedExpressions are transformed into regular Expressions in the Binder.

Constructor & Destructor Documentation

◆ ParsedExpression()

duckdb::ParsedExpression::ParsedExpression ( ExpressionType type,
ExpressionClass expression_class )
inline

Create an Expression.

13558 }
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
Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ IsAggregate()

bool duckdb::ParsedExpression::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.

340424 {
340425 bool is_aggregate = false;
340426 ParsedExpressionIterator::EnumerateChildren(
340427 *this, [&](const ParsedExpression &child) { is_aggregate |= child.IsAggregate(); });
340428 return is_aggregate;
340429}
ParsedExpression(ExpressionType type, ExpressionClass expression_class)
Create an Expression.
Definition duckdb.hpp:13557
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsWindow()

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

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

Implements duckdb::BaseExpression.

Reimplemented in duckdb::WindowExpression.

340431 {
340432 bool is_window = false;
340433 ParsedExpressionIterator::EnumerateChildren(*this,
340434 [&](const ParsedExpression &child) { is_window |= child.IsWindow(); });
340435 return is_window;
340436}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasSubquery()

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

Returns true if the query contains a subquery.

Implements duckdb::BaseExpression.

Reimplemented in duckdb::SubqueryExpression.

340455 {
340456 bool has_subquery = false;
340457 ParsedExpressionIterator::EnumerateChildren(
340458 *this, [&](const ParsedExpression &child) { has_subquery |= child.HasSubquery(); });
340459 return has_subquery;
340460}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsScalar()

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

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

Implements duckdb::BaseExpression.

Reimplemented in duckdb::PositionalReferenceExpression, and duckdb::SubqueryExpression.

340438 {
340439 bool is_scalar = true;
340440 ParsedExpressionIterator::EnumerateChildren(*this, [&](const ParsedExpression &child) {
340441 if (!child.IsScalar()) {
340442 is_scalar = false;
340443 }
340444 });
340445 return is_scalar;
340446}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ HasParameter()

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

Returns true if the expression has a parameter.

Implements duckdb::BaseExpression.

340448 {
340449 bool has_parameter = false;
340450 ParsedExpressionIterator::EnumerateChildren(
340451 *this, [&](const ParsedExpression &child) { has_parameter |= child.HasParameter(); });
340452 return has_parameter;
340453}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Equals() [1/2]

bool duckdb::ParsedExpression::Equals ( const BaseExpression & other) const
overridevirtual

Returns true if this expression is equal to another expression.

Reimplemented from duckdb::BaseExpression.

340462 {
340463 if (!BaseExpression::Equals(other)) {
340464 return false;
340465 }
340466 switch (expression_class) {
340467 case ExpressionClass::BETWEEN:
340468 return BetweenExpression::Equal(Cast<BetweenExpression>(), other.Cast<BetweenExpression>());
340469 case ExpressionClass::CASE:
340470 return CaseExpression::Equal(Cast<CaseExpression>(), other.Cast<CaseExpression>());
340471 case ExpressionClass::CAST:
340472 return CastExpression::Equal(Cast<CastExpression>(), other.Cast<CastExpression>());
340473 case ExpressionClass::COLLATE:
340474 return CollateExpression::Equal(Cast<CollateExpression>(), other.Cast<CollateExpression>());
340475 case ExpressionClass::COLUMN_REF:
340476 return ColumnRefExpression::Equal(Cast<ColumnRefExpression>(), other.Cast<ColumnRefExpression>());
340477 case ExpressionClass::COMPARISON:
340478 return ComparisonExpression::Equal(Cast<ComparisonExpression>(), other.Cast<ComparisonExpression>());
340479 case ExpressionClass::CONJUNCTION:
340480 return ConjunctionExpression::Equal(Cast<ConjunctionExpression>(), other.Cast<ConjunctionExpression>());
340481 case ExpressionClass::CONSTANT:
340482 return ConstantExpression::Equal(Cast<ConstantExpression>(), other.Cast<ConstantExpression>());
340483 case ExpressionClass::DEFAULT:
340484 return true;
340485 case ExpressionClass::FUNCTION:
340486 return FunctionExpression::Equal(Cast<FunctionExpression>(), other.Cast<FunctionExpression>());
340487 case ExpressionClass::LAMBDA:
340488 return LambdaExpression::Equal(Cast<LambdaExpression>(), other.Cast<LambdaExpression>());
340489 case ExpressionClass::OPERATOR:
340490 return OperatorExpression::Equal(Cast<OperatorExpression>(), other.Cast<OperatorExpression>());
340491 case ExpressionClass::PARAMETER:
340492 return ParameterExpression::Equal(Cast<ParameterExpression>(), other.Cast<ParameterExpression>());
340493 case ExpressionClass::POSITIONAL_REFERENCE:
340494 return PositionalReferenceExpression::Equal(Cast<PositionalReferenceExpression>(),
340495 other.Cast<PositionalReferenceExpression>());
340496 case ExpressionClass::STAR:
340497 return StarExpression::Equal(Cast<StarExpression>(), other.Cast<StarExpression>());
340498 case ExpressionClass::SUBQUERY:
340499 return SubqueryExpression::Equal(Cast<SubqueryExpression>(), other.Cast<SubqueryExpression>());
340500 case ExpressionClass::WINDOW:
340501 return WindowExpression::Equal(Cast<WindowExpression>(), other.Cast<WindowExpression>());
340502 case ExpressionClass::TYPE:
340503 return TypeExpression::Equal(Cast<TypeExpression>(), other.Cast<TypeExpression>());
340504 default:
340505 throw SerializationException("Unsupported type for expression comparison!");
340506 }
340507}
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:

◆ Hash()

hash_t duckdb::ParsedExpression::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.

Reimplemented in duckdb::PositionalReferenceExpression, and duckdb::TypeExpression.

340509 {
340510 hash_t hash = duckdb::Hash<uint32_t>(static_cast<uint32_t>(type));
340511 ParsedExpressionIterator::EnumerateChildren(
340512 *this, [&](const ParsedExpression &child) { hash = CombineHash(child.Hash(), hash); });
340513 return hash;
340514}
::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:

◆ Copy()

◆ Serialize()

void duckdb::ParsedExpression::Serialize ( Serializer & serializer) const
virtual
418644 {
418645 serializer.WriteProperty<ExpressionClass>(100, "class", expression_class);
418646 serializer.WriteProperty<ExpressionType>(101, "type", type);
418647 serializer.WritePropertyWithDefault<string>(102, "alias", alias);
418648 serializer.WritePropertyWithDefault<optional_idx>(103, "query_location", query_location, optional_idx());
418649}
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< ParsedExpression > duckdb::ParsedExpression::Deserialize ( Deserializer & deserializer)
static
418651 {
418652 auto expression_class = deserializer.ReadProperty<ExpressionClass>(100, "class");
418653 auto type = deserializer.ReadProperty<ExpressionType>(101, "type");
418654 auto alias = deserializer.ReadPropertyWithDefault<string>(102, "alias");
418655 auto query_location = deserializer.ReadPropertyWithExplicitDefault<optional_idx>(103, "query_location", optional_idx());
418656 deserializer.Set<ExpressionType>(type);
418657 unique_ptr<ParsedExpression> result;
418658 switch (expression_class) {
418659 case ExpressionClass::BETWEEN:
418660 result = BetweenExpression::Deserialize(deserializer);
418661 break;
418662 case ExpressionClass::CASE:
418663 result = CaseExpression::Deserialize(deserializer);
418664 break;
418665 case ExpressionClass::CAST:
418666 result = CastExpression::Deserialize(deserializer);
418667 break;
418668 case ExpressionClass::COLLATE:
418669 result = CollateExpression::Deserialize(deserializer);
418670 break;
418671 case ExpressionClass::COLUMN_REF:
418672 result = ColumnRefExpression::Deserialize(deserializer);
418673 break;
418674 case ExpressionClass::COMPARISON:
418675 result = ComparisonExpression::Deserialize(deserializer);
418676 break;
418677 case ExpressionClass::CONJUNCTION:
418678 result = ConjunctionExpression::Deserialize(deserializer);
418679 break;
418680 case ExpressionClass::CONSTANT:
418681 result = ConstantExpression::Deserialize(deserializer);
418682 break;
418683 case ExpressionClass::DEFAULT:
418684 result = DefaultExpression::Deserialize(deserializer);
418685 break;
418686 case ExpressionClass::FUNCTION:
418687 result = FunctionExpression::Deserialize(deserializer);
418688 break;
418689 case ExpressionClass::LAMBDA:
418690 result = LambdaExpression::Deserialize(deserializer);
418691 break;
418692 case ExpressionClass::LAMBDA_REF:
418693 result = LambdaRefExpression::Deserialize(deserializer);
418694 break;
418695 case ExpressionClass::OPERATOR:
418696 result = OperatorExpression::Deserialize(deserializer);
418697 break;
418698 case ExpressionClass::PARAMETER:
418699 result = ParameterExpression::Deserialize(deserializer);
418700 break;
418701 case ExpressionClass::POSITIONAL_REFERENCE:
418702 result = PositionalReferenceExpression::Deserialize(deserializer);
418703 break;
418704 case ExpressionClass::STAR:
418705 result = StarExpression::Deserialize(deserializer);
418706 break;
418707 case ExpressionClass::SUBQUERY:
418708 result = SubqueryExpression::Deserialize(deserializer);
418709 break;
418710 case ExpressionClass::TYPE:
418711 result = TypeExpression::Deserialize(deserializer);
418712 break;
418713 case ExpressionClass::WINDOW:
418714 result = WindowExpression::Deserialize(deserializer);
418715 break;
418716 default:
418717 throw SerializationException("Unsupported type for deserialization of ParsedExpression!");
418718 }
418719 deserializer.Unset<ExpressionType>();
418720 result->alias = std::move(alias);
418721 result->query_location = query_location;
418722 return result;
418723}

◆ Equals() [2/2]

bool duckdb::ParsedExpression::Equals ( const unique_ptr< ParsedExpression > & left,
const unique_ptr< ParsedExpression > & right )
static
340516 {
340517 if (left.get() == right.get()) {
340518 return true;
340519 }
340520 if (!left || !right) {
340521 return false;
340522 }
340523 return left->Equals(*right);
340524}

◆ ListEquals()

bool duckdb::ParsedExpression::ListEquals ( const vector< unique_ptr< ParsedExpression > > & left,
const vector< unique_ptr< ParsedExpression > > & right )
static
340527 {
340528 return ExpressionUtil::ListEquals(left, right);
340529}
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

◆ CopyProperties()

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

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

13583 {
13584 type = other.type;
13585 expression_class = other.expression_class;
13586 alias = other.alias;
13587 query_location = other.query_location;
13588 }
Here is the call graph for this function:

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