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

Public Member Functions

 QueryRelation (const shared_ptr< ClientContext > &context, unique_ptr< SelectStatement > select_stmt, string alias, const string &query="")
unique_ptr< QueryNode > GetQueryNode () override
string GetQuery () override
unique_ptr< TableRef > GetTableRef () override
BoundStatement Bind (Binder &binder) override
const vector< ColumnDefinition > & Columns () override
string ToString (idx_t depth) override
string GetAlias () override
Public Member Functions inherited from duckdb::Relation
 Relation (const shared_ptr< ClientContext > &context_p, const RelationType type)
 Relation (const shared_ptr< ClientContextWrapper > &context, RelationType type, const string &alias_p="")
 Relation (const shared_ptr< RelationContextWrapper > &context, RelationType type, const string &alias_p="")
DUCKDB_API unique_ptr< QueryResult > ExecuteOrThrow ()
DUCKDB_API unique_ptr< QueryResult > Execute ()
DUCKDB_API string ToString ()
DUCKDB_API void Print ()
DUCKDB_API void Head (idx_t limit=10)
DUCKDB_API shared_ptr< Relation > CreateView (const string &name, bool replace=true, bool temporary=false)
DUCKDB_API shared_ptr< Relation > CreateView (const string &schema_name, const string &name, bool replace=true, bool temporary=false)
DUCKDB_API unique_ptr< QueryResult > Query (const string &sql) const
DUCKDB_API unique_ptr< QueryResult > Query (const string &name, const string &sql)
DUCKDB_API unique_ptr< QueryResult > Explain (ExplainType type=ExplainType::EXPLAIN_STANDARD, ExplainFormat explain_format=ExplainFormat::DEFAULT)
 Explain the query plan of this relation.
virtual bool IsReadOnly ()
DUCKDB_API void TryBindRelation (vector< ColumnDefinition > &columns)
DUCKDB_API shared_ptr< Relation > Project (const string &select_list)
DUCKDB_API shared_ptr< Relation > Project (const string &expression, const string &alias)
DUCKDB_API shared_ptr< Relation > Project (const string &select_list, const vector< string > &aliases)
DUCKDB_API shared_ptr< Relation > Project (const vector< string > &expressions)
DUCKDB_API shared_ptr< Relation > Project (const vector< string > &expressions, const vector< string > &aliases)
DUCKDB_API shared_ptr< Relation > Project (vector< unique_ptr< ParsedExpression > > expressions, const vector< string > &aliases)
DUCKDB_API shared_ptr< Relation > Filter (const string &expression)
DUCKDB_API shared_ptr< Relation > Filter (unique_ptr< ParsedExpression > expression)
DUCKDB_API shared_ptr< Relation > Filter (const vector< string > &expressions)
DUCKDB_API shared_ptr< Relation > Limit (int64_t n, int64_t offset=0)
DUCKDB_API shared_ptr< Relation > Order (const string &expression)
DUCKDB_API shared_ptr< Relation > Order (const vector< string > &expressions)
DUCKDB_API shared_ptr< Relation > Order (vector< OrderByNode > expressions)
DUCKDB_API shared_ptr< Relation > Join (const shared_ptr< Relation > &other, const string &condition, JoinType type=JoinType::INNER, JoinRefType ref_type=JoinRefType::REGULAR)
shared_ptr< Relation > Join (const shared_ptr< Relation > &other, vector< unique_ptr< ParsedExpression > > condition, JoinType type=JoinType::INNER, JoinRefType ref_type=JoinRefType::REGULAR)
DUCKDB_API shared_ptr< Relation > CrossProduct (const shared_ptr< Relation > &other, JoinRefType join_ref_type=JoinRefType::CROSS)
DUCKDB_API shared_ptr< Relation > Union (const shared_ptr< Relation > &other)
DUCKDB_API shared_ptr< Relation > Except (const shared_ptr< Relation > &other)
DUCKDB_API shared_ptr< Relation > Intersect (const shared_ptr< Relation > &other)
DUCKDB_API shared_ptr< Relation > Distinct ()
DUCKDB_API shared_ptr< Relation > Aggregate (const string &aggregate_list)
DUCKDB_API shared_ptr< Relation > Aggregate (const vector< string > &aggregates)
DUCKDB_API shared_ptr< Relation > Aggregate (vector< unique_ptr< ParsedExpression > > expressions)
DUCKDB_API shared_ptr< Relation > Aggregate (const string &aggregate_list, const string &group_list)
DUCKDB_API shared_ptr< Relation > Aggregate (const vector< string > &aggregates, const vector< string > &groups)
DUCKDB_API shared_ptr< Relation > Aggregate (vector< unique_ptr< ParsedExpression > > expressions, const string &group_list)
DUCKDB_API shared_ptr< Relation > Alias (const string &alias)
DUCKDB_API shared_ptr< Relation > InsertRel (const string &schema_name, const string &table_name)
 Insert the data from this relation into a table.
