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

Represents a generic expression that returns a table. More...

#include <duckdb.hpp>

Inheritance diagram for duckdb::TableRef:
Collaboration diagram for duckdb::TableRef:

Public Member Functions

 TableRef (TableReferenceType type)
virtual string ToString () const =0
 Convert the object to a string.
void Print ()
virtual bool Equals (const TableRef &other) const
virtual unique_ptr< TableRef > Copy ()=0
void CopyProperties (TableRef &target) const
 Copy the properties of this table ref to the target.
virtual void Serialize (Serializer &serializer) const
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static bool Equals (const unique_ptr< TableRef > &left, const unique_ptr< TableRef > &right)
static unique_ptr< TableRef > Deserialize (Deserializer &deserializer)

Public Attributes

TableReferenceType type
string alias
unique_ptr< SampleOptions > sample
 Sample options (if any).
optional_idx query_location
 The location in the query (if any).
shared_ptr< ExternalDependency > external_dependency
 External dependencies of this table function.
vector< string > column_name_alias
 Aliases for the column names.

Static Public Attributes

static constexpr const TableReferenceType TYPE = TableReferenceType::INVALID

Protected Member Functions

string BaseToString (string result) const
string BaseToString (string result, const vector< string > &column_name_alias) const
string AliasToString (const vector< string > &column_name_alias) const
string SampleToString () const

Detailed Description

Represents a generic expression that returns a table.

Constructor & Destructor Documentation

◆ TableRef()

duckdb::TableRef::TableRef ( TableReferenceType type)
inlineexplicit
53730 : type(type) {
53731 }

◆ ~TableRef()

virtual duckdb::TableRef::~TableRef ( )
inlinevirtual
53732 {
53733 }

Member Function Documentation

◆ ToString()

◆ Print()

void duckdb::TableRef::Print ( )
351236 {
351238}
static DUCKDB_API void Print(OutputStream stream, const string &str)
Print the object to the stream.
Definition duckdb.cpp:92556
virtual string ToString() const =0
Convert the object to a string.

◆ Equals() [1/2]

bool duckdb::TableRef::Equals ( const TableRef & other) const
virtual
351224 {
351225 return type == other.type && alias == other.alias && SampleOptions::Equals(sample.get(), other.sample.get());
351226}
unique_ptr< SampleOptions > sample
Sample options (if any).
Definition duckdb.hpp:53738

◆ Equals() [2/2]

bool duckdb::TableRef::Equals ( const unique_ptr< TableRef > & left,
const unique_ptr< TableRef > & right )
static
351240 {
351241 if (left.get() == right.get()) {
351242 return true;
351243 }
351244 if (!left || !right) {
351245 return false;
351246 }
351247 return left->Equals(*right);
351248}

◆ CopyProperties()

void duckdb::TableRef::CopyProperties ( TableRef & target) const

Copy the properties of this table ref to the target.

351228 {
351229 D_ASSERT(type == target.type);
351230 target.alias = alias;
351231 target.query_location = query_location;
351232 target.sample = sample ? sample->Copy() : nullptr;
351233 target.external_dependency = external_dependency;
351234}
shared_ptr< ExternalDependency > external_dependency
External dependencies of this table function.
Definition duckdb.hpp:53742
optional_idx query_location
The location in the query (if any).
Definition duckdb.hpp:53740

◆ Serialize()

void duckdb::TableRef::Serialize ( Serializer & serializer) const
virtual

Reimplemented in duckdb::ColumnDataRef, duckdb::EmptyTableRef, duckdb::ExpressionListRef, duckdb::JoinRef, duckdb::PivotRef, duckdb::ShowRef, duckdb::SubqueryRef, and duckdb::TableFunctionRef.

419588 {
419589 serializer.WriteProperty<TableReferenceType>(100, "type", type);
419590 serializer.WritePropertyWithDefault<string>(101, "alias", alias);
419591 serializer.WritePropertyWithDefault<unique_ptr<SampleOptions>>(102, "sample", sample);
419592 serializer.WritePropertyWithDefault<optional_idx>(103, "query_location", query_location, optional_idx());
419593}

◆ Deserialize()

