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

SelectNode represents a standard SELECT statement. More...

Inheritance diagram for duckdb::SelectNode:
Collaboration diagram for duckdb::SelectNode:

Public Member Functions

string ToString () const override
 Convert the query node to a string.
bool Equals (const QueryNode *other) const override
unique_ptr< QueryNode > Copy () const override
 Create a copy of this SelectNode.
void Serialize (Serializer &serializer) const override
 Serializes a QueryNode to a stand-alone binary blob.
Public Member Functions inherited from duckdb::QueryNode
 QueryNode (QueryNodeType type)
string ResultModifiersToString () const
void AddDistinct ()
 Adds a distinct modifier to the query node.
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const

Static Public Member Functions

static unique_ptr< QueryNode > Deserialize (Deserializer &deserializer)
Static Public Member Functions inherited from duckdb::QueryNode
static unique_ptr< QueryNode > Deserialize (Deserializer &deserializer)

Public Attributes

vector< unique_ptr< ParsedExpression > > select_list
 The projection list.
unique_ptr< TableRef > from_table
 The FROM clause.
unique_ptr< ParsedExpression > where_clause
 The WHERE clause.
GroupByNode groups
 list of groups
unique_ptr< ParsedExpression > having
 HAVING clause.
unique_ptr< ParsedExpression > qualify
 QUALIFY clause.
AggregateHandling aggregate_handling
 Aggregate handling during binding.
unique_ptr< SampleOptions > sample
 The SAMPLE clause.
Public Attributes inherited from duckdb::QueryNode
QueryNodeType type
 The type of the query node, either SetOperation or Select.
vector< unique_ptr< ResultModifier > > modifiers
 The set of result modifiers associated with this query node.
CommonTableExpressionMap cte_map
 CTEs (used by SelectNode and SetOperationNode).

Static Public Attributes

static constexpr const QueryNodeType TYPE = QueryNodeType::SELECT_NODE

Additional Inherited Members

Protected Member Functions inherited from duckdb::QueryNode
void CopyProperties (QueryNode &other) const
 Copy base QueryNode properties from another expression to this one, used in Copy method.

Detailed Description

SelectNode represents a standard SELECT statement.

Constructor & Destructor Documentation

◆ SelectNode()

duckdb::SelectNode::SelectNode ( )
348053 : QueryNode(QueryNodeType::SELECT_NODE), aggregate_handling(AggregateHandling::STANDARD_HANDLING) {
348054}
AggregateHandling aggregate_handling
Aggregate handling during binding.
Definition duckdb.cpp:197266

Member Function Documentation

◆ ToString()

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

Convert the query node to a string.

Implements duckdb::QueryNode.

