mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
Merge pull request #54067 from ClickHouse/vdimir/is_not_distinct_from_operator
Parse IS NOT DISTINCT and <=> operators
This commit is contained in:
commit
c08fc52812
@ -2336,12 +2336,14 @@ const std::vector<std::pair<std::string_view, Operator>> ParserExpressionImpl::o
|
||||
{":", Operator("if", 3, 3, OperatorType::FinishIf)},
|
||||
{"OR", Operator("or", 3, 2, OperatorType::Mergeable)},
|
||||
{"AND", Operator("and", 4, 2, OperatorType::Mergeable)},
|
||||
{"IS NOT DISTINCT FROM", Operator("isNotDistinctFrom", 6, 2)},
|
||||
{"IS NULL", Operator("isNull", 6, 1, OperatorType::IsNull)},
|
||||
{"IS NOT NULL", Operator("isNotNull", 6, 1, OperatorType::IsNull)},
|
||||
{"BETWEEN", Operator("", 7, 0, OperatorType::StartBetween)},
|
||||
{"NOT BETWEEN", Operator("", 7, 0, OperatorType::StartNotBetween)},
|
||||
{"==", Operator("equals", 9, 2, OperatorType::Comparison)},
|
||||
{"!=", Operator("notEquals", 9, 2, OperatorType::Comparison)},
|
||||
{"<=>", Operator("isNotDistinctFrom", 9, 2, OperatorType::Comparison)},
|
||||
{"<>", Operator("notEquals", 9, 2, OperatorType::Comparison)},
|
||||
{"<=", Operator("lessOrEquals", 9, 2, OperatorType::Comparison)},
|
||||
{">=", Operator("greaterOrEquals", 9, 2, OperatorType::Comparison)},
|
||||
|
@ -375,9 +375,14 @@ Token Lexer::nextTokenImpl()
|
||||
return Token(TokenType::NotEquals, token_begin, ++pos);
|
||||
return Token(TokenType::ErrorSingleExclamationMark, token_begin, pos);
|
||||
}
|
||||
case '<': /// <, <=, <>
|
||||
case '<': /// <, <=, <>, <=>
|
||||
{
|
||||
++pos;
|
||||
if (pos + 1 < end && *pos == '=' && *(pos + 1) == '>')
|
||||
{
|
||||
pos += 2;
|
||||
return Token(TokenType::Spaceship, token_begin, pos);
|
||||
}
|
||||
if (pos < end && *pos == '=')
|
||||
return Token(TokenType::LessOrEquals, token_begin, ++pos);
|
||||
if (pos < end && *pos == '>')
|
||||
|
@ -51,6 +51,7 @@ namespace DB
|
||||
M(Greater) \
|
||||
M(LessOrEquals) \
|
||||
M(GreaterOrEquals) \
|
||||
M(Spaceship) /** <=>. Used in MySQL for NULL-safe equality comparison. */ \
|
||||
M(PipeMark) \
|
||||
M(Concatenation) /** String concatenation operator: || */ \
|
||||
\
|
||||
|
@ -66,6 +66,7 @@ $1 " as " $2 ;
|
||||
"==";
|
||||
"!=";
|
||||
"<>";
|
||||
"<=>"
|
||||
"<";
|
||||
"<=";
|
||||
">";
|
||||
|
@ -42,6 +42,7 @@ const std::unordered_set<std::string_view> keywords
|
||||
"<>",
|
||||
"=",
|
||||
"==",
|
||||
"<=>",
|
||||
">",
|
||||
">=",
|
||||
"?",
|
||||
|
@ -0,0 +1,116 @@
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal Bool_0
|
||||
Function in (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal Bool_1
|
||||
Literal Tuple_(Bool_1, Bool_0)
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal UInt64_1
|
||||
Function plus (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal UInt64_1
|
||||
Literal UInt64_1
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal Bool_1
|
||||
Function like (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal \'x\'
|
||||
Literal \'a\'
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal \'x\'
|
||||
Function concat (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal \'x\'
|
||||
Literal \'a\'
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal UInt64_1
|
||||
Function CAST (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal \'1\'
|
||||
Literal \'integer\'
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function not (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal UInt64_1
|
||||
Literal UInt64_1
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal Int64_-1
|
||||
Literal UInt64_1
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function or (children 1)
|
||||
ExpressionList (children 2)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal Bool_0
|
||||
Literal Bool_1
|
||||
Literal Bool_1
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Function isNull (children 1)
|
||||
ExpressionList (children 1)
|
||||
Literal NULL
|
||||
Literal NULL
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function equals (children 1)
|
||||
ExpressionList (children 2)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal UInt64_1
|
||||
Literal UInt64_1
|
||||
Literal UInt64_1
|
||||
SelectWithUnionQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
SelectQuery (children 1)
|
||||
ExpressionList (children 1)
|
||||
Function isNotDistinctFrom (children 1)
|
||||
ExpressionList (children 2)
|
||||
Function equals (children 1)
|
||||
ExpressionList (children 2)
|
||||
Literal UInt64_1
|
||||
Literal UInt64_1
|
||||
Literal UInt64_1
|
@ -0,0 +1,32 @@
|
||||
-- EXPLAIN AST SELECT false IS NOT DISTINCT FROM (true IN (true, false));
|
||||
EXPLAIN AST SELECT false IS NOT DISTINCT FROM true IN (true, false);
|
||||
|
||||
-- EXPLAIN AST SELECT 1 IS NOT DISTINCT FROM (1 + 1);
|
||||
EXPLAIN AST SELECT 1 IS NOT DISTINCT FROM 1 + 1;
|
||||
|
||||
-- EXPLAIN AST SELECT true IS NOT DISTINCT FROM ('x' LIKE 'a');
|
||||
EXPLAIN AST SELECT true IS NOT DISTINCT FROM 'x' LIKE 'a';
|
||||
|
||||
-- EXPLAIN AST SELECT 'x' IS NOT DISTINCT FROM ('x' || 'a');
|
||||
EXPLAIN AST SELECT 'x' IS NOT DISTINCT FROM 'x' || 'a';
|
||||
|
||||
-- EXPLAIN AST SELECT 1 IS NOT DISTINCT FROM (1 :: integer);
|
||||
EXPLAIN AST SELECT 1 IS NOT DISTINCT FROM 1 :: integer;
|
||||
|
||||
-- EXPLAIN AST SELECT NOT (1 IS NOT DISTINCT FROM 1);
|
||||
EXPLAIN AST SELECT NOT 1 IS NOT DISTINCT FROM 1;
|
||||
|
||||
-- EXPLAIN AST SELECT (- 1) IS NOT DISTINCT FROM 1 ;
|
||||
EXPLAIN AST SELECT - 1 IS NOT DISTINCT FROM 1 ;
|
||||
|
||||
-- EXPLAIN AST SELECT (false IS NOT DISTINCT FROM true) OR true;
|
||||
EXPLAIN AST SELECT false IS NOT DISTINCT FROM true OR true;
|
||||
|
||||
-- EXPLAIN AST SELECT (NULL IS NULL) IS NOT DISTINCT FROM NULL;
|
||||
EXPLAIN AST SELECT NULL IS NULL IS NOT DISTINCT FROM NULL;
|
||||
|
||||
-- EXPLAIN AST SELECT (1 <=> 1) == 1;
|
||||
EXPLAIN AST SELECT 1 <=> 1 == 1;
|
||||
|
||||
-- EXPLAIN AST SELECT (1 == 1) <=> 1;
|
||||
EXPLAIN AST SELECT 1 == 1 <=> 1;
|
Loading…
Reference in New Issue
Block a user