Some polishing

This commit is contained in:
Igor Nikonov 2023-02-02 11:14:26 +00:00
parent ca72c1269c
commit 996b833faa
2 changed files with 13 additions and 9 deletions

View File

@ -2262,6 +2262,7 @@ ActionsDAGPtr ActionsDAG::buildFilterActionsDAG(
const ActionsDAG::Node * ActionsDAG::getOriginalNodeForOutputAlias(const String & output_name)
{
/// find alias in output
const Node * output_alias = nullptr;
for (const auto * node : outputs)
{
@ -2274,6 +2275,7 @@ const ActionsDAG::Node * ActionsDAG::getOriginalNodeForOutputAlias(const String
if (!output_alias)
return nullptr;
/// find original(non alias) node it refers to
const Node * node = output_alias;
while (node && node->type == ActionsDAG::ActionType::ALIAS)
{

View File

@ -13,17 +13,17 @@
namespace DB::QueryPlanOptimizations
{
constexpr bool debug_logging_enabled = true;
void logDebug(const String & prefix, const String & message)
{
if constexpr (debug_logging_enabled)
{
LOG_DEBUG(&Poco::Logger::get("redundantDistinct"), "{}: {}", prefix, message);
}
}
namespace
{
constexpr bool debug_logging_enabled = false;
void logActionsDAG(const String & prefix, const ActionsDAGPtr & actions)
{
if constexpr (debug_logging_enabled)
{
LOG_DEBUG(&Poco::Logger::get("redundantDistinct"), "{}: {}", prefix, actions->dumpDAG());
}
}
std::set<std::string_view> getDistinctColumns(const DistinctStep * distinct)
{
/// find non-const columns in DISTINCT
@ -100,6 +100,8 @@ size_t tryRemoveRedundantDistinct(QueryPlan::Node * parent_node, QueryPlan::Node
path_actions->mergeInplace(std::move(*clone));
}
logActionsDAG("merged DAG:\n{}", path_actions);
/// compare columns of two DISTINCTs
for (const auto & column : distinct_columns)
{