348056 {
348057 if (from_table && from_table->type == TableReferenceType::SHOW_REF) {
348058 D_ASSERT(select_list.size() == 1);
348059 return from_table->ToString();
348060 }
348061 string result;
348062 result = cte_map.ToString();
348063 result += "SELECT ";
348064
348065 // search for a distinct modifier
348066 for (idx_t modifier_idx = 0; modifier_idx < modifiers.size(); modifier_idx++) {
348067 if (modifiers[modifier_idx]->type == ResultModifierType::DISTINCT_MODIFIER) {
348068 auto &distinct_modifier = modifiers[modifier_idx]->Cast<DistinctModifier>();
348069 result += "DISTINCT ";
348070 if (!distinct_modifier.distinct_on_targets.empty()) {
348071 result += "ON (";
348072 for (idx_t k = 0; k < distinct_modifier.distinct_on_targets.size(); k++) {
348073 if (k > 0) {
348074 result += ", ";
348075 }
348076 result += distinct_modifier.distinct_on_targets[k]->ToString();
348077 }
348078 result += ") ";
348079 }
348080 }
348081 }
348082 for (idx_t i = 0; i < select_list.size(); i++) {
348083 if (i > 0) {
348084 result += ", ";
348085 }
348086 result += select_list[i]->ToString();
348087 if (!select_list[i]->GetAlias().empty()) {
348088 result += StringUtil::Format(" AS %s", SQLIdentifier(select_list[i]->GetAlias()));
348089 }
348090 }
348091 if (from_table && from_table->type != TableReferenceType::EMPTY_FROM) {
348092 result += " FROM " + from_table->ToString();
348093 }
348094 if (where_clause) {
348095 result += " WHERE " + where_clause->ToString();
348096 }
348097 if (!groups.grouping_sets.empty()) {
348098 result += " GROUP BY ";
348099 // if we are dealing with multiple grouping sets, we have to add a few additional brackets
348100 bool grouping_sets = groups.grouping_sets.size() > 1;
348101 if (grouping_sets) {
348102 result += "GROUPING SETS (";
348103 }
348104 for (idx_t i = 0; i < groups.grouping_sets.size(); i++) {
348105 auto &grouping_set = groups.grouping_sets[i];
348106 if (i > 0) {
348107 result += ",";
348108 }
348109 if (grouping_set.empty()) {
348110 result += "()";
348111 continue;
348112 }
348113 if (grouping_sets) {
348114 result += "(";
348115 }
348116 bool first = true;
348117 for (auto &grp : grouping_set) {
348118 if (!first) {
348119 result += ", ";
348120 }
348121 result += groups.group_expressions[grp]->ToString();
348122 first = false;
348123 }
348124 if (grouping_sets) {
348125 result += ")";
348126 }
348127 }
348128 if (grouping_sets) {
348129 result += ")";
348130 }
348131 } else if (aggregate_handling == AggregateHandling::FORCE_AGGREGATES) {
348132 result += " GROUP BY ALL";
348133 }
348134 if (having) {
348135 result += " HAVING " + having->ToString();
348136 }
348137 if (qualify) {
348138 result += " QUALIFY " + qualify->ToString();
348139 }
348140 if (sample) {
348141 result += " USING SAMPLE ";
348142 result += sample->sample_size.ToString();
348143 if (sample->is_percentage) {
348144 result += "%";
348145 }
348146 result += " (" + EnumUtil::ToString(sample->method);
348147 if (sample->seed.IsValid()) {
348148 result += ", " + std::to_string(sample->seed.GetIndex());
348149 }
348150 result += ")";
348151 }
348152
348153 return result + ResultModifiersToString();
348154}
CommonTableExpressionMap cte_map
CTEs (used by SelectNode and SetOperationNode).
Definition duckdb.hpp:53582
QueryNodeType type
The type of the query node, either SetOperation or Select.
Definition duckdb.hpp:53578
vector< unique_ptr< ResultModifier > > modifiers
The set of result modifiers associated with this query node.
Definition duckdb.hpp:53580
vector< unique_ptr< ParsedExpression > > select_list
The projection list.
Definition duckdb.cpp:197254
GroupByNode groups
list of groups
Definition duckdb.cpp:197260
unique_ptr< ParsedExpression > having
HAVING clause.
Definition duckdb.cpp:197262
unique_ptr< ParsedExpression > where_clause
The WHERE clause.
Definition duckdb.cpp:197258
unique_ptr< ParsedExpression > qualify
QUALIFY clause.
Definition duckdb.cpp:197264
unique_ptr< TableRef > from_table
The FROM clause.
Definition duckdb.cpp:197256
unique_ptr< SampleOptions > sample
The SAMPLE clause.
Definition duckdb.cpp:197268
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
Here is the call graph for this function:

◆ Equals()

bool duckdb::SelectNode::Equals ( const QueryNode * other) const
overridevirtual

Reimplemented from duckdb::QueryNode.

348156 {
348157 if (!QueryNode::Equals(other_p)) {
348158 return false;
348159 }
348160 if (this == other_p) {
348161 return true;
348162 }
348163 auto &other = other_p->Cast<SelectNode>();
348164
348165 // SELECT
348166 if (!ExpressionUtil::ListEquals(select_list, other.select_list)) {
348167 return false;
348168 }
348169 // FROM
348170 if (!TableRef::Equals(from_table, other.from_table)) {
348171 return false;
348172 }
348173 // WHERE
348174 if (!ParsedExpression::Equals(where_clause, other.where_clause)) {
348175 return false;
348176 }
348177 // GROUP BY
348178 if (!ParsedExpression::ListEquals(groups.group_expressions, other.groups.group_expressions)) {
348179 return false;
348180 }
348181 if (groups.grouping_sets != other.groups.grouping_sets) {
348182 return false;
348183 }
348184 if (!SampleOptions::Equals(sample.get(), other.sample.get())) {
348185 return false;
348186 }
348187 // HAVING
348188 if (!ParsedExpression::Equals(having, other.having)) {
348189 return false;
348190 }
348191 // QUALIFY
348192 if (!ParsedExpression::Equals(qualify, other.qualify)) {
348193 return false;
348194 }
348195 return true;
348196}
static bool ListEquals(const vector< unique_ptr< ParsedExpression > > &a, const vector< unique_ptr< ParsedExpression > > &b)
ListEquals: check if a list of two expressions is equal (order is important).
Definition duckdb.cpp:337970
bool Equals(const BaseExpression &other) const override
Returns true if this expression is equal to another expression.
Definition duckdb.cpp:340462

