mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-23 08:02:02 +00:00
fix union all bug #1059
This commit is contained in:
parent
e0a1e6982b
commit
a80ebcdbc2
@ -100,7 +100,7 @@ void InterpreterSelectQuery::init(const BlockInputStreamPtr & input, const Names
|
||||
}
|
||||
}
|
||||
|
||||
if (is_first_select_inside_union_all && hasAsterisk())
|
||||
if (is_first_select_inside_union_all && (hasAsterisk() || hasAggregation(&query)))
|
||||
{
|
||||
basicInit(input);
|
||||
|
||||
@ -126,6 +126,25 @@ void InterpreterSelectQuery::init(const BlockInputStreamPtr & input, const Names
|
||||
}
|
||||
}
|
||||
|
||||
bool InterpreterSelectQuery::hasAggregation(ASTSelectQuery * query_ptr){
|
||||
if(!query_ptr) {
|
||||
return false;
|
||||
}
|
||||
if(query_ptr->group_expression_list || query_ptr->having_expression) {
|
||||
return true;
|
||||
}
|
||||
ASTPtr tail = query_ptr->next_union_all;
|
||||
while(tail) {
|
||||
ASTPtr head = tail;
|
||||
ASTSelectQuery & head_query = static_cast<ASTSelectQuery &>(*head);
|
||||
if(head_query.group_expression_list || head_query.having_expression) {
|
||||
return true;
|
||||
}
|
||||
tail = head_query.next_union_all;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void InterpreterSelectQuery::basicInit(const BlockInputStreamPtr & input)
|
||||
{
|
||||
auto query_table = query.table();
|
||||
|
@ -96,6 +96,7 @@ private:
|
||||
void init(const BlockInputStreamPtr & input, const Names & required_column_names = Names{});
|
||||
void basicInit(const BlockInputStreamPtr & input);
|
||||
void initQueryAnalyzer();
|
||||
bool hasAggregation(ASTSelectQuery * query_ptr);
|
||||
|
||||
/// Execute one SELECT query from the UNION ALL chain.
|
||||
void executeSingleQuery();
|
||||
|
Loading…
Reference in New Issue
Block a user