mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-25 00:52:02 +00:00
EXPLAIN PLAN sortmode options
+ ActionsDAG fixes
This commit is contained in:
parent
0a659f5ab8
commit
a70c47f780
@ -1932,7 +1932,6 @@ bool ActionsDAG::isSortingPreserved(const SortDescription & sort_description) co
|
||||
const Field field{};
|
||||
std::unordered_set<const Node *> visited_nodes;
|
||||
|
||||
bool column_found = false;
|
||||
for (const auto & head : nodes)
|
||||
{
|
||||
const auto * root = &head;
|
||||
@ -1953,8 +1952,6 @@ bool ActionsDAG::isSortingPreserved(const SortDescription & sort_description) co
|
||||
/// if found column
|
||||
if (node == column)
|
||||
{
|
||||
column_found = true;
|
||||
|
||||
backtrace.pop(); /// pop column itself
|
||||
|
||||
/// walk back to root and check functions
|
||||
@ -1994,16 +1991,25 @@ bool ActionsDAG::isSortingPreserved(const SortDescription & sort_description) co
|
||||
}
|
||||
}
|
||||
|
||||
return column_found;
|
||||
return true;
|
||||
};
|
||||
|
||||
for (const auto & column_sort_desc : sort_description)
|
||||
{
|
||||
const auto * node = tryFindInIndex(column_sort_desc.column_name);
|
||||
if (node && node->type == ActionsDAG::ActionType::INPUT)
|
||||
for (const auto * node : inputs)
|
||||
{
|
||||
if (!node_preserve_sorting(node))
|
||||
if (!node)
|
||||
continue;
|
||||
|
||||
if (node->result_name == column_sort_desc.column_name || (node->column && isColumnConst(*node->column)))
|
||||
{
|
||||
if (!node_preserve_sorting(node))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -174,7 +174,8 @@ struct QueryPlanSettings
|
||||
{"actions", query_plan_options.actions},
|
||||
{"indexes", query_plan_options.indexes},
|
||||
{"optimize", optimize},
|
||||
{"json", json}
|
||||
{"json", json},
|
||||
{"sortmode", query_plan_options.sort_mode},
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -327,7 +327,11 @@ static void explainStep(
|
||||
}
|
||||
settings.out.write('\n');
|
||||
|
||||
if (step.hasOutputStream() && step.getOutputStream().header)
|
||||
}
|
||||
|
||||
if (options.sort_mode)
|
||||
{
|
||||
if (step.hasOutputStream())
|
||||
{
|
||||
settings.out << prefix << "Sort Mode: " << step.getOutputStream().sort_mode;
|
||||
if (step.getOutputStream().sort_mode != DataStream::SortMode::None)
|
||||
|
@ -71,6 +71,8 @@ public:
|
||||
bool actions = false;
|
||||
/// Add information about indexes actions.
|
||||
bool indexes = false;
|
||||
/// Add information about sort mode
|
||||
bool sort_mode = false;
|
||||
};
|
||||
|
||||
struct ExplainPipelineOptions
|
||||
|
Loading…
Reference in New Issue
Block a user