mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
Interpret subquery with empty result as Null literal. [#CLICKHOUSE-2760]
This commit is contained in:
parent
67d8ce3568
commit
11b3aad985
@ -989,7 +989,11 @@ void ExpressionAnalyzer::executeScalarSubqueriesImpl(ASTPtr & ast)
|
||||
block = res.in->read();
|
||||
|
||||
if (!block)
|
||||
throw Exception("Scalar subquery returned empty result", ErrorCodes::INCORRECT_RESULT_OF_SCALAR_SUBQUERY);
|
||||
{
|
||||
/// Interpret subquery with empty result as Null literal
|
||||
ast = std::make_unique<ASTLiteral>(ast->range, Null());
|
||||
return;
|
||||
}
|
||||
|
||||
if (block.rows() != 1 || res.in->read())
|
||||
throw Exception("Scalar subquery returned more than one row", ErrorCodes::INCORRECT_RESULT_OF_SCALAR_SUBQUERY);
|
||||
|
@ -0,0 +1,5 @@
|
||||
\N
|
||||
\N
|
||||
\N
|
||||
\N
|
||||
\N
|
@ -0,0 +1,5 @@
|
||||
SELECT (SELECT 1 WHERE 0);
|
||||
SELECT (SELECT * FROM (SELECT * FROM system.numbers LIMIT 2) WHERE number = number + 1);
|
||||
SELECT (SELECT Null WHERE 1);
|
||||
SELECT (SELECT NULL WHERE 0);
|
||||
SELECT (SELECT Null WHERE nuLL IS NOT NULL);
|
Loading…
Reference in New Issue
Block a user