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

Represents a function call that has been bound to a base function. More...

Inheritance diagram for duckdb::BoundFunctionExpression:
Collaboration diagram for duckdb::BoundFunctionExpression:

Public Member Functions

 BoundFunctionExpression (LogicalType return_type, ScalarFunction bound_function, vector< unique_ptr< Expression > > arguments, unique_ptr< FunctionData > bind_info, bool is_operator=false)
bool IsVolatile () const override
bool IsConsistent () const override
bool IsFoldable () const override
bool CanThrow () const override
string ToString () const override
 Convert the Expression to a String.
bool PropagatesNullValues () const override
hash_t Hash () const override
bool Equals (const BaseExpression &other) const override
 Returns true if this expression is equal to another expression.
unique_ptr< Expression > Copy () const override
 Create a copy of this expression.
void Verify () const override
void Serialize (Serializer &serializer) const override
Public Member Functions inherited from duckdb::Expression
 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.
hash_t Hash () const override
bool Equals (const BaseExpression &other) const override
 Returns true if this expression is equal to another expression.
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
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static unique_ptr< Expression > Deserialize (Deserializer &deserializer)
Static Public Member Functions inherited from duckdb::Expression
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

ScalarFunction function
 The bound function expression.
vector< unique_ptr< Expression > > children
 List of child-expressions of the function.
unique_ptr< FunctionData > bind_info
 The bound function data (if any).
bool is_operator
 Whether or not the function is an operator, only used for rendering.
Public Attributes inherited from duckdb::Expression
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).

Static Public Attributes

static constexpr const ExpressionClass TYPE = ExpressionClass::BOUND_FUNCTION

Additional Inherited Members

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

Detailed Description

Represents a function call that has been bound to a base function.

Constructor & Destructor Documentation

◆ BoundFunctionExpression()

duckdb::BoundFunctionExpression::BoundFunctionExpression ( LogicalType return_type,
ScalarFunction bound_function,
vector< unique_ptr< Expression > > arguments,
unique_ptr< FunctionData > bind_info,
bool is_operator = false )
376404 : Expression(ExpressionType::BOUND_FUNCTION, ExpressionClass::BOUND_FUNCTION, std::move(return_type)),
376405 function(std::move(bound_function)), children(std::move(arguments)), bind_info(std::move(bind_info)),
376407 D_ASSERT(!function.name.empty());
376408}
bool is_operator
Whether or not the function is an operator, only used for rendering.
Definition duckdb.cpp:80973
vector< unique_ptr< Expression > > children
List of child-expressions of the function.
Definition duckdb.cpp:80969
unique_ptr< FunctionData > bind_info
The bound function data (if any).
Definition duckdb.cpp:80971
ScalarFunction function
The bound function expression.
Definition duckdb.cpp:80967
LogicalType return_type
The return type of the expression.
Definition duckdb.hpp:17743

Member Function Documentation

◆ IsVolatile()

bool duckdb::BoundFunctionExpression::IsVolatile ( ) const
overridevirtual

Reimplemented from duckdb::Expression.

376410 {
376411 return function.GetStability() == FunctionStability::VOLATILE ? true : Expression::IsVolatile();
376412}

◆ IsConsistent()

bool duckdb::BoundFunctionExpression::IsConsistent ( ) const
overridevirtual

Reimplemented from duckdb::Expression.

376414 {
376415 return function.GetStability() != FunctionStability::CONSISTENT ? false : Expression::IsConsistent();
376416}

◆ IsFoldable()

bool duckdb::BoundFunctionExpression::IsFoldable ( ) const
overridevirtual

Reimplemented from duckdb::Expression.

376418 {
376419 // functions with side effects cannot be folded: they have to be executed once for every row
376420 if (function.HasBindLambdaCallback()) {
376421 // This is a lambda function
376422 D_ASSERT(bind_info);
376423 auto &lambda_bind_data = bind_info->Cast<ListLambdaBindData>();
376424 if (lambda_bind_data.lambda_expr) {
376425 auto &expr = *lambda_bind_data.lambda_expr;
376426 if (expr.IsVolatile()) {
376427 return false;
376428 }
376429 }
376430 }
376431 return function.GetStability() == FunctionStability::VOLATILE ? false : Expression::IsFoldable();
376432}

◆ CanThrow()

bool duckdb::BoundFunctionExpression::CanThrow ( ) const
overridevirtual

Reimplemented from duckdb::Expression.

376434 {
376435 if (function.GetErrorMode() == FunctionErrors::CAN_THROW_RUNTIME_ERROR) {
376436 return true;
376437 }
376438 return Expression::CanThrow();
376439}

◆ ToString()

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

Convert the Expression to a String.

Implements duckdb::BaseExpression.

