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::TypeExpression Class Reference
Inheritance diagram for duckdb::TypeExpression:
Collaboration diagram for duckdb::TypeExpression:

Public Member Functions

 TypeExpression (string catalog, string schema, string type_name, vector< unique_ptr< ParsedExpression > > children)
 TypeExpression (string type_name, vector< unique_ptr< ParsedExpression > > children)
const string & GetTypeName () const
const string & GetSchema () const
const string & GetCatalog () const
const vector< unique_ptr< ParsedExpression > > & GetChildren () const
vector< unique_ptr< ParsedExpression > > & GetChildren ()
string ToString () const override
 Convert the Expression to a String.
unique_ptr< ParsedExpression > Copy () const override
 Create a copy of this expression.
hash_t Hash () const override
void Serialize (Serializer &serializer) const override
void Verify () 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.
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 bool Equal (const TypeExpression &a, const TypeExpression &b)
static unique_ptr< ParsedExpression > Deserialize (Deserializer &deserializer)
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)

Static Public Attributes

static constexpr const ExpressionClass TYPE = ExpressionClass::TYPE

Private Attributes

string catalog
 Qualified name parts.
string schema
string type_name
vector< unique_ptr< ParsedExpression > > children
 Children of the type expression (e.g. type parameters).

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).
Protected Member Functions inherited from duckdb::ParsedExpression
void CopyProperties (const ParsedExpression &other)

Constructor & Destructor Documentation

◆ TypeExpression() [1/3]

duckdb::TypeExpression::TypeExpression ( string catalog,
string schema,
string type_name,
vector< unique_ptr< ParsedExpression > > children )
337592 : ParsedExpression(ExpressionType::TYPE, ExpressionClass::TYPE), catalog(std::move(catalog)),
337593 schema(std::move(schema)), type_name(std::move(type_name)), children(std::move(children_p)) {
337594 D_ASSERT(!this->type_name.empty());
337595}
ParsedExpression(ExpressionType type, ExpressionClass expression_class)
Create an Expression.
Definition duckdb.hpp:13557
vector< unique_ptr< ParsedExpression > > children
Children of the type expression (e.g. type parameters).
Definition duckdb.cpp:894
string catalog
Qualified name parts.
Definition duckdb.cpp:889

◆ TypeExpression() [2/3]

duckdb::TypeExpression::TypeExpression ( string type_name,
vector< unique_ptr< ParsedExpression > > children )
337598 : TypeExpression(INVALID_CATALOG, INVALID_SCHEMA, std::move(type_name), std::move(children)) {
337599}

◆ TypeExpression() [3/3]

duckdb::TypeExpression::TypeExpression ( )
private
337601 : ParsedExpression(ExpressionType::TYPE, ExpressionClass::TYPE) {
337602}

Member Function Documentation

◆ GetTypeName()

const string & duckdb::TypeExpression::GetTypeName ( ) const
inline
856 {
857 return type_name;
858 }

◆ GetSchema()

const string & duckdb::TypeExpression::GetSchema ( ) const
inline
859 {
860 return schema;
861 }

◆ GetCatalog()

const string & duckdb::TypeExpression::GetCatalog ( ) const
inline
862 {
863 return catalog;
864 }

◆ GetChildren() [1/2]

const vector< unique_ptr< ParsedExpression > > & duckdb::TypeExpression::GetChildren ( ) const
inline
865 {
866 return children;
867 }

◆ GetChildren() [2/2]

vector< unique_ptr< ParsedExpression > > & duckdb::TypeExpression::GetChildren ( )
inline
868 {
869 return children;
870 }

◆ ToString()

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

Convert the Expression to a String.

Implements duckdb::BaseExpression.

