From f04bd0643d3df34b932fa8b3a4770390a0cc9fa2 Mon Sep 17 00:00:00 2001 From: feng lv Date: Wed, 11 Nov 2020 03:45:06 +0000 Subject: [PATCH] fix test fix fix --- .../InterpreterSelectWithUnionQuery.cpp | 12 +- src/Parsers/ParserSelectWithUnionQuery.cpp | 2 +- ..._explain_select_with_union_query.reference | 216 ++++++++++++------ 3 files changed, 150 insertions(+), 80 deletions(-) diff --git a/src/Interpreters/InterpreterSelectWithUnionQuery.cpp b/src/Interpreters/InterpreterSelectWithUnionQuery.cpp index 1932f49ddc9..a836dc8b271 100644 --- a/src/Interpreters/InterpreterSelectWithUnionQuery.cpp +++ b/src/Interpreters/InterpreterSelectWithUnionQuery.cpp @@ -33,10 +33,8 @@ struct CustomizeASTSelectWithUnionQueryNormalize { if (auto * inner_union = ast_select->as()) { - /// We need flatten from last to first - for (auto child = inner_union->list_of_selects->children.rbegin(); child != inner_union->list_of_selects->children.rend(); - ++child) - getSelectsFromUnionListNode(*child, selects); + for (auto & child : inner_union->list_of_selects->children) + getSelectsFromUnionListNode(child, selects); return; } @@ -85,13 +83,13 @@ struct CustomizeASTSelectWithUnionQueryNormalize auto distinct_list = std::make_shared(); distinct_list->list_of_selects = std::make_shared(); distinct_list->children.push_back(distinct_list->list_of_selects); - for (int j = i + 1; j >= 0; j--) + + for (int j = 0; j <= i + 1; ++j) { getSelectsFromUnionListNode(select_list[j], distinct_list->list_of_selects->children); } + distinct_list->union_mode = ASTSelectWithUnionQuery::Mode::DISTINCT; - // Reverse children list - std::reverse(distinct_list->list_of_selects->children.begin(), distinct_list->list_of_selects->children.end()); distinct_list->is_normalized = true; selects.push_back(std::move(distinct_list)); break; diff --git a/src/Parsers/ParserSelectWithUnionQuery.cpp b/src/Parsers/ParserSelectWithUnionQuery.cpp index efda8e43ca9..9a644d8e937 100644 --- a/src/Parsers/ParserSelectWithUnionQuery.cpp +++ b/src/Parsers/ParserSelectWithUnionQuery.cpp @@ -38,7 +38,7 @@ bool ParserSelectWithUnionQuery::parseImpl(Pos & pos, ASTPtr & node, Expected & auto select_with_union_query = std::make_shared(); node = select_with_union_query; - select_with_union_query->list_of_selects = list_node; //std::make_shared(); + select_with_union_query->list_of_selects = list_node; select_with_union_query->children.push_back(select_with_union_query->list_of_selects); select_with_union_query->list_of_modes = parser.getUnionModes(); diff --git a/tests/queries/0_stateless/01556_explain_select_with_union_query.reference b/tests/queries/0_stateless/01556_explain_select_with_union_query.reference index cf892c2c591..2d09a1f8625 100644 --- a/tests/queries/0_stateless/01556_explain_select_with_union_query.reference +++ b/tests/queries/0_stateless/01556_explain_select_with_union_query.reference @@ -1,252 +1,324 @@ Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Distinct Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Union Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne) Expression (Projection) Expression (Before ORDER BY and SELECT) - ReadFromStorage (Read from SystemOne) + SettingQuotaAndLimits (Set limits and quota after reading from storage) + ReadFromStorage (SystemOne)