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

Represents a function call. More...

Inheritance diagram for duckdb::FunctionExpression:
Collaboration diagram for duckdb::FunctionExpression:

Public Member Functions

DUCKDB_API FunctionExpression (string catalog_name, string schema_name, const string &function_name, vector< unique_ptr< ParsedExpression > > children, unique_ptr< ParsedExpression > filter=nullptr, unique_ptr< OrderModifier > order_bys=nullptr, bool distinct=false, bool is_operator=false, bool export_state=false)
 
DUCKDB_API FunctionExpression (const string &function_name, vector< unique_ptr< ParsedExpression > > children, unique_ptr< ParsedExpression > filter=nullptr, unique_ptr< OrderModifier > order_bys=nullptr, bool distinct=false, bool is_operator=false, bool export_state=false)
 
string ToString () const override
 Convert the Expression to a String.
 
unique_ptr< ParsedExpressionCopy () const override
 Create a copy of this expression.
 
hash_t Hash () const override
 
void Serialize (Serializer &serializer) const override
 
void Verify () const override
 
optional_ptr< ParsedExpressionIsLambdaFunction () const
 Returns a pointer to the lambda expression, if the function has a lambda expression as a child, else nullptr.
 
- 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
 
template<class TARGET >
TARGETCast ()
 
template<class TARGET >
const TARGETCast () const
 

Static Public Member Functions

static bool Equal (const FunctionExpression &a, const FunctionExpression &b)
 
static unique_ptr< ParsedExpressionDeserialize (Deserializer &deserializer)
 
template<class T , class BASE , class ORDER_MODIFIER = OrderModifier>
static string ToString (const T &entry, const string &catalog, const string &schema, const string &function_name, bool is_operator=false, bool distinct=false, BASE *filter=nullptr, ORDER_MODIFIER *order_bys=nullptr, bool export_state=false, bool add_alias=false)
 
- Static Public Member Functions inherited from duckdb::ParsedExpression
static unique_ptr< ParsedExpressionDeserialize (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

string catalog
 Catalog of the function.
 
string schema
 Schema of the function.
 
string function_name
 Function name.
 
bool is_operator
 Whether or not the function is an operator, only used for rendering.
 
vector< unique_ptr< ParsedExpression > > children
 List of arguments to the function.
 
bool distinct
 Whether or not the aggregate function is distinct, only used for aggregates.
 
unique_ptr< ParsedExpressionfilter
 Expression representing a filter, only used for aggregates.
 
unique_ptr< OrderModifierorder_bys
 Modifier representing an ORDER BY, only used for aggregates.
 
bool export_state
 whether this function should export its state or not
 
- 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::FUNCTION
 

Additional Inherited Members

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

Detailed Description

Represents a function call.

Member Function Documentation

◆ ToString() [1/2]

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

Convert the Expression to a String.

Implements duckdb::BaseExpression.

◆ Copy()

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

Create a copy of this expression.

Implements duckdb::ParsedExpression.

◆ Hash()

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

◆ Serialize()

void duckdb::FunctionExpression::Serialize ( Serializer serializer) const
overridevirtual

Reimplemented from duckdb::ParsedExpression.

◆ Verify()

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

Reimplemented from duckdb::BaseExpression.

◆ ToString() [2/2]

template<class T , class BASE , class ORDER_MODIFIER = OrderModifier>
static string duckdb::FunctionExpression::ToString ( const T &  entry,
const string &  catalog,
const string &  schema,
const string &  function_name,
bool  is_operator = false,
bool  distinct = false,
BASE *  filter = nullptr,
ORDER_MODIFIER *  order_bys = nullptr,
bool  export_state = false,
bool  add_alias = false 
)
inlinestatic
3183 {
3184 if (is_operator) {
3185 // built-in operator
3186 D_ASSERT(!distinct);
3187 if (entry.children.size() == 1) {
3188 if (StringUtil::Contains(function_name, "__postfix")) {
3189 return "((" + entry.children[0]->ToString() + ")" +
3190 StringUtil::Replace(function_name, "__postfix", "") + ")";
3191 } else {
3192 return function_name + "(" + entry.children[0]->ToString() + ")";
3193 }
3194 } else if (entry.children.size() == 2) {
3195 return StringUtil::Format("(%s %s %s)", entry.children[0]->ToString(), function_name,
3196 entry.children[1]->ToString());
3197 }
3198 }
3199 // standard function call
3200 string result;
3201 if (!catalog.empty()) {
3203 }
3204 if (!schema.empty()) {
3206 }
3208 result += "(";
3209 if (distinct) {
3210 result += "DISTINCT ";
3211 }
3212 result += StringUtil::Join(entry.children, entry.children.size(), ", ", [&](const unique_ptr<BASE> &child) {
3213 return child->GetAlias().empty() || !add_alias
3214 ? child->ToString()
3215 : StringUtil::Format("%s := %s", SQLIdentifier(child->GetAlias()), child->ToString());
3216 });
3217 // ordered aggregate
3218 if (order_bys && !order_bys->orders.empty()) {
3219 if (entry.children.empty()) {
3220 result += ") WITHIN GROUP (";
3221 }
3222 result += " ORDER BY ";
3223 for (idx_t i = 0; i < order_bys->orders.size(); i++) {
3224 if (i > 0) {
3225 result += ", ";
3226 }
3227 result += order_bys->orders[i].ToString();
3228 }
3229 }
3230 result += ")";
3231
3232 // filtered aggregate
3233 if (filter) {
3234 result += " FILTER (WHERE " + filter->ToString() + ")";
3235 }
3236
3237 if (export_state) {
3238 result += " EXPORT_STATE";
3239 }
3240
3241 return result;
3242 }
bool distinct
Whether or not the aggregate function is distinct, only used for aggregates.
Definition duckdb.cpp:3155
bool is_operator
Whether or not the function is an operator, only used for rendering.
Definition duckdb.cpp:3151
unique_ptr< ParsedExpression > filter
Expression representing a filter, only used for aggregates.
Definition duckdb.cpp:3157
string catalog
Catalog of the function.
Definition duckdb.cpp:3145
string function_name
Function name.
Definition duckdb.cpp:3149
unique_ptr< OrderModifier > order_bys
Modifier representing an ORDER BY, only used for aggregates.
Definition duckdb.cpp:3159
bool export_state
whether this function should export its state or not
Definition duckdb.cpp:3161
string schema
Schema of the function.
Definition duckdb.cpp:3147
static string WriteOptionallyQuoted(const string &text, char quote='"', bool allow_caps = true, KeywordCategory category = KeywordCategory::KEYWORD_NONE)
Writes a string that is optionally quoted + escaped so it can be used as an identifier.
static DUCKDB_API bool Contains(const string &haystack, const string &needle)
Returns true if the needle string exists in the haystack.
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.
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002

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