mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
CLICKHOUSE-3819 add CASE without ELSE
This commit is contained in:
parent
88f1346be4
commit
9e485dae1e
@ -50,12 +50,18 @@ bool ParserCase::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
if (!has_branch)
|
||||
return false;
|
||||
|
||||
if (!s_else.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
ASTPtr expr_else;
|
||||
if (!p_expr.parse(pos, expr_else, expected))
|
||||
return false;
|
||||
if (s_else.ignore(pos, expected))
|
||||
{
|
||||
if (!p_expr.parse(pos, expr_else, expected))
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Field field_with_null;
|
||||
ASTLiteral null_literal(field_with_null);
|
||||
expr_else = std::make_shared<ASTLiteral>(null_literal);
|
||||
}
|
||||
args.push_back(expr_else);
|
||||
|
||||
if (!s_end.ignore(pos, expected))
|
||||
|
@ -0,0 +1,4 @@
|
||||
0
|
||||
NULL
|
||||
0
|
||||
NULL
|
@ -0,0 +1,9 @@
|
||||
DROP TABLE IF EXISTS test.test;
|
||||
|
||||
CREATE TABLE test.test (a UInt8) ENGINE = Memory;
|
||||
|
||||
INSERT INTO test.test VALUES (1), (2), (1), (3);
|
||||
|
||||
SELECT CASE WHEN a=1 THEN 0 END FROM test.test;
|
||||
|
||||
DROP TABLE test.test;
|
Loading…
Reference in New Issue
Block a user