mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
fix subquery with limit
This commit is contained in:
parent
c9dd1aa58b
commit
3b40099578
@ -784,9 +784,22 @@ static bool hasWithTotalsInAnySubqueryInFromClause(const ASTSelectQuery & query)
|
||||
{
|
||||
if (const auto * ast_union = query_table->as<ASTSelectWithUnionQuery>())
|
||||
{
|
||||
///NOTE: Child of subquery can be ASTSelectWithUnionQuery or ASTSelectQuery,
|
||||
/// and after normalization, the height of the AST tree is at most 2
|
||||
for (const auto & elem : ast_union->list_of_selects->children)
|
||||
if (hasWithTotalsInAnySubqueryInFromClause(elem->as<ASTSelectQuery &>()))
|
||||
return true;
|
||||
{
|
||||
if (const auto * child_union = elem->as<ASTSelectWithUnionQuery>())
|
||||
{
|
||||
for (const auto & child_elem : child_union->list_of_selects->children)
|
||||
if (hasWithTotalsInAnySubqueryInFromClause(child_elem->as<ASTSelectQuery &>()))
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (hasWithTotalsInAnySubqueryInFromClause(elem->as<ASTSelectQuery &>()))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
@ -0,0 +1,8 @@
|
||||
SELECT x
|
||||
FROM
|
||||
(
|
||||
SELECT 1 AS x
|
||||
UNION DISTINCT
|
||||
SELECT 1
|
||||
)
|
||||
LIMIT 1;
|
Loading…
Reference in New Issue
Block a user