mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
Merge pull request #57713 from evillique/fix-unary-operators-parsing
Fix unary operators parsing
This commit is contained in:
commit
64cd83fcd9
@ -468,7 +468,8 @@ enum class OperatorType
|
||||
StartIf,
|
||||
FinishIf,
|
||||
Cast,
|
||||
Lambda
|
||||
Lambda,
|
||||
Not
|
||||
};
|
||||
|
||||
/** Operator struct stores parameters of the operator:
|
||||
@ -2420,7 +2421,7 @@ const std::vector<std::pair<std::string_view, Operator>> ParserExpressionImpl::o
|
||||
|
||||
const std::vector<std::pair<std::string_view, Operator>> ParserExpressionImpl::unary_operators_table
|
||||
{
|
||||
{"NOT", Operator("not", 5, 1)},
|
||||
{"NOT", Operator("not", 5, 1, OperatorType::Not)},
|
||||
{"-", Operator("negate", 13, 1)},
|
||||
{"−", Operator("negate", 13, 1)}
|
||||
};
|
||||
@ -2592,7 +2593,16 @@ Action ParserExpressionImpl::tryParseOperand(Layers & layers, IParser::Pos & pos
|
||||
|
||||
if (cur_op != unary_operators_table.end())
|
||||
{
|
||||
layers.back()->pushOperator(cur_op->second);
|
||||
if (cur_op->second.type == OperatorType::Not && pos->type == TokenType::OpeningRoundBracket)
|
||||
{
|
||||
++pos;
|
||||
auto identifier = std::make_shared<ASTIdentifier>(cur_op->second.function_name);
|
||||
layers.push_back(getFunctionLayer(identifier, layers.front()->is_table_function));
|
||||
}
|
||||
else
|
||||
{
|
||||
layers.back()->pushOperator(cur_op->second);
|
||||
}
|
||||
return Action::OPERAND;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1 @@
|
||||
2
|
@ -0,0 +1 @@
|
||||
SELECT NOT (0) + NOT (0);
|
Loading…
Reference in New Issue
Block a user