◆ Copy()

unique_ptr< QueryNode > duckdb::SelectNode::Copy ( ) const
overridevirtual

Create a copy of this SelectNode.

Implements duckdb::QueryNode.

348198 {
348199 auto result = make_uniq<SelectNode>();
348200 for (auto &child : select_list) {
348201 result->select_list.push_back(child->Copy());
348202 }
348203 result->from_table = from_table ? from_table->Copy() : nullptr;
348204 result->where_clause = where_clause ? where_clause->Copy() : nullptr;
348205 // groups
348206 for (auto &group : groups.group_expressions) {
348207 result->groups.group_expressions.push_back(group->Copy());
348208 }
348209 result->groups.grouping_sets = groups.grouping_sets;
348210 result->aggregate_handling = aggregate_handling;
348211 result->having = having ? having->Copy() : nullptr;
348212 result->qualify = qualify ? qualify->Copy() : nullptr;
348213 result->sample = sample ? sample->Copy() : nullptr;
348214 this->CopyProperties(*result);
348215 return std::move(result);
348216}
void CopyProperties(QueryNode &other) const
Copy base QueryNode properties from another expression to this one, used in Copy method.
Definition duckdb.cpp:348602
Here is the call graph for this function:

◆ Serialize()

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

Serializes a QueryNode to a stand-alone binary blob.

Deserializes a blob back into a QueryNode

Reimplemented from duckdb::QueryNode.

419116 {
419117 QueryNode::Serialize(serializer);
419118 serializer.WritePropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(200, "select_list", select_list);
419119 serializer.WritePropertyWithDefault<unique_ptr<TableRef>>(201, "from_table", from_table);
419120 serializer.WritePropertyWithDefault<unique_ptr<ParsedExpression>>(202, "where_clause", where_clause);
419121 serializer.WritePropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(203, "group_expressions", groups.group_expressions);
419122 serializer.WritePropertyWithDefault<vector<GroupingSet>>(204, "group_sets", groups.grouping_sets);
419123 serializer.WriteProperty<AggregateHandling>(205, "aggregate_handling", aggregate_handling);
419124 serializer.WritePropertyWithDefault<unique_ptr<ParsedExpression>>(206, "having", having);
419125 serializer.WritePropertyWithDefault<unique_ptr<SampleOptions>>(207, "sample", sample);
419126 serializer.WritePropertyWithDefault<unique_ptr<ParsedExpression>>(208, "qualify", qualify);
419127}

◆ Deserialize()

unique_ptr< QueryNode > duckdb::SelectNode::Deserialize ( Deserializer & deserializer)
static
419129 {
419130 auto result = duckdb::unique_ptr<SelectNode>(new SelectNode());
419131 deserializer.ReadPropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(200, "select_list", result->select_list);
419132 deserializer.ReadPropertyWithDefault<unique_ptr<TableRef>>(201, "from_table", result->from_table);
419133 deserializer.ReadPropertyWithDefault<unique_ptr<ParsedExpression>>(202, "where_clause", result->where_clause);
419134 deserializer.ReadPropertyWithDefault<vector<unique_ptr<ParsedExpression>>>(203, "group_expressions", result->groups.group_expressions);
419135 deserializer.ReadPropertyWithDefault<vector<GroupingSet>>(204, "group_sets", result->groups.grouping_sets);
419136 deserializer.ReadProperty<AggregateHandling>(205, "aggregate_handling", result->aggregate_handling);
419137 deserializer.ReadPropertyWithDefault<unique_ptr<ParsedExpression>>(206, "having", result->having);
419138 deserializer.ReadPropertyWithDefault<unique_ptr<SampleOptions>>(207, "sample", result->sample);
419139 deserializer.ReadPropertyWithDefault<unique_ptr<ParsedExpression>>(208, "qualify", result->qualify);
419140 return std::move(result);
419141}

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