DUCKDB_API shared_ptr< Relation > InsertRel (const string &catalog_name, const string &schema_name, const string &table_name)
DUCKDB_API void Insert (const string &table_name)
DUCKDB_API void Insert (const string &schema_name, const string &table_name)
DUCKDB_API void Insert (const string &catalog_name, const string &schema_name, const string &table_name)
virtual DUCKDB_API void Insert (const vector< vector< Value > > &values)
 Insert a row (i.e.,list of values) into a table.
virtual DUCKDB_API void Insert (vector< vector< unique_ptr< ParsedExpression > > > &&expressions)
DUCKDB_API shared_ptr< Relation > CreateRel (const string &schema_name, const string &table_name, bool temporary=false, OnCreateConflict on_conflict=OnCreateConflict::ERROR_ON_CONFLICT)
 Create a table and insert the data from this relation into that table.
DUCKDB_API shared_ptr< Relation > CreateRel (const string &catalog_name, const string &schema_name, const string &table_name, bool temporary=false, OnCreateConflict on_conflict=OnCreateConflict::ERROR_ON_CONFLICT)
DUCKDB_API void Create (const string &table_name, bool temporary=false, OnCreateConflict on_conflict=OnCreateConflict::ERROR_ON_CONFLICT)
DUCKDB_API void Create (const string &schema_name, const string &table_name, bool temporary=false, OnCreateConflict on_conflict=OnCreateConflict::ERROR_ON_CONFLICT)
DUCKDB_API void Create (const string &catalog_name, const string &schema_name, const string &table_name, bool temporary=false, OnCreateConflict on_conflict=OnCreateConflict::ERROR_ON_CONFLICT)
DUCKDB_API shared_ptr< Relation > WriteCSVRel (const string &csv_file, case_insensitive_map_t< vector< Value > > options=case_insensitive_map_t< vector< Value > >())
 Write a relation to a CSV file.
DUCKDB_API void WriteCSV (const string &csv_file, case_insensitive_map_t< vector< Value > > options=case_insensitive_map_t< vector< Value > >())
DUCKDB_API shared_ptr< Relation > WriteParquetRel (const string &parquet_file, case_insensitive_map_t< vector< Value > > options=case_insensitive_map_t< vector< Value > >())
 Write a relation to a Parquet file.
DUCKDB_API void WriteParquet (const string &parquet_file, case_insensitive_map_t< vector< Value > > options=case_insensitive_map_t< vector< Value > >())
virtual DUCKDB_API void Update (const string &update, const string &condition=string())
 Update a table, can only be used on a TableRelation.
virtual DUCKDB_API void Update (vector< string > column_names, vector< unique_ptr< ParsedExpression > > &&update, unique_ptr< ParsedExpression > condition=nullptr)
virtual DUCKDB_API void Delete (const string &condition=string())
 Delete from a table, can only be used on a TableRelation.
DUCKDB_API shared_ptr< Relation > TableFunction (const std::string &fname, const vector< Value > &values)
 Create a relation from calling a table in/out function on the input relation Create a relation from calling a table in/out function on the input relation.
DUCKDB_API shared_ptr< Relation > TableFunction (const std::string &fname, const vector< Value > &values, const named_parameter_map_t &named_parameters)
virtual bool InheritsColumnBindings ()
 Whether or not the relation inherits column bindings from its child or not, only relevant for binding.
virtual Relation * ChildRelation ()
void AddExternalDependency (shared_ptr< ExternalDependency > dependency)
DUCKDB_API vector< shared_ptr< ExternalDependency > > GetAllDependencies ()
template<class TARGET>
TARGET & Cast ()
template<class TARGET>
const TARGET & Cast () const
Public Member Functions inherited from duckdb::enable_shared_from_this< Relation >
shared_ptr< Relation > shared_from_this ()

Static Public Member Functions

static unique_ptr< SelectStatement > ParseStatement (ClientContext &context, const string &query, const string &error)

Public Attributes

unique_ptr< SelectStatement > select_stmt
string query
string alias
vector< ColumnDefinition > columns
Public Attributes inherited from duckdb::Relation
shared_ptr< ClientContextWrapper > context
RelationType type
const string alias
vector< shared_ptr< ExternalDependency > > external_dependencies

Private Member Functions

unique_ptr< SelectStatement > GetSelectStatement ()

Additional Inherited Members

Protected Member Functions inherited from duckdb::enable_shared_from_this< Relation >
enable_shared_from_this & operator= (enable_shared_from_this const &) noexcept
Static Protected Member Functions inherited from duckdb::Relation
static DUCKDB_API string RenderWhitespace (idx_t depth)

Constructor & Destructor Documentation

◆ QueryRelation()