376441 {
376443 is_operator);
376444}
string ToString() const override
Convert the Expression to a String.
Definition duckdb.cpp:336803
Here is the call graph for this function:

◆ PropagatesNullValues()

bool duckdb::BoundFunctionExpression::PropagatesNullValues ( ) const
overridevirtual

Reimplemented from duckdb::Expression.

376445 {
376446 return function.GetNullHandling() == FunctionNullHandling::SPECIAL_HANDLING ? false
376447 : Expression::PropagatesNullValues();
376448}

◆ Hash()

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

376450 {
376451 hash_t result = Expression::Hash();
376452 return CombineHash(result, function.Hash());
376453}
hash_t Hash() const override
Definition duckdb.cpp:377203
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:

◆ Equals()

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

Returns true if this expression is equal to another expression.

Reimplemented from duckdb::BaseExpression.

376455 {
376456 if (!Expression::Equals(other_p)) {
376457 return false;
376458 }
376459 auto &other = other_p.Cast<BoundFunctionExpression>();
376460 if (other.function != function) {
376461 return false;
376462 }
376463 if (!Expression::ListEquals(children, other.children)) {
376464 return false;
376465 }
376466 if (!FunctionData::Equals(bind_info.get(), other.bind_info.get())) {
376467 return false;
376468 }
376469 return true;
376470}
bool Equals(const BaseExpression &other) const override
Returns true if this expression is equal to another expression.
Definition duckdb.hpp:17762
Here is the call graph for this function:

◆ Copy()

unique_ptr< Expression > duckdb::BoundFunctionExpression::Copy ( ) const
overridevirtual

Create a copy of this expression.

Implements duckdb::Expression.

376472 {
376473 vector<unique_ptr<Expression>> new_children;
376474 new_children.reserve(children.size());
376475 for (auto &child : children) {
376476 new_children.push_back(child->Copy());
376477 }
376478 unique_ptr<FunctionData> new_bind_info = bind_info ? bind_info->Copy() : nullptr;
376479
376480 auto copy = make_uniq<BoundFunctionExpression>(return_type, function, std::move(new_children),
376481 std::move(new_bind_info), is_operator);
376482 copy->CopyProperties(*this);
376483 return std::move(copy);
376484}

◆ Verify()

void duckdb::BoundFunctionExpression::Verify ( ) const
overridevirtual

Reimplemented from duckdb::BaseExpression.

376486 {
376487 D_ASSERT(!function.name.empty());
376488}

◆ Serialize()

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

Reimplemented from duckdb::Expression.

376490 {
376491 Expression::Serialize(serializer);
376492 serializer.WriteProperty(200, "return_type", return_type);
376493 serializer.WriteProperty(201, "children", children);
376494 FunctionSerializer::Serialize(serializer, function, bind_info.get());
376495 serializer.WriteProperty(202, "is_operator", is_operator);
376496}

◆ Deserialize()

unique_ptr< Expression > duckdb::BoundFunctionExpression::Deserialize ( Deserializer & deserializer)
static
376498 {
376499 auto return_type = deserializer.ReadProperty<LogicalType>(200, "return_type");
376500 auto children = deserializer.ReadProperty<vector<unique_ptr<Expression>>>(201, "children");
376501
376502 auto entry = FunctionSerializer::Deserialize<ScalarFunction, ScalarFunctionCatalogEntry>(
376503 deserializer, CatalogType::SCALAR_FUNCTION_ENTRY, children, return_type);
376504 auto function_return_type = entry.first.GetReturnType();
376505
376506 auto is_operator = deserializer.ReadProperty<bool>(202, "is_operator");
376507
376508 if (entry.first.HasBindExpressionCallback()) {
376509 // bind the function expression
376510 auto &context = deserializer.Get<ClientContext &>();
376511 auto bind_input = FunctionBindExpressionInput(context, entry.second, children);
376512 // replace the function expression with the bound expression
376513 auto bound_expression = entry.first.GetBindExpressionCallback()(bind_input);
376514 if (bound_expression) {
376515 return bound_expression;
376516 }
376517 // Otherwise, fall thorugh and continue on normally
376518 }
376519 auto result = make_uniq<BoundFunctionExpression>(std::move(function_return_type), std::move(entry.first),
376520 std::move(children), std::move(entry.second));
376521 result->is_operator = is_operator;
376522 if (result->return_type != return_type) {
376523 // return type mismatch - push a cast
376524 auto &context = deserializer.Get<ClientContext &>();
376525 return BoundCastExpression::AddCastToType(context, std::move(result), return_type);
376526 }
376527 return std::move(result);
376528}
static DUCKDB_API unique_ptr< Expression > AddCastToType(ClientContext &context, unique_ptr< Expression > expr, const LogicalType &target_type, bool try_cast=false)
Cast an expression to the specified SQL type if required.
Definition duckdb.cpp:375869

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