From 0f415424f84926721364e9309d2591b2e754e1a1 Mon Sep 17 00:00:00 2001 From: zhang2014 Date: Sun, 21 Jan 2018 18:58:13 +0800 Subject: [PATCH] ISSUES-320 fix failed test --- .../src/Interpreters/InterpreterSelectQuery.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/dbms/src/Interpreters/InterpreterSelectQuery.cpp b/dbms/src/Interpreters/InterpreterSelectQuery.cpp index 6d23b401088..17718571ca9 100644 --- a/dbms/src/Interpreters/InterpreterSelectQuery.cpp +++ b/dbms/src/Interpreters/InterpreterSelectQuery.cpp @@ -95,8 +95,8 @@ void InterpreterSelectQuery::init(const BlockInputStreamPtr & input, const Names ASTSelectQuery & head_query = static_cast(*head); tail = head_query.next_union_all; - interpreter->next_select_in_union_all = std::make_unique( - head, context, required_column_names, to_stage, subquery_depth); + interpreter->next_select_in_union_all = + std::make_unique(head, context, to_stage, subquery_depth); interpreter = interpreter->next_select_in_union_all.get(); } } @@ -119,10 +119,17 @@ void InterpreterSelectQuery::init(const BlockInputStreamPtr & input, const Names } else { - if (!required_column_names.empty()) - rewriteExpressionList(required_column_names); - renameColumns(); + if (!required_column_names.empty()) { + rewriteExpressionList(required_column_names); + + if (is_first_select_inside_union_all) { + for (auto p = next_select_in_union_all.get(); p != nullptr; p = p->next_select_in_union_all.get()) + p->query_analyzer.reset(new ExpressionAnalyzer( + p->query_ptr, p->context, p->storage, p->table_column_names, p->subquery_depth, !only_analyze)); + } + } + basicInit(input); } }