1#include "duckdb/main/relation/distinct_relation.hpp"
2#include "duckdb/main/client_context.hpp"
3#include "duckdb/parser/query_node.hpp"
4
5namespace duckdb {
6
7DistinctRelation::DistinctRelation(shared_ptr<Relation> child_p)
8 : Relation(child_p->context, RelationType::DISTINCT_RELATION), child(std::move(child_p)) {
9 D_ASSERT(child.get() != this);
10 vector<ColumnDefinition> dummy_columns;
11 context.GetContext()->TryBindRelation(relation&: *this, result_columns&: dummy_columns);
12}
13
14unique_ptr<QueryNode> DistinctRelation::GetQueryNode() {
15 auto child_node = child->GetQueryNode();
16 child_node->AddDistinct();
17 return child_node;
18}
19
20string DistinctRelation::GetAlias() {
21 return child->GetAlias();
22}
23
24const vector<ColumnDefinition> &DistinctRelation::Columns() {
25 return child->Columns();
26}
27
28string DistinctRelation::ToString(idx_t depth) {
29 string str = RenderWhitespace(depth) + "Distinct\n";
30 return str + child->ToString(depth: depth + 1);
31 ;
32}
33
34} // namespace duckdb
35