337604 {
337605 string result;
337606 if (!catalog.empty()) {
337608 }
337609 if (!schema.empty()) {
337610 result += KeywordHelper::WriteOptionallyQuoted(schema) + ".";
337611 }
337612
337613 auto &params = children;
337614
337615 // LIST and ARRAY have special syntax
337616 if (result.empty() && StringUtil::CIEquals(type_name, "LIST") && params.size() == 1) {
337617 return params[0]->ToString() + "[]";
337618 }
337619 if (result.empty() && StringUtil::CIEquals(type_name, "ARRAY") && params.size() == 2) {
337620 auto &type_param = params[0];
337621 auto &size_param = params[1];
337622 return type_param->ToString() + "[" + size_param->ToString() + "]";
337623 }
337624 // So does STRUCT, MAP and UNION
337625 if (result.empty() && StringUtil::CIEquals(type_name, "STRUCT")) {
337626 if (params.empty()) {
337627 return "STRUCT";
337628 }
337629 string struct_result = "STRUCT(";
337630 for (idx_t i = 0; i < params.size(); i++) {
337631 struct_result += KeywordHelper::WriteOptionallyQuoted(params[i]->GetAlias()) + " " + params[i]->ToString();
337632 if (i < params.size() - 1) {
337633 struct_result += ", ";
337634 }
337635 }
337636 struct_result += ")";
337637 return struct_result;
337638 }
337639 if (result.empty() && StringUtil::CIEquals(type_name, "UNION")) {
337640 if (params.empty()) {
337641 return "UNION";
337642 }
337643 string union_result = "UNION(";
337644 for (idx_t i = 0; i < params.size(); i++) {
337645 union_result += KeywordHelper::WriteOptionallyQuoted(params[i]->GetAlias()) + " " + params[i]->ToString();
337646 if (i < params.size() - 1) {
337647 union_result += ", ";
337648 }
337649 }
337650 union_result += ")";
337651 return union_result;
337652 }
337653
337654 if (result.empty() && StringUtil::CIEquals(type_name, "MAP") && params.size() == 2) {
337655 return "MAP(" + params[0]->ToString() + ", " + params[1]->ToString() + ")";
337656 }
337657
337658 if (result.empty() && StringUtil::CIEquals(type_name, "VARCHAR") && !params.empty()) {
337659 if (params.back()->HasAlias() && StringUtil::CIEquals(params.back()->GetAlias(), "collation")) {
337660 // Special case for VARCHAR with collation
337661 auto collate_expr = params.back()->Cast<ConstantExpression>();
337662 return StringUtil::Format("VARCHAR COLLATE %s", SQLIdentifier(StringValue::Get(collate_expr.value)));
337663 }
337664 }
337665
337666 if (result.empty() && StringUtil::CIEquals(type_name, "INTERVAL") && !params.empty()) {
337667 // We ignore interval types parameters.
337668 return "INTERVAL";
337669 }
337670
337671 result += KeywordHelper::WriteOptionallyQuoted(type_name, '"', true, KeywordCategory::KEYWORD_COL_NAME);
337672
337673 if (!params.empty()) {
337674 result += "(";
337675 for (idx_t i = 0; i < params.size(); i++) {
337676 result += params[i]->ToString();
337677 if (i < params.size() - 1) {
337678 result += ", ";
337679 }
337680 }
337681 result += ")";
337682 }
337683 return result;
337684}
const string & GetAlias() const
Returns the alias of the expression.
Definition duckdb.hpp:13264
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.
Definition duckdb.cpp:338034
static string Format(const string fmt_str, ARGS... params)
Format a string using printf semantics.
Definition duckdb.hpp:4002
static DUCKDB_API bool CIEquals(const string &l1, const string &l2)
Case insensitive equals.
Definition duckdb.cpp:109696
PyParams params(const std::string &tag, const std::string &model, const std::string &weights, const std::string &device)
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
Here is the call graph for this function:

◆ Copy()

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

Create a copy of this expression.

Implements duckdb::ParsedExpression.

337686 {
337687 vector<unique_ptr<ParsedExpression>> copy_children;
337688 copy_children.reserve(children.size());
337689 for (const auto &child : children) {
337690 copy_children.push_back(child->Copy());
337691 }
337692
337693 auto copy = make_uniq<TypeExpression>(catalog, schema, type_name, std::move(copy_children));
337694 copy->CopyProperties(*this);
337695
337696 return std::move(copy);
337697}

◆ Equal()

bool duckdb::TypeExpression::Equal ( const TypeExpression & a,
const TypeExpression & b )
static
337699 {
337700 if (a.catalog != b.catalog || a.schema != b.schema || a.type_name != b.type_name) {
337701 return false;
337702 }
337703 return ParsedExpression::ListEquals(a.children, b.children);
337704}

◆ Hash()

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

Reimplemented from duckdb::ParsedExpression.

337710 {
337711 hash_t result = ParsedExpression::Hash();
337712 result = CombineHash(result, duckdb::Hash<const char *>(catalog.c_str()));
337713 result = CombineHash(result, duckdb::Hash<const char *>(schema.c_str()));
337714 result = CombineHash(result, duckdb::Hash<const char *>(type_name.c_str()));
337715 return result;
337716}
hash_t Hash() const override
Definition duckdb.cpp:340509
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:

◆ Serialize()

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

Reimplemented from duckdb::ParsedExpression.

418969 {
418970 ParsedExpression::Serialize(serializer);
418971 serializer.WritePropertyWithDefault<string>(200, "catalog", catalog);
418972 serializer.WritePropertyWithDefault<string>(201, "schema", schema);
418973 serializer.WritePropertyWithDefault<string>(202, "type_name", type_name);
418974 serializer.WritePropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(203, "children", children);
418975}

◆ Deserialize()

unique_ptr< ParsedExpression > duckdb::TypeExpression::Deserialize ( Deserializer & deserializer)
static
418977 {
418978 auto result = duckdb::unique_ptr<TypeExpression>(new TypeExpression());
418979 deserializer.ReadPropertyWithDefault<string>(200, "catalog", result->catalog);
418980 deserializer.ReadPropertyWithDefault<string>(201, "schema", result->schema);
418981 deserializer.ReadPropertyWithDefault<string>(202, "type_name", result->type_name);
418982 deserializer.ReadPropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(203, "children", result->children);
418983 return std::move(result);
418984}

◆ Verify()

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

Reimplemented from duckdb::BaseExpression.

337706 {
337707 D_ASSERT(!type_name.empty());
337708}

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