Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #46771 to 23.2: More concise logging at trace level for PREWHERE steps #46799

Merged
merged 1 commit into from
Feb 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Storages/MergeTree/MergeTreeBaseSelectProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@ IMergeTreeSelectAlgorithm::IMergeTreeSelectAlgorithm(
result_header = header_without_const_virtual_columns;
injectPartConstVirtualColumns(0, result_header, nullptr, partition_value_type, virt_column_names);

LOG_TEST(log, "PREWHERE actions: {}", (prewhere_actions ? prewhere_actions->dump() : std::string("<nullptr>")));
if (prewhere_actions)
LOG_TRACE(log, "PREWHERE condition was split into {} steps: {}", prewhere_actions->steps.size(), prewhere_actions->dumpConditions());

if (prewhere_info)
LOG_TEST(log, "Original PREWHERE DAG:\n{}\nPREWHERE actions:\n{}",
(prewhere_info->prewhere_actions ? prewhere_info->prewhere_actions->dumpDAG(): std::string("<nullptr>")),
(prewhere_actions ? prewhere_actions->dump() : std::string("<nullptr>")));
}

bool tryBuildPrewhereSteps(PrewhereInfoPtr prewhere_info, const ExpressionActionsSettings & actions_settings, PrewhereExprInfo & prewhere);
Expand Down
10 changes: 10 additions & 0 deletions src/Storages/MergeTree/MergeTreeRangeReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1430,4 +1430,14 @@ std::string PrewhereExprInfo::dump() const
return s.str();
}

std::string PrewhereExprInfo::dumpConditions() const
{
WriteBufferFromOwnString s;

for (size_t i = 0; i < steps.size(); ++i)
s << (i == 0 ? "\"" : ", \"") << steps[i].column_name << "\"";

return s.str();
}

}
2 changes: 2 additions & 0 deletions src/Storages/MergeTree/MergeTreeRangeReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ struct PrewhereExprInfo
std::vector<PrewhereExprStep> steps;

std::string dump() const;

std::string dumpConditions() const;
};

class FilterWithCachedCount
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,6 @@ bool tryBuildPrewhereSteps(PrewhereInfoPtr prewhere_info, const ExpressionAction
if (!prewhere_info || !prewhere_info->prewhere_actions)
return true;

Poco::Logger * log = &Poco::Logger::get("tryBuildPrewhereSteps");

LOG_TRACE(log, "Original PREWHERE DAG:\n{}", prewhere_info->prewhere_actions->dumpDAG());

/// 1. List all condition nodes that are combined with AND into PREWHERE condition
const auto & condition_root = prewhere_info->prewhere_actions->findInOutputs(prewhere_info->prewhere_column_name);
const bool is_conjunction = (condition_root.type == ActionsDAG::ActionType::FUNCTION && condition_root.function_base->getName() == "and");
Expand Down Expand Up @@ -339,8 +335,6 @@ bool tryBuildPrewhereSteps(PrewhereInfoPtr prewhere_info, const ExpressionAction
prewhere.steps.back().need_filter = prewhere_info->need_filter;
}

LOG_TRACE(log, "Resulting PREWHERE:\n{}", prewhere.dump());

return true;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
<Test> MergeTreeBaseSelectProcessor: PREWHERE actions: <nullptr>
<Test> MergeTreeRangeReader: First reader returned: num_rows: 1, columns: 1, total_rows_per_granule: 1, no filter, column[0]: Int32(size = 1), requested columns: key
<Test> MergeTreeRangeReader: read() returned num_rows: 1, columns: 1, total_rows_per_granule: 1, no filter, column[0]: Int32(size = 1), sample block key