mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-21 15:12:02 +00:00
Better parser
This commit is contained in:
parent
0d2a2c332f
commit
4aff9a20c6
@ -81,6 +81,13 @@ bool ParserParenthesisExpression::parseImpl(Pos & pos, ASTPtr & node, Expected &
|
||||
if (!contents.parse(pos, contents_node, expected))
|
||||
return false;
|
||||
|
||||
bool is_elem = true;
|
||||
if (pos->type == TokenType::Comma)
|
||||
{
|
||||
is_elem = false;
|
||||
++pos;
|
||||
}
|
||||
|
||||
if (pos->type != TokenType::ClosingRoundBracket)
|
||||
return false;
|
||||
++pos;
|
||||
@ -94,7 +101,7 @@ bool ParserParenthesisExpression::parseImpl(Pos & pos, ASTPtr & node, Expected &
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expr_list.children.size() == 1)
|
||||
if (expr_list.children.size() == 1 && is_elem)
|
||||
{
|
||||
node = expr_list.children.front();
|
||||
}
|
||||
|
@ -275,8 +275,7 @@ class ParserWithOptionalAlias : public IParserBase
|
||||
{
|
||||
public:
|
||||
ParserWithOptionalAlias(ParserPtr && elem_parser_, bool allow_alias_without_as_keyword_)
|
||||
: elem_parser(std::move(elem_parser_)), allow_alias_without_as_keyword(allow_alias_without_as_keyword_)
|
||||
{}
|
||||
: elem_parser(std::move(elem_parser_)), allow_alias_without_as_keyword(allow_alias_without_as_keyword_) {}
|
||||
protected:
|
||||
ParserPtr elem_parser;
|
||||
bool allow_alias_without_as_keyword;
|
||||
|
@ -560,7 +560,7 @@ bool ParserOrderByExpressionList::parseImpl(Pos & pos, ASTPtr & node, Expected &
|
||||
bool ParserNullityChecking::parseImpl(Pos & pos, ASTPtr & node, Expected & expected)
|
||||
{
|
||||
ASTPtr node_comp;
|
||||
if (!ParserComparisonExpression{}.parse(pos, node_comp, expected))
|
||||
if (!elem_parser.parse(pos, node_comp, expected))
|
||||
return false;
|
||||
|
||||
ParserKeyword s_is{"IS"};
|
||||
|
@ -115,18 +115,6 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
class ParserTupleElementExpression : public IParserBase
|
||||
{
|
||||
private:
|
||||
static const char * operators[];
|
||||
|
||||
protected:
|
||||
const char * getName() const { return "tuple element expression"; }
|
||||
|
||||
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected);
|
||||
};
|
||||
|
||||
|
||||
class ParserArrayElementExpression : public IParserBase
|
||||
{
|
||||
private:
|
||||
@ -139,6 +127,18 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
class ParserTupleElementExpression : public IParserBase
|
||||
{
|
||||
private:
|
||||
static const char * operators[];
|
||||
|
||||
protected:
|
||||
const char * getName() const { return "tuple element expression"; }
|
||||
|
||||
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected);
|
||||
};
|
||||
|
||||
|
||||
class ParserUnaryMinusExpression : public IParserBase
|
||||
{
|
||||
private:
|
||||
@ -241,6 +241,9 @@ protected:
|
||||
*/
|
||||
class ParserNullityChecking : public IParserBase
|
||||
{
|
||||
private:
|
||||
ParserComparisonExpression elem_parser;
|
||||
|
||||
protected:
|
||||
const char * getName() const override { return "nullity checking"; }
|
||||
bool parseImpl(Pos & pos, ASTPtr & node, Expected & expected) override;
|
||||
|
@ -0,0 +1,2 @@
|
||||
Tuple(UInt8) (1)
|
||||
SELECT tuple(1)
|
5
dbms/tests/queries/0_stateless/01021_tuple_parser.sql
Normal file
5
dbms/tests/queries/0_stateless/01021_tuple_parser.sql
Normal file
@ -0,0 +1,5 @@
|
||||
SELECT toTypeName((1,)), (1,);
|
||||
|
||||
SET enable_debug_queries = 1;
|
||||
|
||||
ANALYZE SELECT (1,)
|
Loading…
Reference in New Issue
Block a user