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

Represents a PIVOT or UNPIVOT expression. More...

Inheritance diagram for duckdb::PivotRef:
Collaboration diagram for duckdb::PivotRef:

Public Member Functions

string ToString () const override
 Convert the object to a string.
bool Equals (const TableRef &other_p) const override
unique_ptr< TableRef > Copy () override
void Serialize (Serializer &serializer) const override
 Deserializes a blob back into a PivotRef.
Public Member Functions inherited from duckdb::TableRef
 TableRef (TableReferenceType type)
void Print ()
void CopyProperties (TableRef &target) const
 Copy the properties of this table ref to the target.
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static unique_ptr< TableRef > Deserialize (Deserializer &source)
Static Public Member Functions inherited from duckdb::TableRef
static bool Equals (const unique_ptr< TableRef > &left, const unique_ptr< TableRef > &right)
static unique_ptr< TableRef > Deserialize (Deserializer &deserializer)

Public Attributes

unique_ptr< TableRef > source
 The source table of the pivot.
vector< unique_ptr< ParsedExpression > > aggregates
 The aggregates to compute over the pivot (PIVOT only).
vector< string > unpivot_names
 The names of the unpivot expressions (UNPIVOT only).
vector< PivotColumn > pivots
 The set of pivots.
vector< string > groups
 The groups to pivot over. If none are specified all columns not included in the pivots/aggregate are chosen.
bool include_nulls
 Whether or not to include nulls in the result (UNPIVOT only).
vector< PivotValueElement > bound_pivot_values
 The set of values to pivot on (bound pivot only).
vector< string > bound_group_names
 The set of bound group names (bound pivot only).
vector< string > bound_aggregate_names
 The set of bound aggregate names (bound pivot only).
Public Attributes inherited from duckdb::TableRef
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::PIVOT
Static Public Attributes inherited from duckdb::TableRef
static constexpr const TableReferenceType TYPE = TableReferenceType::INVALID

Additional Inherited Members

Protected Member Functions inherited from duckdb::TableRef
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 PIVOT or UNPIVOT expression.

Constructor & Destructor Documentation

◆ PivotRef()

duckdb::PivotRef::PivotRef ( )
inlineexplicit
197340 : TableRef(TableReferenceType::PIVOT), include_nulls(false) {
197341 }
bool include_nulls
Whether or not to include nulls in the result (UNPIVOT only).
Definition duckdb.cpp:197354

Member Function Documentation

◆ ToString()

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

Convert the object to a string.

Implements duckdb::TableRef.

350921 {
350922 string result;
350923 result = source->ToString();
350924 if (!aggregates.empty()) {
350925 // pivot
350926 result += " PIVOT (";
350927 for (idx_t aggr_idx = 0; aggr_idx < aggregates.size(); aggr_idx++) {
350928 if (aggr_idx > 0) {
350929 result += ", ";
350930 }
350931 result += aggregates[aggr_idx]->ToString();
350932 if (!aggregates[aggr_idx]->GetAlias().empty()) {
350933 result += " AS " + KeywordHelper::WriteOptionallyQuoted(aggregates[aggr_idx]->GetAlias());
350934 }
350935 }
350936 } else {
350937 // unpivot
350938 result += " UNPIVOT ";
350939 if (include_nulls) {
350940 result += "INCLUDE NULLS ";
350941 }
350942 result += "(";
350943 if (unpivot_names.size() == 1) {
350945 } else {
350946 result += "(";
350947 for (idx_t n = 0; n < unpivot_names.size(); n++) {
350948 if (n > 0) {
350949 result += ", ";
350950 }
350952 }
350953 result += ")";
350954 }
350955 }
350956 result += " FOR";
350957 for (auto &pivot : pivots) {
350958 result += " ";
350959 result += pivot.ToString();
350960 }
350961 if (!groups.empty()) {
350962 result += " GROUP BY ";
350963 for (idx_t i = 0; i < groups.size(); i++) {
350964 if (i > 0) {
350965 result += ", ";
350966 }
350967 result += groups[i];
350968 }
350969 }
350970 result += ")";
350971 if (!alias.empty()) {
350972 result += " AS " + KeywordHelper::WriteOptionallyQuoted(alias);
350973 if (!column_name_alias.empty()) {
350974 result += "(";
350975 for (idx_t i = 0; i < column_name_alias.size(); i++) {
350976 if (i > 0) {
350977 result += ", ";
350978 }
350980 }
350981 result += ")";
350982 }
350983 }
350984 return result;
350985}
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
vector< PivotColumn > pivots
The set of pivots.
Definition duckdb.cpp:197350
vector< string > unpivot_names
The names of the unpivot expressions (UNPIVOT only).
Definition duckdb.cpp:197348
vector< string > groups
The groups to pivot over. If none are specified all columns not included in the pivots/aggregate are ...
Definition duckdb.cpp:197352
vector< unique_ptr< ParsedExpression > > aggregates
The aggregates to compute over the pivot (PIVOT only).
Definition duckdb.cpp:197346
unique_ptr< TableRef > source
The source table of the pivot.
Definition duckdb.cpp:197344
vector< string > column_name_alias
Aliases for the column names.
Definition duckdb.hpp:53744
uint64_t idx_t
a saner size_t for loop indices etc
Definition duckdb.hpp:237
Here is the call graph for this function:

◆ Equals()

bool duckdb::PivotRef::Equals ( const TableRef & other_p) const
overridevirtual

Reimplemented from duckdb::TableRef.

350987 {
350988 if (!TableRef::Equals(other_p)) {
350989 return false;
350990 }
350991 auto &other = other_p.Cast<PivotRef>();
350992 if (!source->Equals(*other.source)) {
350993 return false;
350994 }
350995 if (!ParsedExpression::ListEquals(aggregates, other.aggregates)) {
350996 return false;
350997 }
350998 if (pivots.size() != other.pivots.size()) {
350999 return false;
351000 }
351001 for (idx_t i = 0; i < pivots.size(); i++) {
351002 if (!pivots[i].Equals(other.pivots[i])) {
351003 return false;
351004 }
351005 }
351006 if (unpivot_names != other.unpivot_names) {
351007 return false;
351008 }
351009 if (alias != other.alias) {
351010 return false;
351011 }
351012 if (groups != other.groups) {
351013 return false;
351014 }
351015 if (include_nulls != other.include_nulls) {
351016 return false;
351017 }
351018 return true;
351019}

◆ Copy()

unique_ptr< TableRef > duckdb::PivotRef::Copy ( )
overridevirtual

Implements duckdb::TableRef.

351021 {
351022 auto copy = make_uniq<PivotRef>();
351023 copy->source = source->Copy();
351024 for (auto &aggr : aggregates) {
351025 copy->aggregates.push_back(aggr->Copy());
351026 }
351027 copy->unpivot_names = unpivot_names;
351028 for (auto &entry : pivots) {
351029 copy->pivots.push_back(entry.Copy());
351030 }
351031 copy->groups = groups;
351032 copy->column_name_alias = column_name_alias;
351033 copy->include_nulls = include_nulls;
351034 copy->alias = alias;
351035 return std::move(copy);
351036}

◆ Serialize()

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

Deserializes a blob back into a PivotRef.

Reimplemented from duckdb::TableRef.

419735 {
419736 TableRef::Serialize(serializer);
419737 serializer.WritePropertyWithDefault<unique_ptr<TableRef>>(200, "source", source);
419738 serializer.WritePropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(201, "aggregates", aggregates);
419739 serializer.WritePropertyWithDefault<vector<string>>(202, "unpivot_names", unpivot_names);
419740 serializer.WritePropertyWithDefault<vector<PivotColumn>>(203, "pivots", pivots);
419741 serializer.WritePropertyWithDefault<vector<string>>(204, "groups", groups);
419742 serializer.WritePropertyWithDefault<vector<string>>(205, "column_name_alias", column_name_alias);
419743 serializer.WritePropertyWithDefault<bool>(206, "include_nulls", include_nulls);
419744}

◆ Deserialize()

unique_ptr< TableRef > duckdb::PivotRef::Deserialize ( Deserializer & source)
static
419746 {
419747 auto result = duckdb::unique_ptr<PivotRef>(new PivotRef());
419748 deserializer.ReadPropertyWithDefault<unique_ptr<TableRef>>(200, "source", result->source);
419749 deserializer.ReadPropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(201, "aggregates", result->aggregates);
419750 deserializer.ReadPropertyWithDefault<vector<string>>(202, "unpivot_names", result->unpivot_names);
419751 deserializer.ReadPropertyWithDefault<vector<PivotColumn>>(203, "pivots", result->pivots);
419752 deserializer.ReadPropertyWithDefault<vector<string>>(204, "groups", result->groups);
419753 deserializer.ReadPropertyWithDefault<vector<string>>(205, "column_name_alias", result->column_name_alias);
419754 deserializer.ReadPropertyWithDefault<bool>(206, "include_nulls", result->include_nulls);
419755 return std::move(result);
419756}

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