Skip to content

Commit

Permalink
add _part virtual column into select query as suggested
Browse files Browse the repository at this point in the history
  • Loading branch information
SuzyWangIBMer committed May 13, 2024
1 parent 812ea28 commit dab905e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Analyzer/Passes/UtilizeProjectionPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include <Analyzer/IdentifierNode.h>

#include <Functions/FunctionFactory.h>

#include <Parsers/formatAST.h>
#include <DataTypes/DataTypeString.h>
#include <DataTypes/DataTypeLowCardinality.h>

namespace DB
{
Expand Down Expand Up @@ -84,6 +84,10 @@ class UtilizeProjectionVisitor : public InDepthQueryTreeVisitorWithContext<Utili
for (size_t i = 0; i < primary_keys_col.column_names.size(); i++)
primary_keys.emplace_back(primary_keys_col.column_names.at(i), primary_keys_col.data_types.at(i));

// include virtual column "_part" into select query
auto part_type = std::make_shared<DataTypeLowCardinality>(std::make_shared<DataTypeString>());
primary_keys.emplace_back("_part", part_type);

auto new_node = pkOptimization(projections, node, primary_keys);
query_node->getWhere() = std::move(new_node);
}
Expand Down

0 comments on commit dab905e

Please sign in to comment.