duckdb::QueryRelation::QueryRelation ( const shared_ptr< ClientContext > & context,
unique_ptr< SelectStatement > select_stmt,
string alias,
const string & query = "" )
298018 : Relation(context, RelationType::QUERY_RELATION), select_stmt(std::move(select_stmt_p)), query(query_p),
298019 alias(std::move(alias_p)) {
298020 if (query.empty()) {
298021 query = select_stmt->ToString();
298022 }
298023 TryBindRelation(columns);
298024}

◆ ~QueryRelation()

duckdb::QueryRelation::~QueryRelation ( )
override
298026 {
298027}

Member Function Documentation

◆ ParseStatement()

unique_ptr< SelectStatement > duckdb::QueryRelation::ParseStatement ( ClientContext & context,
const string & query,
const string & error )
static
298030 {
298031 Parser parser(context.GetParserOptions());
298032 parser.ParseQuery(query);
298033 if (parser.statements.size() != 1) {
298034 throw ParserException(error);
298035 }
298036 if (parser.statements[0]->type != StatementType::SELECT_STATEMENT) {
298037 throw ParserException(error);
298038 }
298039 return unique_ptr_cast<SQLStatement, SelectStatement>(std::move(parser.statements[0]));
298040}

◆ GetQueryNode()

unique_ptr< QueryNode > duckdb::QueryRelation::GetQueryNode ( )
overridevirtual

Implements duckdb::Relation.

298046 {
298047 auto select = GetSelectStatement();
298048 return std::move(select->node);
298049}
GMat select(const GMat &src1, const GMat &src2, const GMat &mask)

◆ GetQuery()

string duckdb::QueryRelation::GetQuery ( )
overridevirtual

Reimplemented from duckdb::Relation.

298051 {
298052 return query;
298053}

◆ GetTableRef()

unique_ptr< TableRef > duckdb::QueryRelation::GetTableRef ( )
overridevirtual

Reimplemented from duckdb::Relation.

298055 {
298056 auto subquery_ref = make_uniq<SubqueryRef>(GetSelectStatement(), GetAlias());
298057 return std::move(subquery_ref);
298058}

◆ Bind()

BoundStatement duckdb::QueryRelation::Bind ( Binder & binder)
overridevirtual

Reimplemented from duckdb::Relation.

298060 {
298061 auto saved_binding_mode = binder.GetBindingMode();
298062 binder.SetBindingMode(BindingMode::EXTRACT_REPLACEMENT_SCANS);
298063 bool first_bind = columns.empty();
298064 auto result = Relation::Bind(binder);
298065 auto &replacements = binder.GetReplacementScans();
298066 if (first_bind) {
298067 for (auto &kv : replacements) {
298068 auto &name = kv.first;
298069 auto &tableref = kv.second;
298070
298071 if (!tableref->external_dependency) {
298072 // Only push a CTE for objects that are out of our control (i.e Python)
298073 // This makes sure replacement scans for files (parquet/csv/json etc) are not transformed into a CTE
298074 continue;
298075 }
298076
298077 auto select = make_uniq<SelectStatement>();
298078 auto select_node = make_uniq<SelectNode>();
298079 select_node->select_list.push_back(make_uniq<StarExpression>());
298080 select_node->from_table = std::move(tableref);
298081 select->node = std::move(select_node);
298082
298083 auto cte_info = make_uniq<CommonTableExpressionInfo>();
298084 cte_info->query = std::move(select);
298085
298086 auto subquery = make_uniq<SubqueryRef>(std::move(select_stmt), "query_relation");
298087 auto top_level_select = make_uniq<SelectStatement>();
298088 auto top_level_select_node = make_uniq<SelectNode>();
298089 top_level_select_node->select_list.push_back(make_uniq<StarExpression>());
298090 top_level_select_node->from_table = std::move(subquery);
298091 auto &cte_map = top_level_select_node->cte_map;
298092 top_level_select->node = std::move(top_level_select_node);
298093 cte_map.map[name] = std::move(cte_info);
298094 select_stmt = std::move(top_level_select);
298095 }
298096 }
298097 replacements.clear();
298098 binder.SetBindingMode(saved_binding_mode);
298099 return result;
298100}

◆ Columns()

const vector< ColumnDefinition > & duckdb::QueryRelation::Columns ( )
overridevirtual

Implements duckdb::Relation.

298106 {
298107 return columns;
298108}

◆ ToString()

string duckdb::QueryRelation::ToString ( idx_t depth)
overridevirtual

Implements duckdb::Relation.

298110 {
298111 return RenderWhitespace(depth) + "Subquery";
298112}

◆ GetAlias()

string duckdb::QueryRelation::GetAlias ( )
overridevirtual

Reimplemented from duckdb::Relation.

298102 {
298103 return alias;
298104}

◆ GetSelectStatement()

unique_ptr< SelectStatement > duckdb::QueryRelation::GetSelectStatement ( )
private
298042 {
298043 return unique_ptr_cast<SQLStatement, SelectStatement>(select_stmt->Copy());
298044}

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