unique_ptr< TableRef > duckdb::TableRef::Deserialize ( Deserializer & deserializer)
static
419595 {
419596 auto type = deserializer.ReadProperty<TableReferenceType>(100, "type");
419597 auto alias = deserializer.ReadPropertyWithDefault<string>(101, "alias");
419598 auto sample = deserializer.ReadPropertyWithDefault<unique_ptr<SampleOptions>>(102, "sample");
419599 auto query_location = deserializer.ReadPropertyWithExplicitDefault<optional_idx>(103, "query_location", optional_idx());
419600 unique_ptr<TableRef> result;
419601 switch (type) {
419602 case TableReferenceType::BASE_TABLE:
419603 result = BaseTableRef::Deserialize(deserializer);
419604 break;
419605 case TableReferenceType::COLUMN_DATA:
419606 result = ColumnDataRef::Deserialize(deserializer);
419607 break;
419608 case TableReferenceType::EMPTY_FROM:
419609 result = EmptyTableRef::Deserialize(deserializer);
419610 break;
419611 case TableReferenceType::EXPRESSION_LIST:
419612 result = ExpressionListRef::Deserialize(deserializer);
419613 break;
419614 case TableReferenceType::JOIN:
419615 result = JoinRef::Deserialize(deserializer);
419616 break;
419617 case TableReferenceType::PIVOT:
419618 result = PivotRef::Deserialize(deserializer);
419619 break;
419620 case TableReferenceType::SHOW_REF:
419621 result = ShowRef::Deserialize(deserializer);
419622 break;
419623 case TableReferenceType::SUBQUERY:
419624 result = SubqueryRef::Deserialize(deserializer);
419625 break;
419626 case TableReferenceType::TABLE_FUNCTION:
419627 result = TableFunctionRef::Deserialize(deserializer);
419628 break;
419629 default:
419630 throw SerializationException("Unsupported type for deserialization of TableRef!");
419631 }
419632 result->alias = std::move(alias);
419633 result->sample = std::move(sample);
419634 result->query_location = query_location;
419635 return result;
419636}

◆ Cast() [1/2]

template<class TARGET>
TARGET & duckdb::TableRef::Cast ( )
inline
53764 {
53765 if (type != TARGET::TYPE && TARGET::TYPE != TableReferenceType::INVALID) {
53766 throw InternalException("Failed to cast constraint to type - constraint type mismatch");
53767 }
53768 return reinterpret_cast<TARGET &>(*this);
53769 }

◆ Cast() [2/2]

template<class TARGET>
const TARGET & duckdb::TableRef::Cast ( ) const
inline
53772 {
53773 if (type != TARGET::TYPE && TARGET::TYPE != TableReferenceType::INVALID) {
53774 throw InternalException("Failed to cast constraint to type - constraint type mismatch");
53775 }
53776 return reinterpret_cast<const TARGET &>(*this);
53777 }

◆ BaseToString() [1/2]

string duckdb::TableRef::BaseToString ( string result) const
protected
351182 {
351183 vector<string> column_name_alias;
351184 return BaseToString(std::move(result), column_name_alias);
351185}
vector< string > column_name_alias
Aliases for the column names.
Definition duckdb.hpp:53744

◆ BaseToString() [2/2]

string duckdb::TableRef::BaseToString ( string result,
const vector< string > & column_name_alias ) const
protected
351218 {
351219 result += AliasToString(column_name_alias);
351220 result += SampleToString();
351221 return result;
351222}

◆ AliasToString()

string duckdb::TableRef::AliasToString ( const vector< string > & column_name_alias) const
protected
351187 {
351188 string result;
351189 if (!alias.empty()) {
351190 result += StringUtil::Format(" AS %s", SQLIdentifier(alias));
351191 }
351192 if (!column_name_alias.empty()) {
351193 D_ASSERT(!alias.empty());
351194 result += "(";
351195 for (idx_t i = 0; i < column_name_alias.size(); i++) {
351196 if (i > 0) {
351197 result += ", ";
351198 }
351200 }
351201 result += ")";
351202 }
351203 return result;
351204}
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
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237

◆ SampleToString()

string duckdb::TableRef::SampleToString ( ) const
protected
351206 {
351207 string result;
351208 if (sample) {
351209 result += " TABLESAMPLE " + EnumUtil::ToString(sample->method);
351210 result += "(" + sample->sample_size.ToString() + " " + string(sample->is_percentage ? "PERCENT" : "ROWS") + ")";
351211 if (sample->seed.IsValid()) {
351212 result += "REPEATABLE (" + to_string(sample->seed.GetIndex()) + ")";
351213 }
351214 }
351215 return result;
351216}
std::string to_string(const T &value)
Definition duckdb.cpp:19425

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