1//===----------------------------------------------------------------------===//
2// DuckDB
3//
4// duckdb/main/relation/query_relation.hpp
5//
6//
7//===----------------------------------------------------------------------===//
8
9#pragma once
10
11#include "duckdb/main/relation.hpp"
12#include "duckdb/parser/query_node.hpp"
13
14namespace duckdb {
15class SelectStatement;
16
17class QueryRelation : public Relation {
18public:
19 QueryRelation(const std::shared_ptr<ClientContext> &context, unique_ptr<SelectStatement> select_stmt, string alias);
20 ~QueryRelation();
21
22 unique_ptr<SelectStatement> select_stmt;
23 string alias;
24 vector<ColumnDefinition> columns;
25
26public:
27 static unique_ptr<SelectStatement> ParseStatement(ClientContext &context, const string &query, const string &error);
28 unique_ptr<QueryNode> GetQueryNode() override;
29 unique_ptr<TableRef> GetTableRef() override;
30
31 const vector<ColumnDefinition> &Columns() override;
32 string ToString(idx_t depth) override;
33 string GetAlias() override;
34
35private:
36 unique_ptr<SelectStatement> GetSelectStatement();
37};
38
39} // namespace duckdb
40