Resolved #891. Fixed aliases for empty scalar subqueries. [#CLICKHOUSE-3]

This commit is contained in:
Vitaliy Lyudvichenko 2017-06-19 19:22:54 +03:00 committed by alexey-milovidov
parent 1cd217ba56
commit b772eaa3a8
3 changed files with 6 additions and 1 deletions

View File

@ -1146,7 +1146,9 @@ void ExpressionAnalyzer::executeScalarSubqueriesImpl(ASTPtr & ast)
if (!block) if (!block)
{ {
/// Interpret subquery with empty result as Null literal /// Interpret subquery with empty result as Null literal
ast = std::make_unique<ASTLiteral>(ast->range, Null()); auto ast_new = std::make_unique<ASTLiteral>(ast->range, Null());
ast_new->setAlias(ast->tryGetAlias());
ast = std::move(ast_new);
return; return;
} }

View File

@ -5,3 +5,5 @@
\N \N
\N \N
\N \N
a b
\N 1

View File

@ -5,3 +5,4 @@ SELECT (SELECT Null WHERE nuLL IS NOT NULL);
SELECT (SELECT Null WHERE 1); SELECT (SELECT Null WHERE 1);
SELECT CAST(NULL as Null); SELECT CAST(NULL as Null);
SELECT (SELECT CAST(NULL as Null) WHERE 0); SELECT (SELECT CAST(NULL as Null) WHERE 0);
SELECT (SELECT 1 WHERE 0) AS a, (SELECT 1 WHERE 1) AS b FORMAT TSVWithNames;