Coverage Report

Created: 2026-11-11 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/duckdb/src/main/relation/materialized_relation.cpp
Line
Count
Source
1
#include "duckdb/main/relation/materialized_relation.hpp"
2
#include "duckdb/parser/query_node/select_node.hpp"
3
#include "duckdb/main/client_context.hpp"
4
#include "duckdb/planner/bound_statement.hpp"
5
#include "duckdb/planner/operator/logical_column_data_get.hpp"
6
#include "duckdb/parser/tableref/column_data_ref.hpp"
7
#include "duckdb/parser/expression/star_expression.hpp"
8
#include "duckdb/common/exception.hpp"
9
10
namespace duckdb {
11
12
MaterializedRelation::MaterializedRelation(const shared_ptr<ClientContext> &context,
13
                                           unique_ptr<ColumnDataCollection> &&collection_p, vector<Identifier> names,
14
                                           const Identifier &alias_p)
15
0
    : Relation(context, RelationType::MATERIALIZED_RELATION), alias(alias_p.GetIdentifierName()),
16
0
      collection(std::move(collection_p)) {
17
  // create constant expressions for the values
18
0
  auto types = collection->Types();
19
0
  D_ASSERT(types.size() == names.size());
20
21
0
  QueryResult::DeduplicateColumns(names);
22
0
  for (idx_t i = 0; i < types.size(); i++) {
23
0
    auto &type = types[i];
24
0
    auto &name = names[i];
25
0
    auto column_definition = ColumnDefinition(name, type);
26
0
    columns.push_back(std::move(column_definition));
27
0
  }
28
0
}
29
30
0
unique_ptr<QueryNode> MaterializedRelation::GetQueryNode() {
31
0
  auto result = make_uniq<SelectNode>();
32
0
  result->select_list.push_back(make_uniq<StarExpression>());
33
0
  result->from_table = GetTableRef();
34
0
  return std::move(result);
35
0
}
36
37
0
unique_ptr<TableRef> MaterializedRelation::GetTableRef() {
38
0
  auto table_ref = make_uniq<ColumnDataRef>(collection);
39
0
  for (auto &col : columns) {
40
0
    table_ref->expected_names.emplace_back(col.Name());
41
0
  }
42
0
  table_ref->alias = Identifier(GetAlias());
43
0
  return std::move(table_ref);
44
0
}
45
46
0
Identifier MaterializedRelation::GetAlias() {
47
0
  return Identifier(alias);
48
0
}
49
50
0
const vector<ColumnDefinition> &MaterializedRelation::Columns() {
51
0
  return columns;
52
0
}
53
54
0
string MaterializedRelation::ToString(idx_t depth) {
55
0
  return collection->ToString();
56
0
}
57
58
} // namespace duckdb