mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 07:31:57 +00:00
Implement antlr parser for projections (#24245)
* implement projection grammer for antlr parser * Add comment
This commit is contained in:
parent
c0ef021c6a
commit
9bbc9f97b4
@ -4,11 +4,14 @@
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
ASTPtr ASTProjectionDeclaration::clone() const
|
||||
{
|
||||
auto clone = std::make_shared<ASTProjectionDeclaration>(*this);
|
||||
clone->cloneChildren();
|
||||
return clone;
|
||||
auto res = std::make_shared<ASTProjectionDeclaration>();
|
||||
res->name = name;
|
||||
if (query)
|
||||
res->set(res->query, query->clone());
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ class ASTProjectionDeclaration : public IAST
|
||||
{
|
||||
public:
|
||||
String name;
|
||||
ASTPtr query;
|
||||
IAST * query;
|
||||
|
||||
/** Get the text that identifies this element. */
|
||||
String getID(char) const override { return "Projection"; }
|
||||
|
@ -37,7 +37,6 @@ ASTPtr ASTProjectionSelectQuery::clone() const
|
||||
*/
|
||||
CLONE(Expression::WITH);
|
||||
CLONE(Expression::SELECT);
|
||||
CLONE(Expression::WHERE);
|
||||
CLONE(Expression::GROUP_BY);
|
||||
CLONE(Expression::ORDER_BY);
|
||||
|
||||
@ -47,13 +46,6 @@ ASTPtr ASTProjectionSelectQuery::clone() const
|
||||
}
|
||||
|
||||
|
||||
void ASTProjectionSelectQuery::updateTreeHashImpl(SipHash & hash_state) const
|
||||
{
|
||||
hash_state.update(distinct);
|
||||
IAST::updateTreeHashImpl(hash_state);
|
||||
}
|
||||
|
||||
|
||||
void ASTProjectionSelectQuery::formatImpl(const FormatSettings & s, FormatState & state, FormatStateStacked frame) const
|
||||
{
|
||||
frame.current_select = this;
|
||||
@ -67,16 +59,10 @@ void ASTProjectionSelectQuery::formatImpl(const FormatSettings & s, FormatState
|
||||
s.ostr << s.nl_or_ws;
|
||||
}
|
||||
|
||||
s.ostr << (s.hilite ? hilite_keyword : "") << indent_str << "SELECT " << (distinct ? "DISTINCT " : "") << (s.hilite ? hilite_none : "");
|
||||
s.ostr << (s.hilite ? hilite_keyword : "") << indent_str << "SELECT " << (s.hilite ? hilite_none : "");
|
||||
|
||||
s.one_line ? select()->formatImpl(s, state, frame) : select()->as<ASTExpressionList &>().formatImplMultiline(s, state, frame);
|
||||
|
||||
if (where())
|
||||
{
|
||||
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "WHERE " << (s.hilite ? hilite_none : "");
|
||||
where()->formatImpl(s, state, frame);
|
||||
}
|
||||
|
||||
if (groupBy())
|
||||
{
|
||||
s.ostr << (s.hilite ? hilite_keyword : "") << s.nl_or_ws << indent_str << "GROUP BY " << (s.hilite ? hilite_none : "");
|
||||
@ -129,8 +115,6 @@ ASTPtr ASTProjectionSelectQuery::cloneToASTSelect() const
|
||||
select_query->setExpression(ASTSelectQuery::Expression::WITH, with()->clone());
|
||||
if (select())
|
||||
select_query->setExpression(ASTSelectQuery::Expression::SELECT, select()->clone());
|
||||
if (where())
|
||||
select_query->setExpression(ASTSelectQuery::Expression::WHERE, where()->clone());
|
||||
if (groupBy())
|
||||
select_query->setExpression(ASTSelectQuery::Expression::GROUP_BY, groupBy()->clone());
|
||||
// Get rid of orderBy. It's used for projection definition only
|
||||
|
@ -15,7 +15,6 @@ public:
|
||||
{
|
||||
WITH,
|
||||
SELECT,
|
||||
WHERE,
|
||||
GROUP_BY,
|
||||
ORDER_BY,
|
||||
};
|
||||
@ -25,14 +24,10 @@ public:
|
||||
|
||||
ASTPtr clone() const override;
|
||||
|
||||
bool distinct = false;
|
||||
|
||||
ASTPtr & refSelect() { return getExpression(Expression::SELECT); }
|
||||
ASTPtr & refWhere() { return getExpression(Expression::WHERE); }
|
||||
|
||||
const ASTPtr with() const { return getExpression(Expression::WITH); }
|
||||
const ASTPtr select() const { return getExpression(Expression::SELECT); }
|
||||
const ASTPtr where() const { return getExpression(Expression::WHERE); }
|
||||
const ASTPtr groupBy() const { return getExpression(Expression::GROUP_BY); }
|
||||
const ASTPtr orderBy() const { return getExpression(Expression::ORDER_BY); }
|
||||
|
||||
@ -47,8 +42,6 @@ public:
|
||||
return {};
|
||||
}
|
||||
|
||||
void updateTreeHashImpl(SipHash & hash_state) const override;
|
||||
|
||||
ASTPtr cloneToASTSelect() const;
|
||||
|
||||
protected:
|
||||
|
@ -91,6 +91,15 @@ PtrTo<AlterTableClause> AlterTableClause::createAddIndex(bool if_not_exists, Ptr
|
||||
return query;
|
||||
}
|
||||
|
||||
// static
|
||||
PtrTo<AlterTableClause> AlterTableClause::createAddProjection(bool if_not_exists, PtrTo<TableElementExpr> element, PtrTo<Identifier> after)
|
||||
{
|
||||
assert(element->getType() == TableElementExpr::ExprType::PROJECTION);
|
||||
PtrTo<AlterTableClause> query(new AlterTableClause(ClauseType::ADD_PROJECTION, {element, after}));
|
||||
query->if_not_exists = if_not_exists;
|
||||
return query;
|
||||
}
|
||||
|
||||
// static
|
||||
PtrTo<AlterTableClause> AlterTableClause::createAttach(PtrTo<PartitionClause> clause, PtrTo<TableIdentifier> from)
|
||||
{
|
||||
@ -98,9 +107,23 @@ PtrTo<AlterTableClause> AlterTableClause::createAttach(PtrTo<PartitionClause> cl
|
||||
}
|
||||
|
||||
// static
|
||||
PtrTo<AlterTableClause> AlterTableClause::createClear(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in)
|
||||
PtrTo<AlterTableClause> AlterTableClause::createClearColumn(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in)
|
||||
{
|
||||
PtrTo<AlterTableClause> query(new AlterTableClause(ClauseType::CLEAR, {identifier, in}));
|
||||
PtrTo<AlterTableClause> query(new AlterTableClause(ClauseType::CLEAR_COLUMN, {identifier, in}));
|
||||
query->if_exists = if_exists;
|
||||
return query;
|
||||
}
|
||||
|
||||
PtrTo<AlterTableClause> AlterTableClause::createClearIndex(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in)
|
||||
{
|
||||
PtrTo<AlterTableClause> query(new AlterTableClause(ClauseType::CLEAR_INDEX, {identifier, in}));
|
||||
query->if_exists = if_exists;
|
||||
return query;
|
||||
}
|
||||
|
||||
PtrTo<AlterTableClause> AlterTableClause::createClearProjection(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in)
|
||||
{
|
||||
PtrTo<AlterTableClause> query(new AlterTableClause(ClauseType::CLEAR_PROJECTION, {identifier, in}));
|
||||
query->if_exists = if_exists;
|
||||
return query;
|
||||
}
|
||||
@ -149,6 +172,14 @@ PtrTo<AlterTableClause> AlterTableClause::createDropIndex(bool if_exists, PtrTo<
|
||||
return query;
|
||||
}
|
||||
|
||||
// static
|
||||
PtrTo<AlterTableClause> AlterTableClause::createDropProjection(bool if_exists, PtrTo<Identifier> identifier)
|
||||
{
|
||||
PtrTo<AlterTableClause> query(new AlterTableClause(ClauseType::DROP_PROJECTION, {identifier}));
|
||||
query->if_exists = if_exists;
|
||||
return query;
|
||||
}
|
||||
|
||||
// static
|
||||
PtrTo<AlterTableClause> AlterTableClause::createDropPartition(PtrTo<PartitionClause> clause)
|
||||
{
|
||||
@ -161,6 +192,22 @@ PtrTo<AlterTableClause> AlterTableClause::createFreezePartition(PtrTo<PartitionC
|
||||
return PtrTo<AlterTableClause>(new AlterTableClause(ClauseType::FREEZE_PARTITION, {clause}));
|
||||
}
|
||||
|
||||
// static
|
||||
PtrTo<AlterTableClause> AlterTableClause::createMaterializeIndex(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in)
|
||||
{
|
||||
PtrTo<AlterTableClause> query(new AlterTableClause(ClauseType::MATERIALIZE_INDEX, {identifier, in}));
|
||||
query->if_exists = if_exists;
|
||||
return query;
|
||||
}
|
||||
|
||||
// static
|
||||
PtrTo<AlterTableClause> AlterTableClause::createMaterializeProjection(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in)
|
||||
{
|
||||
PtrTo<AlterTableClause> query(new AlterTableClause(ClauseType::MATERIALIZE_PROJECTION, {identifier, in}));
|
||||
query->if_exists = if_exists;
|
||||
return query;
|
||||
}
|
||||
|
||||
// static
|
||||
PtrTo<AlterTableClause> AlterTableClause::createModify(bool if_exists, PtrTo<TableElementExpr> element)
|
||||
{
|
||||
@ -256,6 +303,13 @@ ASTPtr AlterTableClause::convertToOld() const
|
||||
if (has(AFTER)) command->index = get(AFTER)->convertToOld();
|
||||
break;
|
||||
|
||||
case ClauseType::ADD_PROJECTION:
|
||||
command->type = ASTAlterCommand::ADD_PROJECTION;
|
||||
command->if_not_exists = if_not_exists;
|
||||
command->projection_decl = get(ELEMENT)->convertToOld();
|
||||
if (has(AFTER)) command->projection = get(AFTER)->convertToOld();
|
||||
break;
|
||||
|
||||
case ClauseType::ATTACH:
|
||||
command->type = ASTAlterCommand::ATTACH_PARTITION;
|
||||
command->partition = get(PARTITION)->convertToOld();
|
||||
@ -271,12 +325,30 @@ ASTPtr AlterTableClause::convertToOld() const
|
||||
}
|
||||
break;
|
||||
|
||||
case ClauseType::CLEAR:
|
||||
case ClauseType::CLEAR_COLUMN:
|
||||
command->type = ASTAlterCommand::DROP_COLUMN;
|
||||
command->if_exists = if_exists;
|
||||
command->clear_column = true;
|
||||
command->detach = false;
|
||||
command->column = get(COLUMN)->convertToOld();
|
||||
command->column = get(ELEMENT)->convertToOld();
|
||||
if (has(IN)) command->partition = get(IN)->convertToOld();
|
||||
break;
|
||||
|
||||
case ClauseType::CLEAR_INDEX:
|
||||
command->type = ASTAlterCommand::DROP_INDEX;
|
||||
command->if_exists = if_exists;
|
||||
command->clear_index = true;
|
||||
command->detach = false;
|
||||
command->index = get(ELEMENT)->convertToOld();
|
||||
if (has(IN)) command->partition = get(IN)->convertToOld();
|
||||
break;
|
||||
|
||||
case ClauseType::CLEAR_PROJECTION:
|
||||
command->type = ASTAlterCommand::DROP_PROJECTION;
|
||||
command->if_exists = if_exists;
|
||||
command->clear_projection = true;
|
||||
command->detach = false;
|
||||
command->projection = get(ELEMENT)->convertToOld();
|
||||
if (has(IN)) command->partition = get(IN)->convertToOld();
|
||||
break;
|
||||
|
||||
@ -315,14 +387,21 @@ ASTPtr AlterTableClause::convertToOld() const
|
||||
command->type = ASTAlterCommand::DROP_COLUMN;
|
||||
command->if_exists = if_exists;
|
||||
command->detach = false;
|
||||
command->column = get(COLUMN)->convertToOld();
|
||||
command->column = get(ELEMENT)->convertToOld();
|
||||
break;
|
||||
|
||||
case ClauseType::DROP_INDEX:
|
||||
command->type = ASTAlterCommand::DROP_INDEX;
|
||||
command->if_exists = if_exists;
|
||||
command->detach = false;
|
||||
command->index = get(COLUMN)->convertToOld();
|
||||
command->index = get(ELEMENT)->convertToOld();
|
||||
break;
|
||||
|
||||
case ClauseType::DROP_PROJECTION:
|
||||
command->type = ASTAlterCommand::DROP_PROJECTION;
|
||||
command->if_exists = if_exists;
|
||||
command->detach = false;
|
||||
command->projection = get(ELEMENT)->convertToOld();
|
||||
break;
|
||||
|
||||
case ClauseType::DROP_PARTITION:
|
||||
@ -340,6 +419,20 @@ ASTPtr AlterTableClause::convertToOld() const
|
||||
command->type = ASTAlterCommand::FREEZE_ALL;
|
||||
break;
|
||||
|
||||
case ClauseType::MATERIALIZE_INDEX:
|
||||
command->type = ASTAlterCommand::MATERIALIZE_INDEX;
|
||||
command->if_exists = if_exists;
|
||||
command->index = get(ELEMENT)->convertToOld();
|
||||
if (has(IN)) command->partition = get(IN)->convertToOld();
|
||||
break;
|
||||
|
||||
case ClauseType::MATERIALIZE_PROJECTION:
|
||||
command->type = ASTAlterCommand::MATERIALIZE_PROJECTION;
|
||||
command->if_exists = if_exists;
|
||||
command->projection = get(ELEMENT)->convertToOld();
|
||||
if (has(IN)) command->partition = get(IN)->convertToOld();
|
||||
break;
|
||||
|
||||
case ClauseType::MODIFY:
|
||||
command->type = ASTAlterCommand::MODIFY_COLUMN;
|
||||
command->if_exists = if_exists;
|
||||
@ -511,16 +604,34 @@ antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseAddIndex(ClickHouseParser::
|
||||
return AlterTableClause::createAddIndex(!!ctx->IF(), visit(ctx->tableIndexDfnt()), after);
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseAddProjection(ClickHouseParser::AlterTableClauseAddProjectionContext * ctx)
|
||||
{
|
||||
auto after = ctx->AFTER() ? visit(ctx->nestedIdentifier()).as<PtrTo<Identifier>>() : nullptr;
|
||||
return AlterTableClause::createAddProjection(!!ctx->IF(), visit(ctx->tableProjectionDfnt()), after);
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseAttach(ClickHouseParser::AlterTableClauseAttachContext *ctx)
|
||||
{
|
||||
auto from = ctx->tableIdentifier() ? visit(ctx->tableIdentifier()).as<PtrTo<TableIdentifier>>() : nullptr;
|
||||
return AlterTableClause::createAttach(visit(ctx->partitionClause()), from);
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseClear(ClickHouseParser::AlterTableClauseClearContext * ctx)
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseClearColumn(ClickHouseParser::AlterTableClauseClearColumnContext * ctx)
|
||||
{
|
||||
auto partition = ctx->partitionClause() ? visit(ctx->partitionClause()).as<PtrTo<PartitionClause>>() : nullptr;
|
||||
return AlterTableClause::createClear(!!ctx->IF(), visit(ctx->nestedIdentifier()), partition);
|
||||
return AlterTableClause::createClearColumn(!!ctx->IF(), visit(ctx->nestedIdentifier()), partition);
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseClearIndex(ClickHouseParser::AlterTableClauseClearIndexContext * ctx)
|
||||
{
|
||||
auto partition = ctx->partitionClause() ? visit(ctx->partitionClause()).as<PtrTo<PartitionClause>>() : nullptr;
|
||||
return AlterTableClause::createClearIndex(!!ctx->IF(), visit(ctx->nestedIdentifier()), partition);
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseClearProjection(ClickHouseParser::AlterTableClauseClearProjectionContext * ctx)
|
||||
{
|
||||
auto partition = ctx->partitionClause() ? visit(ctx->partitionClause()).as<PtrTo<PartitionClause>>() : nullptr;
|
||||
return AlterTableClause::createClearProjection(!!ctx->IF(), visit(ctx->nestedIdentifier()), partition);
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseComment(ClickHouseParser::AlterTableClauseCommentContext * ctx)
|
||||
@ -548,6 +659,11 @@ antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseDropIndex(ClickHouseParser:
|
||||
return AlterTableClause::createDropIndex(!!ctx->IF(), visit(ctx->nestedIdentifier()));
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseDropProjection(ClickHouseParser::AlterTableClauseDropProjectionContext * ctx)
|
||||
{
|
||||
return AlterTableClause::createDropProjection(!!ctx->IF(), visit(ctx->nestedIdentifier()));
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseDropPartition(ClickHouseParser::AlterTableClauseDropPartitionContext *ctx)
|
||||
{
|
||||
return AlterTableClause::createDropPartition(visit(ctx->partitionClause()));
|
||||
@ -559,6 +675,18 @@ antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseFreezePartition(ClickHouseP
|
||||
return AlterTableClause::createFreezePartition(clause);
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseMaterializeIndex(ClickHouseParser::AlterTableClauseMaterializeIndexContext * ctx)
|
||||
{
|
||||
auto partition = ctx->partitionClause() ? visit(ctx->partitionClause()).as<PtrTo<PartitionClause>>() : nullptr;
|
||||
return AlterTableClause::createMaterializeIndex(!!ctx->IF(), visit(ctx->nestedIdentifier()), partition);
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseMaterializeProjection(ClickHouseParser::AlterTableClauseMaterializeProjectionContext * ctx)
|
||||
{
|
||||
auto partition = ctx->partitionClause() ? visit(ctx->partitionClause()).as<PtrTo<PartitionClause>>() : nullptr;
|
||||
return AlterTableClause::createMaterializeProjection(!!ctx->IF(), visit(ctx->nestedIdentifier()), partition);
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitAlterTableClauseModify(ClickHouseParser::AlterTableClauseModifyContext * ctx)
|
||||
{
|
||||
return AlterTableClause::createModify(!!ctx->IF(), visit(ctx->tableColumnDfnt()));
|
||||
|
@ -61,16 +61,22 @@ class AlterTableClause : public INode
|
||||
public:
|
||||
static PtrTo<AlterTableClause> createAddColumn(bool if_not_exists, PtrTo<TableElementExpr> element, PtrTo<Identifier> after);
|
||||
static PtrTo<AlterTableClause> createAddIndex(bool if_not_exists, PtrTo<TableElementExpr> element, PtrTo<Identifier> after);
|
||||
static PtrTo<AlterTableClause> createAddProjection(bool if_not_exists, PtrTo<TableElementExpr> element, PtrTo<Identifier> after);
|
||||
static PtrTo<AlterTableClause> createAttach(PtrTo<PartitionClause> clause, PtrTo<TableIdentifier> from);
|
||||
static PtrTo<AlterTableClause> createClear(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in);
|
||||
static PtrTo<AlterTableClause> createClearColumn(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in);
|
||||
static PtrTo<AlterTableClause> createClearIndex(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in);
|
||||
static PtrTo<AlterTableClause> createClearProjection(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in);
|
||||
static PtrTo<AlterTableClause> createCodec(bool if_exists, PtrTo<Identifier> identifier, PtrTo<CodecExpr> codec);
|
||||
static PtrTo<AlterTableClause> createComment(bool if_exists, PtrTo<Identifier> identifier, PtrTo<StringLiteral> comment);
|
||||
static PtrTo<AlterTableClause> createDelete(PtrTo<ColumnExpr> expr);
|
||||
static PtrTo<AlterTableClause> createDetach(PtrTo<PartitionClause> clause);
|
||||
static PtrTo<AlterTableClause> createDropColumn(bool if_exists, PtrTo<Identifier> identifier);
|
||||
static PtrTo<AlterTableClause> createDropIndex(bool if_exists, PtrTo<Identifier> identifier);
|
||||
static PtrTo<AlterTableClause> createDropProjection(bool if_exists, PtrTo<Identifier> identifier);
|
||||
static PtrTo<AlterTableClause> createDropPartition(PtrTo<PartitionClause> clause);
|
||||
static PtrTo<AlterTableClause> createFreezePartition(PtrTo<PartitionClause> clause);
|
||||
static PtrTo<AlterTableClause> createMaterializeIndex(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in);
|
||||
static PtrTo<AlterTableClause> createMaterializeProjection(bool if_exists, PtrTo<Identifier> identifier, PtrTo<PartitionClause> in);
|
||||
static PtrTo<AlterTableClause> createModify(bool if_exists, PtrTo<TableElementExpr> element);
|
||||
static PtrTo<AlterTableClause> createMovePartitionToDisk(PtrTo<PartitionClause> clause, PtrTo<StringLiteral> literal);
|
||||
static PtrTo<AlterTableClause> createMovePartitionToTable(PtrTo<PartitionClause> clause, PtrTo<TableIdentifier> identifier);
|
||||
@ -88,19 +94,19 @@ class AlterTableClause : public INode
|
||||
private:
|
||||
enum ChildIndex : UInt8
|
||||
{
|
||||
// ADD COLUMN or INDEX
|
||||
ELEMENT = 0, // TableElementExpr
|
||||
// ADD COLUMN, INDEX or PROJECTION
|
||||
ELEMENT = 0, // TableElementExpr (COLUMN, CONSTRAINT, INDEX, PROJECTION)
|
||||
AFTER = 1, // Identifier (optional)
|
||||
|
||||
// ATTACH/REPLACE
|
||||
PARTITION = 0, // PartitionClause
|
||||
FROM = 1, // TableIdentifier (optional)
|
||||
|
||||
// CLEAR
|
||||
COLUMN = 0, // Identifier
|
||||
// CLEAR COLUMN, INDEX or PROJECTION
|
||||
IN = 1, // PartitionClause
|
||||
|
||||
// CODEC
|
||||
// CODEC, COMMENT and RENAME
|
||||
COLUMN = 0, // Identifier
|
||||
CODEC = 1, // CodecExpr
|
||||
|
||||
// COMMENT
|
||||
@ -127,16 +133,22 @@ class AlterTableClause : public INode
|
||||
{
|
||||
ADD_COLUMN,
|
||||
ADD_INDEX,
|
||||
ADD_PROJECTION,
|
||||
ATTACH,
|
||||
CLEAR,
|
||||
CLEAR_COLUMN,
|
||||
CLEAR_INDEX,
|
||||
CLEAR_PROJECTION,
|
||||
CODEC,
|
||||
COMMENT,
|
||||
DELETE,
|
||||
DETACH,
|
||||
DROP_COLUMN,
|
||||
DROP_INDEX,
|
||||
DROP_PROJECTION,
|
||||
DROP_PARTITION,
|
||||
FREEZE_PARTITION,
|
||||
MATERIALIZE_INDEX,
|
||||
MATERIALIZE_PROJECTION,
|
||||
MODIFY,
|
||||
MOVE_PARTITION_TO_DISK,
|
||||
MOVE_PARTITION_TO_TABLE,
|
||||
|
@ -48,6 +48,7 @@ ASTPtr TableSchemaClause::convertToOld() const
|
||||
auto column_list = std::make_shared<ASTExpressionList>();
|
||||
auto constraint_list = std::make_shared<ASTExpressionList>();
|
||||
auto index_list = std::make_shared<ASTExpressionList>();
|
||||
auto projection_list = std::make_shared<ASTExpressionList>();
|
||||
|
||||
for (const auto & element : get(ELEMENTS)->as<TableElementList &>())
|
||||
{
|
||||
@ -62,12 +63,16 @@ ASTPtr TableSchemaClause::convertToOld() const
|
||||
case TableElementExpr::ExprType::INDEX:
|
||||
index_list->children.push_back(element->convertToOld());
|
||||
break;
|
||||
case TableElementExpr::ExprType::PROJECTION:
|
||||
projection_list->children.push_back(element->convertToOld());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!column_list->children.empty()) columns->set(columns->columns, column_list);
|
||||
if (!constraint_list->children.empty()) columns->set(columns->constraints, constraint_list);
|
||||
if (!index_list->children.empty()) columns->set(columns->indices, index_list);
|
||||
if (!projection_list->children.empty()) columns->set(columns->projections, projection_list);
|
||||
|
||||
return columns;
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
#include <Parsers/New/AST/SelectUnionQuery.h>
|
||||
|
||||
#include <Parsers/ASTExpressionList.h>
|
||||
#include <Parsers/ASTFunction.h>
|
||||
#include <Parsers/ASTLiteral.h>
|
||||
#include <Parsers/ASTProjectionSelectQuery.h>
|
||||
#include <Parsers/ASTSelectQuery.h>
|
||||
#include <Parsers/ASTSelectWithUnionQuery.h>
|
||||
#include <Parsers/ASTSetQuery.h>
|
||||
@ -102,6 +104,59 @@ ASTPtr SettingsClause::convertToOld() const
|
||||
return expr;
|
||||
}
|
||||
|
||||
// PROJECTION SELECT Caluse
|
||||
|
||||
ProjectionSelectStmt::ProjectionSelectStmt(PtrTo<ColumnExprList> expr_list)
|
||||
: INode(MAX_INDEX)
|
||||
{
|
||||
set(COLUMNS, expr_list);
|
||||
}
|
||||
|
||||
void ProjectionSelectStmt::setWithClause(PtrTo<WithClause> clause)
|
||||
{
|
||||
set(WITH, clause);
|
||||
}
|
||||
|
||||
void ProjectionSelectStmt::setGroupByClause(PtrTo<GroupByClause> clause)
|
||||
{
|
||||
set(GROUP_BY, clause);
|
||||
}
|
||||
|
||||
void ProjectionSelectStmt::setOrderByClause(PtrTo<ProjectionOrderByClause> clause)
|
||||
{
|
||||
set(ORDER_BY, clause);
|
||||
}
|
||||
|
||||
ASTPtr ProjectionSelectStmt::convertToOld() const
|
||||
{
|
||||
auto old_select = std::make_shared<ASTProjectionSelectQuery>();
|
||||
|
||||
old_select->setExpression(ASTProjectionSelectQuery::Expression::SELECT, get(COLUMNS)->convertToOld());
|
||||
|
||||
if (has(WITH)) old_select->setExpression(ASTProjectionSelectQuery::Expression::WITH, get(WITH)->convertToOld());
|
||||
if (has(GROUP_BY)) old_select->setExpression(ASTProjectionSelectQuery::Expression::GROUP_BY, get(GROUP_BY)->convertToOld());
|
||||
if (has(ORDER_BY))
|
||||
{
|
||||
ASTPtr order_expression;
|
||||
auto expr_list = get(ORDER_BY)->convertToOld();
|
||||
if (expr_list->children.size() == 1)
|
||||
{
|
||||
order_expression = expr_list->children.front();
|
||||
}
|
||||
else
|
||||
{
|
||||
auto function_node = std::make_shared<ASTFunction>();
|
||||
function_node->name = "tuple";
|
||||
function_node->arguments = expr_list;
|
||||
function_node->children.push_back(expr_list);
|
||||
order_expression = function_node;
|
||||
}
|
||||
old_select->setExpression(ASTProjectionSelectQuery::Expression::ORDER_BY, std::move(order_expression));
|
||||
}
|
||||
|
||||
return old_select;
|
||||
}
|
||||
|
||||
// SELECT Statement
|
||||
|
||||
SelectStmt::SelectStmt(bool distinct_, ModifierType type, bool totals, PtrTo<ColumnExprList> expr_list)
|
||||
@ -302,6 +357,11 @@ antlrcpp::Any ParseTreeVisitor::visitOrderByClause(ClickHouseParser::OrderByClau
|
||||
return std::make_shared<OrderByClause>(visit(ctx->orderExprList()).as<PtrTo<OrderExprList>>());
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitProjectionOrderByClause(ClickHouseParser::ProjectionOrderByClauseContext *ctx)
|
||||
{
|
||||
return std::make_shared<ProjectionOrderByClause>(visit(ctx->columnExprList()).as<PtrTo<ColumnExprList>>());
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitLimitByClause(ClickHouseParser::LimitByClauseContext *ctx)
|
||||
{
|
||||
return std::make_shared<LimitByClause>(visit(ctx->limitExpr()), visit(ctx->columnExprList()));
|
||||
@ -317,6 +377,18 @@ antlrcpp::Any ParseTreeVisitor::visitSettingsClause(ClickHouseParser::SettingsCl
|
||||
return std::make_shared<SettingsClause>(visit(ctx->settingExprList()).as<PtrTo<SettingExprList>>());
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitProjectionSelectStmt(ClickHouseParser::ProjectionSelectStmtContext *ctx)
|
||||
{
|
||||
PtrTo<ColumnExprList> column_list = visit(ctx->columnExprList());
|
||||
auto select_stmt = std::make_shared<ProjectionSelectStmt>(column_list);
|
||||
|
||||
if (ctx->withClause()) select_stmt->setWithClause(visit(ctx->withClause()));
|
||||
if (ctx->groupByClause()) select_stmt->setGroupByClause(visit(ctx->groupByClause()));
|
||||
if (ctx->projectionOrderByClause()) select_stmt->setOrderByClause(visit(ctx->projectionOrderByClause()));
|
||||
|
||||
return select_stmt;
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitSelectStmt(ClickHouseParser::SelectStmtContext *ctx)
|
||||
{
|
||||
SelectStmt::ModifierType type = SelectStmt::ModifierType::NONE;
|
||||
|
@ -97,6 +97,29 @@ class SettingsClause : public INode
|
||||
|
||||
// Statement
|
||||
|
||||
class ProjectionSelectStmt : public INode
|
||||
{
|
||||
public:
|
||||
ProjectionSelectStmt(PtrTo<ColumnExprList> expr_list);
|
||||
|
||||
void setWithClause(PtrTo<WithClause> clause);
|
||||
void setGroupByClause(PtrTo<GroupByClause> clause);
|
||||
void setOrderByClause(PtrTo<ProjectionOrderByClause> clause);
|
||||
|
||||
ASTPtr convertToOld() const override;
|
||||
|
||||
private:
|
||||
enum ChildIndex : UInt8
|
||||
{
|
||||
COLUMNS = 0, // ColumnExprList
|
||||
WITH, // WithClause (optional)
|
||||
GROUP_BY, // GroupByClause (optional)
|
||||
ORDER_BY, // OrderByClause (optional)
|
||||
|
||||
MAX_INDEX,
|
||||
};
|
||||
};
|
||||
|
||||
class SelectStmt : public INode
|
||||
{
|
||||
public:
|
||||
|
@ -4,10 +4,12 @@
|
||||
#include <Parsers/ASTConstraintDeclaration.h>
|
||||
#include <Parsers/ASTFunction.h>
|
||||
#include <Parsers/ASTIndexDeclaration.h>
|
||||
#include <Parsers/ASTProjectionDeclaration.h>
|
||||
#include <Parsers/New/AST/ColumnExpr.h>
|
||||
#include <Parsers/New/AST/ColumnTypeExpr.h>
|
||||
#include <Parsers/New/AST/Identifier.h>
|
||||
#include <Parsers/New/AST/Literal.h>
|
||||
#include <Parsers/New/AST/SelectUnionQuery.h>
|
||||
#include <Parsers/New/ParseTreeVisitor.h>
|
||||
|
||||
|
||||
@ -81,6 +83,13 @@ TableElementExpr::createIndex(PtrTo<Identifier> name, PtrTo<ColumnExpr> expr, Pt
|
||||
return PtrTo<TableElementExpr>(new TableElementExpr(ExprType::INDEX, {name, expr, type, granularity}));
|
||||
}
|
||||
|
||||
// static
|
||||
PtrTo<TableElementExpr>
|
||||
TableElementExpr::createProjection(PtrTo<Identifier> name, PtrTo<ProjectionSelectStmt> query)
|
||||
{
|
||||
return PtrTo<TableElementExpr>(new TableElementExpr(ExprType::PROJECTION, {name, query}));
|
||||
}
|
||||
|
||||
TableElementExpr::TableElementExpr(ExprType type, PtrList exprs) : INode(exprs), expr_type(type)
|
||||
{
|
||||
}
|
||||
@ -152,6 +161,15 @@ ASTPtr TableElementExpr::convertToOld() const
|
||||
expr->set(expr->type, get(INDEX_TYPE)->convertToOld());
|
||||
expr->granularity = get<NumberLiteral>(GRANULARITY)->as<UInt64>().value_or(0); // FIXME: throw exception instead of default.
|
||||
|
||||
return expr;
|
||||
}
|
||||
case ExprType::PROJECTION:
|
||||
{
|
||||
auto expr = std::make_shared<ASTProjectionDeclaration>();
|
||||
|
||||
expr->name = get<Identifier>(NAME)->getName();
|
||||
expr->set(expr->query, get(QUERY)->convertToOld());
|
||||
|
||||
return expr;
|
||||
}
|
||||
}
|
||||
@ -222,6 +240,11 @@ antlrcpp::Any ParseTreeVisitor::visitTableElementExprIndex(ClickHouseParser::Tab
|
||||
return visit(ctx->tableIndexDfnt());
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitTableElementExprProjection(ClickHouseParser::TableElementExprProjectionContext *ctx)
|
||||
{
|
||||
return visit(ctx->tableProjectionDfnt());
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitTableIndexDfnt(ClickHouseParser::TableIndexDfntContext *ctx)
|
||||
{
|
||||
return TableElementExpr::createIndex(
|
||||
@ -231,4 +254,11 @@ antlrcpp::Any ParseTreeVisitor::visitTableIndexDfnt(ClickHouseParser::TableIndex
|
||||
Literal::createNumber(ctx->DECIMAL_LITERAL()));
|
||||
}
|
||||
|
||||
antlrcpp::Any ParseTreeVisitor::visitTableProjectionDfnt(ClickHouseParser::TableProjectionDfntContext *ctx)
|
||||
{
|
||||
return TableElementExpr::createProjection(
|
||||
visit(ctx->nestedIdentifier()),
|
||||
visit(ctx->projectionSelectStmt()));
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -68,6 +68,7 @@ class TableElementExpr : public INode
|
||||
COLUMN,
|
||||
CONSTRAINT,
|
||||
INDEX,
|
||||
PROJECTION,
|
||||
};
|
||||
|
||||
static PtrTo<TableElementExpr> createColumn(
|
||||
@ -83,6 +84,9 @@ class TableElementExpr : public INode
|
||||
static PtrTo<TableElementExpr>
|
||||
createIndex(PtrTo<Identifier> name, PtrTo<ColumnExpr> expr, PtrTo<ColumnTypeExpr> type, PtrTo<NumberLiteral> granularity);
|
||||
|
||||
static PtrTo<TableElementExpr>
|
||||
createProjection(PtrTo<Identifier> name, PtrTo<ProjectionSelectStmt> query);
|
||||
|
||||
auto getType() const { return expr_type; }
|
||||
|
||||
ASTPtr convertToOld() const override;
|
||||
@ -106,6 +110,9 @@ class TableElementExpr : public INode
|
||||
EXPR = 1, // ColumnExpr
|
||||
INDEX_TYPE = 2, // ColumnTypeExpr
|
||||
GRANULARITY = 3, // NumberLiteral
|
||||
|
||||
// PROJECTION
|
||||
QUERY = 1, // ColumnExpr
|
||||
};
|
||||
|
||||
const ExprType expr_type;
|
||||
|
@ -47,6 +47,7 @@ class PartitionClause;
|
||||
class Query;
|
||||
class RatioExpr;
|
||||
class TableSchemaClause;
|
||||
class ProjectionSelectStmt;
|
||||
class SelectStmt;
|
||||
class SelectUnionQuery;
|
||||
class SettingExpr;
|
||||
@ -81,6 +82,7 @@ using TTLExprList = List<TTLExpr>;
|
||||
using ClusterClause = SimpleClause<StringLiteral>;
|
||||
using DestinationClause = SimpleClause<TableIdentifier>;
|
||||
using OrderByClause = SimpleClause<OrderExprList>;
|
||||
using ProjectionOrderByClause = SimpleClause<ColumnExprList>;
|
||||
using PrimaryKeyClause = SimpleClause<ColumnExpr>;
|
||||
using TTLClause = SimpleClause<TTLExprList>;
|
||||
using UUIDClause = SimpleClause<StringLiteral>;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -102,6 +102,7 @@ LIMIT: L I M I T;
|
||||
LIVE: L I V E;
|
||||
LOCAL: L O C A L;
|
||||
LOGS: L O G S;
|
||||
MATERIALIZE: M A T E R I A L I Z E;
|
||||
MATERIALIZED: M A T E R I A L I Z E D;
|
||||
MAX: M A X;
|
||||
MERGES: M E R G E S;
|
||||
@ -127,6 +128,7 @@ PARTITION: P A R T I T I O N;
|
||||
POPULATE: P O P U L A T E;
|
||||
PREWHERE: P R E W H E R E;
|
||||
PRIMARY: P R I M A R Y;
|
||||
PROJECTION: P R O J E C T I O N;
|
||||
QUARTER: Q U A R T E R;
|
||||
RANGE: R A N G E;
|
||||
RELOAD: R E L O A D;
|
||||
|
@ -13,51 +13,51 @@ namespace DB {
|
||||
class ClickHouseLexer : public antlr4::Lexer {
|
||||
public:
|
||||
enum {
|
||||
ADD = 1, AFTER = 2, ALIAS = 3, ALL = 4, ALTER = 5, AND = 6, ANTI = 7,
|
||||
ANY = 8, ARRAY = 9, AS = 10, ASCENDING = 11, ASOF = 12, ASYNC = 13,
|
||||
ATTACH = 14, BETWEEN = 15, BOTH = 16, BY = 17, CASE = 18, CAST = 19,
|
||||
CHECK = 20, CLEAR = 21, CLUSTER = 22, CODEC = 23, COLLATE = 24, COLUMN = 25,
|
||||
COMMENT = 26, CONSTRAINT = 27, CREATE = 28, CROSS = 29, CUBE = 30, DATABASE = 31,
|
||||
DATABASES = 32, DATE = 33, DAY = 34, DEDUPLICATE = 35, DEFAULT = 36,
|
||||
DELAY = 37, DELETE = 38, DESC = 39, DESCENDING = 40, DESCRIBE = 41,
|
||||
DETACH = 42, DICTIONARIES = 43, DICTIONARY = 44, DISK = 45, DISTINCT = 46,
|
||||
DISTRIBUTED = 47, DROP = 48, ELSE = 49, END = 50, ENGINE = 51, EVENTS = 52,
|
||||
EXISTS = 53, EXPLAIN = 54, EXPRESSION = 55, EXTRACT = 56, FETCHES = 57,
|
||||
FINAL = 58, FIRST = 59, FLUSH = 60, FOR = 61, FORMAT = 62, FREEZE = 63,
|
||||
FROM = 64, FULL = 65, FUNCTION = 66, GLOBAL = 67, GRANULARITY = 68,
|
||||
GROUP = 69, HAVING = 70, HIERARCHICAL = 71, HOUR = 72, ID = 73, IF = 74,
|
||||
ILIKE = 75, IN = 76, INDEX = 77, INF = 78, INJECTIVE = 79, INNER = 80,
|
||||
INSERT = 81, INTERVAL = 82, INTO = 83, IS = 84, IS_OBJECT_ID = 85, JOIN = 86,
|
||||
KEY = 87, KILL = 88, LAST = 89, LAYOUT = 90, LEADING = 91, LEFT = 92,
|
||||
LIFETIME = 93, LIKE = 94, LIMIT = 95, LIVE = 96, LOCAL = 97, LOGS = 98,
|
||||
MATERIALIZED = 99, MAX = 100, MERGES = 101, MIN = 102, MINUTE = 103,
|
||||
MODIFY = 104, MONTH = 105, MOVE = 106, MUTATION = 107, NAN_SQL = 108,
|
||||
NO = 109, NOT = 110, NULL_SQL = 111, NULLS = 112, OFFSET = 113, ON = 114,
|
||||
OPTIMIZE = 115, OR = 116, ORDER = 117, OUTER = 118, OUTFILE = 119, PARTITION = 120,
|
||||
POPULATE = 121, PREWHERE = 122, PRIMARY = 123, QUARTER = 124, RANGE = 125,
|
||||
RELOAD = 126, REMOVE = 127, RENAME = 128, REPLACE = 129, REPLICA = 130,
|
||||
REPLICATED = 131, RIGHT = 132, ROLLUP = 133, SAMPLE = 134, SECOND = 135,
|
||||
SELECT = 136, SEMI = 137, SENDS = 138, SET = 139, SETTINGS = 140, SHOW = 141,
|
||||
SOURCE = 142, START = 143, STOP = 144, SUBSTRING = 145, SYNC = 146,
|
||||
SYNTAX = 147, SYSTEM = 148, TABLE = 149, TABLES = 150, TEMPORARY = 151,
|
||||
TEST = 152, THEN = 153, TIES = 154, TIMEOUT = 155, TIMESTAMP = 156,
|
||||
TO = 157, TOP = 158, TOTALS = 159, TRAILING = 160, TRIM = 161, TRUNCATE = 162,
|
||||
TTL = 163, TYPE = 164, UNION = 165, UPDATE = 166, USE = 167, USING = 168,
|
||||
UUID = 169, VALUES = 170, VIEW = 171, VOLUME = 172, WATCH = 173, WEEK = 174,
|
||||
WHEN = 175, WHERE = 176, WITH = 177, YEAR = 178, JSON_FALSE = 179, JSON_TRUE = 180,
|
||||
IDENTIFIER = 181, FLOATING_LITERAL = 182, OCTAL_LITERAL = 183, DECIMAL_LITERAL = 184,
|
||||
HEXADECIMAL_LITERAL = 185, STRING_LITERAL = 186, ARROW = 187, ASTERISK = 188,
|
||||
BACKQUOTE = 189, BACKSLASH = 190, COLON = 191, COMMA = 192, CONCAT = 193,
|
||||
DASH = 194, DOT = 195, EQ_DOUBLE = 196, EQ_SINGLE = 197, GE = 198, GT = 199,
|
||||
LBRACE = 200, LBRACKET = 201, LE = 202, LPAREN = 203, LT = 204, NOT_EQ = 205,
|
||||
PERCENT = 206, PLUS = 207, QUERY = 208, QUOTE_DOUBLE = 209, QUOTE_SINGLE = 210,
|
||||
RBRACE = 211, RBRACKET = 212, RPAREN = 213, SEMICOLON = 214, SLASH = 215,
|
||||
UNDERSCORE = 216, MULTI_LINE_COMMENT = 217, SINGLE_LINE_COMMENT = 218,
|
||||
WHITESPACE = 219
|
||||
ADD = 1, AFTER = 2, ALIAS = 3, ALL = 4, ALTER = 5, AND = 6, ANTI = 7,
|
||||
ANY = 8, ARRAY = 9, AS = 10, ASCENDING = 11, ASOF = 12, ASYNC = 13,
|
||||
ATTACH = 14, BETWEEN = 15, BOTH = 16, BY = 17, CASE = 18, CAST = 19,
|
||||
CHECK = 20, CLEAR = 21, CLUSTER = 22, CODEC = 23, COLLATE = 24, COLUMN = 25,
|
||||
COMMENT = 26, CONSTRAINT = 27, CREATE = 28, CROSS = 29, CUBE = 30, DATABASE = 31,
|
||||
DATABASES = 32, DATE = 33, DAY = 34, DEDUPLICATE = 35, DEFAULT = 36,
|
||||
DELAY = 37, DELETE = 38, DESC = 39, DESCENDING = 40, DESCRIBE = 41,
|
||||
DETACH = 42, DICTIONARIES = 43, DICTIONARY = 44, DISK = 45, DISTINCT = 46,
|
||||
DISTRIBUTED = 47, DROP = 48, ELSE = 49, END = 50, ENGINE = 51, EVENTS = 52,
|
||||
EXISTS = 53, EXPLAIN = 54, EXPRESSION = 55, EXTRACT = 56, FETCHES = 57,
|
||||
FINAL = 58, FIRST = 59, FLUSH = 60, FOR = 61, FORMAT = 62, FREEZE = 63,
|
||||
FROM = 64, FULL = 65, FUNCTION = 66, GLOBAL = 67, GRANULARITY = 68,
|
||||
GROUP = 69, HAVING = 70, HIERARCHICAL = 71, HOUR = 72, ID = 73, IF = 74,
|
||||
ILIKE = 75, IN = 76, INDEX = 77, INF = 78, INJECTIVE = 79, INNER = 80,
|
||||
INSERT = 81, INTERVAL = 82, INTO = 83, IS = 84, IS_OBJECT_ID = 85, JOIN = 86,
|
||||
KEY = 87, KILL = 88, LAST = 89, LAYOUT = 90, LEADING = 91, LEFT = 92,
|
||||
LIFETIME = 93, LIKE = 94, LIMIT = 95, LIVE = 96, LOCAL = 97, LOGS = 98,
|
||||
MATERIALIZED = 99, MATERIALIZE = 100, MAX = 101, MERGES = 102, MIN = 103,
|
||||
MINUTE = 104, MODIFY = 105, MONTH = 106, MOVE = 107, MUTATION = 108,
|
||||
NAN_SQL = 109, NO = 110, NOT = 111, NULL_SQL = 112, NULLS = 113, OFFSET = 114,
|
||||
ON = 115, OPTIMIZE = 116, OR = 117, ORDER = 118, OUTER = 119, OUTFILE = 120,
|
||||
PARTITION = 121, POPULATE = 122, PREWHERE = 123, PRIMARY = 124, PROJECTION = 125,
|
||||
QUARTER = 126, RANGE = 127, RELOAD = 128, REMOVE = 129, RENAME = 130,
|
||||
REPLACE = 131, REPLICA = 132, REPLICATED = 133, RIGHT = 134, ROLLUP = 135,
|
||||
SAMPLE = 136, SECOND = 137, SELECT = 138, SEMI = 139, SENDS = 140, SET = 141,
|
||||
SETTINGS = 142, SHOW = 143, SOURCE = 144, START = 145, STOP = 146, SUBSTRING = 147,
|
||||
SYNC = 148, SYNTAX = 149, SYSTEM = 150, TABLE = 151, TABLES = 152, TEMPORARY = 153,
|
||||
TEST = 154, THEN = 155, TIES = 156, TIMEOUT = 157, TIMESTAMP = 158,
|
||||
TO = 159, TOP = 160, TOTALS = 161, TRAILING = 162, TRIM = 163, TRUNCATE = 164,
|
||||
TTL = 165, TYPE = 166, UNION = 167, UPDATE = 168, USE = 169, USING = 170,
|
||||
UUID = 171, VALUES = 172, VIEW = 173, VOLUME = 174, WATCH = 175, WEEK = 176,
|
||||
WHEN = 177, WHERE = 178, WITH = 179, YEAR = 180, JSON_FALSE = 181, JSON_TRUE = 182,
|
||||
IDENTIFIER = 183, FLOATING_LITERAL = 184, OCTAL_LITERAL = 185, DECIMAL_LITERAL = 186,
|
||||
HEXADECIMAL_LITERAL = 187, STRING_LITERAL = 188, ARROW = 189, ASTERISK = 190,
|
||||
BACKQUOTE = 191, BACKSLASH = 192, COLON = 193, COMMA = 194, CONCAT = 195,
|
||||
DASH = 196, DOT = 197, EQ_DOUBLE = 198, EQ_SINGLE = 199, GE = 200, GT = 201,
|
||||
LBRACE = 202, LBRACKET = 203, LE = 204, LPAREN = 205, LT = 206, NOT_EQ = 207,
|
||||
PERCENT = 208, PLUS = 209, QUERY = 210, QUOTE_DOUBLE = 211, QUOTE_SINGLE = 212,
|
||||
RBRACE = 213, RBRACKET = 214, RPAREN = 215, SEMICOLON = 216, SLASH = 217,
|
||||
UNDERSCORE = 218, MULTI_LINE_COMMENT = 219, SINGLE_LINE_COMMENT = 220,
|
||||
WHITESPACE = 221
|
||||
};
|
||||
|
||||
ClickHouseLexer(antlr4::CharStream *input);
|
||||
~ClickHouseLexer() override;
|
||||
~ClickHouseLexer();
|
||||
|
||||
virtual std::string getGrammarFileName() const override;
|
||||
virtual const std::vector<std::string>& getRuleNames() const override;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -35,31 +35,37 @@ alterStmt
|
||||
;
|
||||
|
||||
alterTableClause
|
||||
: ADD COLUMN (IF NOT EXISTS)? tableColumnDfnt (AFTER nestedIdentifier)? # AlterTableClauseAddColumn
|
||||
| ADD INDEX (IF NOT EXISTS)? tableIndexDfnt (AFTER nestedIdentifier)? # AlterTableClauseAddIndex
|
||||
| ATTACH partitionClause (FROM tableIdentifier)? # AlterTableClauseAttach
|
||||
| CLEAR COLUMN (IF EXISTS)? nestedIdentifier (IN partitionClause)? # AlterTableClauseClear
|
||||
| COMMENT COLUMN (IF EXISTS)? nestedIdentifier STRING_LITERAL # AlterTableClauseComment
|
||||
| DELETE WHERE columnExpr # AlterTableClauseDelete
|
||||
| DETACH partitionClause # AlterTableClauseDetach
|
||||
| DROP COLUMN (IF EXISTS)? nestedIdentifier # AlterTableClauseDropColumn
|
||||
| DROP INDEX (IF EXISTS)? nestedIdentifier # AlterTableClauseDropIndex
|
||||
| DROP partitionClause # AlterTableClauseDropPartition
|
||||
| FREEZE partitionClause? # AlterTableClauseFreezePartition
|
||||
| MODIFY COLUMN (IF EXISTS)? nestedIdentifier codecExpr # AlterTableClauseModifyCodec
|
||||
| MODIFY COLUMN (IF EXISTS)? nestedIdentifier COMMENT STRING_LITERAL # AlterTableClauseModifyComment
|
||||
| MODIFY COLUMN (IF EXISTS)? nestedIdentifier REMOVE tableColumnPropertyType # AlterTableClauseModifyRemove
|
||||
| MODIFY COLUMN (IF EXISTS)? tableColumnDfnt # AlterTableClauseModify
|
||||
| MODIFY ORDER BY columnExpr # AlterTableClauseModifyOrderBy
|
||||
| MODIFY ttlClause # AlterTableClauseModifyTTL
|
||||
: ADD COLUMN (IF NOT EXISTS)? tableColumnDfnt (AFTER nestedIdentifier)? # AlterTableClauseAddColumn
|
||||
| ADD INDEX (IF NOT EXISTS)? tableIndexDfnt (AFTER nestedIdentifier)? # AlterTableClauseAddIndex
|
||||
| ADD PROJECTION (IF NOT EXISTS)? tableProjectionDfnt (AFTER nestedIdentifier)? # AlterTableClauseAddProjection
|
||||
| ATTACH partitionClause (FROM tableIdentifier)? # AlterTableClauseAttach
|
||||
| CLEAR COLUMN (IF EXISTS)? nestedIdentifier (IN partitionClause)? # AlterTableClauseClearColumn
|
||||
| CLEAR INDEX (IF EXISTS)? nestedIdentifier (IN partitionClause)? # AlterTableClauseClearIndex
|
||||
| CLEAR PROJECTION (IF EXISTS)? nestedIdentifier (IN partitionClause)? # AlterTableClauseClearProjection
|
||||
| COMMENT COLUMN (IF EXISTS)? nestedIdentifier STRING_LITERAL # AlterTableClauseComment
|
||||
| DELETE WHERE columnExpr # AlterTableClauseDelete
|
||||
| DETACH partitionClause # AlterTableClauseDetach
|
||||
| DROP COLUMN (IF EXISTS)? nestedIdentifier # AlterTableClauseDropColumn
|
||||
| DROP INDEX (IF EXISTS)? nestedIdentifier # AlterTableClauseDropIndex
|
||||
| DROP PROJECTION (IF EXISTS)? nestedIdentifier # AlterTableClauseDropProjection
|
||||
| DROP partitionClause # AlterTableClauseDropPartition
|
||||
| FREEZE partitionClause? # AlterTableClauseFreezePartition
|
||||
| MATERIALIZE INDEX (IF EXISTS)? nestedIdentifier (IN partitionClause)? # AlterTableClauseMaterializeIndex
|
||||
| MATERIALIZE PROJECTION (IF EXISTS)? nestedIdentifier (IN partitionClause)? # AlterTableClauseMaterializeProjection
|
||||
| MODIFY COLUMN (IF EXISTS)? nestedIdentifier codecExpr # AlterTableClauseModifyCodec
|
||||
| MODIFY COLUMN (IF EXISTS)? nestedIdentifier COMMENT STRING_LITERAL # AlterTableClauseModifyComment
|
||||
| MODIFY COLUMN (IF EXISTS)? nestedIdentifier REMOVE tableColumnPropertyType # AlterTableClauseModifyRemove
|
||||
| MODIFY COLUMN (IF EXISTS)? tableColumnDfnt # AlterTableClauseModify
|
||||
| MODIFY ORDER BY columnExpr # AlterTableClauseModifyOrderBy
|
||||
| MODIFY ttlClause # AlterTableClauseModifyTTL
|
||||
| MOVE partitionClause ( TO DISK STRING_LITERAL
|
||||
| TO VOLUME STRING_LITERAL
|
||||
| TO TABLE tableIdentifier
|
||||
) # AlterTableClauseMovePartition
|
||||
| REMOVE TTL # AlterTableClauseRemoveTTL
|
||||
| RENAME COLUMN (IF EXISTS)? nestedIdentifier TO nestedIdentifier # AlterTableClauseRename
|
||||
| REPLACE partitionClause FROM tableIdentifier # AlterTableClauseReplace
|
||||
| UPDATE assignmentExprList whereClause # AlterTableClauseUpdate
|
||||
) # AlterTableClauseMovePartition
|
||||
| REMOVE TTL # AlterTableClauseRemoveTTL
|
||||
| RENAME COLUMN (IF EXISTS)? nestedIdentifier TO nestedIdentifier # AlterTableClauseRename
|
||||
| REPLACE partitionClause FROM tableIdentifier # AlterTableClauseReplace
|
||||
| UPDATE assignmentExprList whereClause # AlterTableClauseUpdate
|
||||
;
|
||||
|
||||
assignmentExprList: assignmentExpr (COMMA assignmentExpr)*;
|
||||
@ -154,6 +160,7 @@ tableElementExpr
|
||||
: tableColumnDfnt # TableElementExprColumn
|
||||
| CONSTRAINT identifier CHECK columnExpr # TableElementExprConstraint
|
||||
| INDEX tableIndexDfnt # TableElementExprIndex
|
||||
| PROJECTION tableProjectionDfnt # TableElementExprProjection
|
||||
;
|
||||
tableColumnDfnt
|
||||
: nestedIdentifier columnTypeExpr tableColumnPropertyExpr? (COMMENT STRING_LITERAL)? codecExpr? (TTL columnExpr)?
|
||||
@ -161,6 +168,7 @@ tableColumnDfnt
|
||||
;
|
||||
tableColumnPropertyExpr: (DEFAULT | MATERIALIZED | ALIAS) columnExpr;
|
||||
tableIndexDfnt: nestedIdentifier columnExpr TYPE columnTypeExpr GRANULARITY DECIMAL_LITERAL;
|
||||
tableProjectionDfnt: nestedIdentifier projectionSelectStmt;
|
||||
codecExpr: CODEC LPAREN codecArgExpr (COMMA codecArgExpr)* RPAREN;
|
||||
codecArgExpr: identifier (LPAREN columnExprList? RPAREN)?;
|
||||
ttlExpr: columnExpr (DELETE | TO DISK STRING_LITERAL | TO VOLUME STRING_LITERAL)?;
|
||||
@ -212,6 +220,17 @@ optimizeStmt: OPTIMIZE TABLE tableIdentifier clusterClause? partitionClause? FIN
|
||||
|
||||
renameStmt: RENAME TABLE tableIdentifier TO tableIdentifier (COMMA tableIdentifier TO tableIdentifier)* clusterClause?;
|
||||
|
||||
// PROJECTION SELECT statement
|
||||
|
||||
projectionSelectStmt:
|
||||
LPAREN
|
||||
withClause?
|
||||
SELECT columnExprList
|
||||
groupByClause?
|
||||
projectionOrderByClause?
|
||||
RPAREN
|
||||
;
|
||||
|
||||
// SELECT statement
|
||||
|
||||
selectUnionStmt: selectStmtWithParens (UNION ALL selectStmtWithParens)*;
|
||||
@ -240,6 +259,7 @@ whereClause: WHERE columnExpr;
|
||||
groupByClause: GROUP BY ((CUBE | ROLLUP) LPAREN columnExprList RPAREN | columnExprList);
|
||||
havingClause: HAVING columnExpr;
|
||||
orderByClause: ORDER BY orderExprList;
|
||||
projectionOrderByClause: ORDER BY columnExprList;
|
||||
limitByClause: LIMIT limitExpr BY columnExprList;
|
||||
limitClause: LIMIT limitExpr (WITH TIES)?;
|
||||
settingsClause: SETTINGS settingExprList;
|
||||
@ -436,7 +456,7 @@ keyword
|
||||
| DISTRIBUTED | DROP | ELSE | END | ENGINE | EVENTS | EXISTS | EXPLAIN | EXPRESSION | EXTRACT | FETCHES | FINAL | FIRST | FLUSH | FOR
|
||||
| FORMAT | FREEZE | FROM | FULL | FUNCTION | GLOBAL | GRANULARITY | GROUP | HAVING | HIERARCHICAL | ID | IF | ILIKE | IN | INDEX
|
||||
| INJECTIVE | INNER | INSERT | INTERVAL | INTO | IS | IS_OBJECT_ID | JOIN | JSON_FALSE | JSON_TRUE | KEY | KILL | LAST | LAYOUT
|
||||
| LEADING | LEFT | LIFETIME | LIKE | LIMIT | LIVE | LOCAL | LOGS | MATERIALIZED | MAX | MERGES | MIN | MODIFY | MOVE | MUTATION | NO
|
||||
| LEADING | LEFT | LIFETIME | LIKE | LIMIT | LIVE | LOCAL | LOGS | MATERIALIZE | MATERIALIZED | MAX | MERGES | MIN | MODIFY | MOVE | MUTATION | NO
|
||||
| NOT | NULLS | OFFSET | ON | OPTIMIZE | OR | ORDER | OUTER | OUTFILE | PARTITION | POPULATE | PREWHERE | PRIMARY | RANGE | RELOAD
|
||||
| REMOVE | RENAME | REPLACE | REPLICA | REPLICATED | RIGHT | ROLLUP | SAMPLE | SELECT | SEMI | SENDS | SET | SETTINGS | SHOW | SOURCE
|
||||
| START | STOP | SUBSTRING | SYNC | SYNTAX | SYSTEM | TABLE | TABLES | TEMPORARY | TEST | THEN | TIES | TIMEOUT | TIMESTAMP | TOTALS
|
||||
|
@ -30,30 +30,30 @@ public:
|
||||
INSERT = 81, INTERVAL = 82, INTO = 83, IS = 84, IS_OBJECT_ID = 85, JOIN = 86,
|
||||
KEY = 87, KILL = 88, LAST = 89, LAYOUT = 90, LEADING = 91, LEFT = 92,
|
||||
LIFETIME = 93, LIKE = 94, LIMIT = 95, LIVE = 96, LOCAL = 97, LOGS = 98,
|
||||
MATERIALIZED = 99, MAX = 100, MERGES = 101, MIN = 102, MINUTE = 103,
|
||||
MODIFY = 104, MONTH = 105, MOVE = 106, MUTATION = 107, NAN_SQL = 108,
|
||||
NO = 109, NOT = 110, NULL_SQL = 111, NULLS = 112, OFFSET = 113, ON = 114,
|
||||
OPTIMIZE = 115, OR = 116, ORDER = 117, OUTER = 118, OUTFILE = 119, PARTITION = 120,
|
||||
POPULATE = 121, PREWHERE = 122, PRIMARY = 123, QUARTER = 124, RANGE = 125,
|
||||
RELOAD = 126, REMOVE = 127, RENAME = 128, REPLACE = 129, REPLICA = 130,
|
||||
REPLICATED = 131, RIGHT = 132, ROLLUP = 133, SAMPLE = 134, SECOND = 135,
|
||||
SELECT = 136, SEMI = 137, SENDS = 138, SET = 139, SETTINGS = 140, SHOW = 141,
|
||||
SOURCE = 142, START = 143, STOP = 144, SUBSTRING = 145, SYNC = 146,
|
||||
SYNTAX = 147, SYSTEM = 148, TABLE = 149, TABLES = 150, TEMPORARY = 151,
|
||||
TEST = 152, THEN = 153, TIES = 154, TIMEOUT = 155, TIMESTAMP = 156,
|
||||
TO = 157, TOP = 158, TOTALS = 159, TRAILING = 160, TRIM = 161, TRUNCATE = 162,
|
||||
TTL = 163, TYPE = 164, UNION = 165, UPDATE = 166, USE = 167, USING = 168,
|
||||
UUID = 169, VALUES = 170, VIEW = 171, VOLUME = 172, WATCH = 173, WEEK = 174,
|
||||
WHEN = 175, WHERE = 176, WITH = 177, YEAR = 178, JSON_FALSE = 179, JSON_TRUE = 180,
|
||||
IDENTIFIER = 181, FLOATING_LITERAL = 182, OCTAL_LITERAL = 183, DECIMAL_LITERAL = 184,
|
||||
HEXADECIMAL_LITERAL = 185, STRING_LITERAL = 186, ARROW = 187, ASTERISK = 188,
|
||||
BACKQUOTE = 189, BACKSLASH = 190, COLON = 191, COMMA = 192, CONCAT = 193,
|
||||
DASH = 194, DOT = 195, EQ_DOUBLE = 196, EQ_SINGLE = 197, GE = 198, GT = 199,
|
||||
LBRACE = 200, LBRACKET = 201, LE = 202, LPAREN = 203, LT = 204, NOT_EQ = 205,
|
||||
PERCENT = 206, PLUS = 207, QUERY = 208, QUOTE_DOUBLE = 209, QUOTE_SINGLE = 210,
|
||||
RBRACE = 211, RBRACKET = 212, RPAREN = 213, SEMICOLON = 214, SLASH = 215,
|
||||
UNDERSCORE = 216, MULTI_LINE_COMMENT = 217, SINGLE_LINE_COMMENT = 218,
|
||||
WHITESPACE = 219
|
||||
MATERIALIZED = 99, MATERIALIZE = 100, MAX = 101, MERGES = 102, MIN = 103,
|
||||
MINUTE = 104, MODIFY = 105, MONTH = 106, MOVE = 107, MUTATION = 108,
|
||||
NAN_SQL = 109, NO = 110, NOT = 111, NULL_SQL = 112, NULLS = 113, OFFSET = 114,
|
||||
ON = 115, OPTIMIZE = 116, OR = 117, ORDER = 118, OUTER = 119, OUTFILE = 120,
|
||||
PARTITION = 121, POPULATE = 122, PREWHERE = 123, PRIMARY = 124, PROJECTION = 125,
|
||||
QUARTER = 126, RANGE = 127, RELOAD = 128, REMOVE = 129, RENAME = 130,
|
||||
REPLACE = 131, REPLICA = 132, REPLICATED = 133, RIGHT = 134, ROLLUP = 135,
|
||||
SAMPLE = 136, SECOND = 137, SELECT = 138, SEMI = 139, SENDS = 140, SET = 141,
|
||||
SETTINGS = 142, SHOW = 143, SOURCE = 144, START = 145, STOP = 146, SUBSTRING = 147,
|
||||
SYNC = 148, SYNTAX = 149, SYSTEM = 150, TABLE = 151, TABLES = 152, TEMPORARY = 153,
|
||||
TEST = 154, THEN = 155, TIES = 156, TIMEOUT = 157, TIMESTAMP = 158,
|
||||
TO = 159, TOP = 160, TOTALS = 161, TRAILING = 162, TRIM = 163, TRUNCATE = 164,
|
||||
TTL = 165, TYPE = 166, UNION = 167, UPDATE = 168, USE = 169, USING = 170,
|
||||
UUID = 171, VALUES = 172, VIEW = 173, VOLUME = 174, WATCH = 175, WEEK = 176,
|
||||
WHEN = 177, WHERE = 178, WITH = 179, YEAR = 180, JSON_FALSE = 181, JSON_TRUE = 182,
|
||||
IDENTIFIER = 183, FLOATING_LITERAL = 184, OCTAL_LITERAL = 185, DECIMAL_LITERAL = 186,
|
||||
HEXADECIMAL_LITERAL = 187, STRING_LITERAL = 188, ARROW = 189, ASTERISK = 190,
|
||||
BACKQUOTE = 191, BACKSLASH = 192, COLON = 193, COMMA = 194, CONCAT = 195,
|
||||
DASH = 196, DOT = 197, EQ_DOUBLE = 198, EQ_SINGLE = 199, GE = 200, GT = 201,
|
||||
LBRACE = 202, LBRACKET = 203, LE = 204, LPAREN = 205, LT = 206, NOT_EQ = 207,
|
||||
PERCENT = 208, PLUS = 209, QUERY = 210, QUOTE_DOUBLE = 211, QUOTE_SINGLE = 212,
|
||||
RBRACE = 213, RBRACKET = 214, RPAREN = 215, SEMICOLON = 216, SLASH = 217,
|
||||
UNDERSCORE = 218, MULTI_LINE_COMMENT = 219, SINGLE_LINE_COMMENT = 220,
|
||||
WHITESPACE = 221
|
||||
};
|
||||
|
||||
enum {
|
||||
@ -68,30 +68,31 @@ public:
|
||||
RuleEngineClause = 26, RulePartitionByClause = 27, RulePrimaryKeyClause = 28,
|
||||
RuleSampleByClause = 29, RuleTtlClause = 30, RuleEngineExpr = 31, RuleTableElementExpr = 32,
|
||||
RuleTableColumnDfnt = 33, RuleTableColumnPropertyExpr = 34, RuleTableIndexDfnt = 35,
|
||||
RuleCodecExpr = 36, RuleCodecArgExpr = 37, RuleTtlExpr = 38, RuleDescribeStmt = 39,
|
||||
RuleDropStmt = 40, RuleExistsStmt = 41, RuleExplainStmt = 42, RuleInsertStmt = 43,
|
||||
RuleColumnsClause = 44, RuleDataClause = 45, RuleKillStmt = 46, RuleOptimizeStmt = 47,
|
||||
RuleRenameStmt = 48, RuleSelectUnionStmt = 49, RuleSelectStmtWithParens = 50,
|
||||
RuleSelectStmt = 51, RuleWithClause = 52, RuleTopClause = 53, RuleFromClause = 54,
|
||||
RuleArrayJoinClause = 55, RulePrewhereClause = 56, RuleWhereClause = 57,
|
||||
RuleGroupByClause = 58, RuleHavingClause = 59, RuleOrderByClause = 60,
|
||||
RuleLimitByClause = 61, RuleLimitClause = 62, RuleSettingsClause = 63,
|
||||
RuleJoinExpr = 64, RuleJoinOp = 65, RuleJoinOpCross = 66, RuleJoinConstraintClause = 67,
|
||||
RuleSampleClause = 68, RuleLimitExpr = 69, RuleOrderExprList = 70, RuleOrderExpr = 71,
|
||||
RuleRatioExpr = 72, RuleSettingExprList = 73, RuleSettingExpr = 74,
|
||||
RuleSetStmt = 75, RuleShowStmt = 76, RuleSystemStmt = 77, RuleTruncateStmt = 78,
|
||||
RuleUseStmt = 79, RuleWatchStmt = 80, RuleColumnTypeExpr = 81, RuleColumnExprList = 82,
|
||||
RuleColumnsExpr = 83, RuleColumnExpr = 84, RuleColumnArgList = 85, RuleColumnArgExpr = 86,
|
||||
RuleColumnLambdaExpr = 87, RuleColumnIdentifier = 88, RuleNestedIdentifier = 89,
|
||||
RuleTableExpr = 90, RuleTableFunctionExpr = 91, RuleTableIdentifier = 92,
|
||||
RuleTableArgList = 93, RuleTableArgExpr = 94, RuleDatabaseIdentifier = 95,
|
||||
RuleFloatingLiteral = 96, RuleNumberLiteral = 97, RuleLiteral = 98,
|
||||
RuleInterval = 99, RuleKeyword = 100, RuleKeywordForAlias = 101, RuleAlias = 102,
|
||||
RuleIdentifier = 103, RuleIdentifierOrNull = 104, RuleEnumValue = 105
|
||||
RuleTableProjectionDfnt = 36, RuleCodecExpr = 37, RuleCodecArgExpr = 38,
|
||||
RuleTtlExpr = 39, RuleDescribeStmt = 40, RuleDropStmt = 41, RuleExistsStmt = 42,
|
||||
RuleExplainStmt = 43, RuleInsertStmt = 44, RuleColumnsClause = 45, RuleDataClause = 46,
|
||||
RuleKillStmt = 47, RuleOptimizeStmt = 48, RuleRenameStmt = 49, RuleProjectionSelectStmt = 50,
|
||||
RuleSelectUnionStmt = 51, RuleSelectStmtWithParens = 52, RuleSelectStmt = 53,
|
||||
RuleWithClause = 54, RuleTopClause = 55, RuleFromClause = 56, RuleArrayJoinClause = 57,
|
||||
RulePrewhereClause = 58, RuleWhereClause = 59, RuleGroupByClause = 60,
|
||||
RuleHavingClause = 61, RuleOrderByClause = 62, RuleProjectionOrderByClause = 63,
|
||||
RuleLimitByClause = 64, RuleLimitClause = 65, RuleSettingsClause = 66,
|
||||
RuleJoinExpr = 67, RuleJoinOp = 68, RuleJoinOpCross = 69, RuleJoinConstraintClause = 70,
|
||||
RuleSampleClause = 71, RuleLimitExpr = 72, RuleOrderExprList = 73, RuleOrderExpr = 74,
|
||||
RuleRatioExpr = 75, RuleSettingExprList = 76, RuleSettingExpr = 77,
|
||||
RuleSetStmt = 78, RuleShowStmt = 79, RuleSystemStmt = 80, RuleTruncateStmt = 81,
|
||||
RuleUseStmt = 82, RuleWatchStmt = 83, RuleColumnTypeExpr = 84, RuleColumnExprList = 85,
|
||||
RuleColumnsExpr = 86, RuleColumnExpr = 87, RuleColumnArgList = 88, RuleColumnArgExpr = 89,
|
||||
RuleColumnLambdaExpr = 90, RuleColumnIdentifier = 91, RuleNestedIdentifier = 92,
|
||||
RuleTableExpr = 93, RuleTableFunctionExpr = 94, RuleTableIdentifier = 95,
|
||||
RuleTableArgList = 96, RuleTableArgExpr = 97, RuleDatabaseIdentifier = 98,
|
||||
RuleFloatingLiteral = 99, RuleNumberLiteral = 100, RuleLiteral = 101,
|
||||
RuleInterval = 102, RuleKeyword = 103, RuleKeywordForAlias = 104, RuleAlias = 105,
|
||||
RuleIdentifier = 106, RuleIdentifierOrNull = 107, RuleEnumValue = 108
|
||||
};
|
||||
|
||||
ClickHouseParser(antlr4::TokenStream *input);
|
||||
~ClickHouseParser() override;
|
||||
~ClickHouseParser();
|
||||
|
||||
virtual std::string getGrammarFileName() const override;
|
||||
virtual const antlr4::atn::ATN& getATN() const override { return _atn; };
|
||||
@ -136,6 +137,7 @@ public:
|
||||
class TableColumnDfntContext;
|
||||
class TableColumnPropertyExprContext;
|
||||
class TableIndexDfntContext;
|
||||
class TableProjectionDfntContext;
|
||||
class CodecExprContext;
|
||||
class CodecArgExprContext;
|
||||
class TtlExprContext;
|
||||
@ -149,6 +151,7 @@ public:
|
||||
class KillStmtContext;
|
||||
class OptimizeStmtContext;
|
||||
class RenameStmtContext;
|
||||
class ProjectionSelectStmtContext;
|
||||
class SelectUnionStmtContext;
|
||||
class SelectStmtWithParensContext;
|
||||
class SelectStmtContext;
|
||||
@ -161,6 +164,7 @@ public:
|
||||
class GroupByClauseContext;
|
||||
class HavingClauseContext;
|
||||
class OrderByClauseContext;
|
||||
class ProjectionOrderByClauseContext;
|
||||
class LimitByClauseContext;
|
||||
class LimitClauseContext;
|
||||
class SettingsClauseContext;
|
||||
@ -313,44 +317,6 @@ public:
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseRenameContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseRenameContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *RENAME();
|
||||
antlr4::tree::TerminalNode *COLUMN();
|
||||
std::vector<NestedIdentifierContext *> nestedIdentifier();
|
||||
NestedIdentifierContext* nestedIdentifier(size_t i);
|
||||
antlr4::tree::TerminalNode *TO();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseFreezePartitionContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseFreezePartitionContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *FREEZE();
|
||||
PartitionClauseContext *partitionClause();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseModifyContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseModifyContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *MODIFY();
|
||||
antlr4::tree::TerminalNode *COLUMN();
|
||||
TableColumnDfntContext *tableColumnDfnt();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseModifyOrderByContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseModifyOrderByContext(AlterTableClauseContext *ctx);
|
||||
@ -363,16 +329,6 @@ public:
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseRemoveTTLContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseRemoveTTLContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *REMOVE();
|
||||
antlr4::tree::TerminalNode *TTL();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseUpdateContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseUpdateContext(AlterTableClauseContext *ctx);
|
||||
@ -384,6 +340,21 @@ public:
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseClearProjectionContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseClearProjectionContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *CLEAR();
|
||||
antlr4::tree::TerminalNode *PROJECTION();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
antlr4::tree::TerminalNode *IN();
|
||||
PartitionClauseContext *partitionClause();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseModifyRemoveContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseModifyRemoveContext(AlterTableClauseContext *ctx);
|
||||
@ -410,20 +381,6 @@ public:
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseModifyCodecContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseModifyCodecContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *MODIFY();
|
||||
antlr4::tree::TerminalNode *COLUMN();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
CodecExprContext *codecExpr();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseCommentContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseCommentContext(AlterTableClauseContext *ctx);
|
||||
@ -438,18 +395,6 @@ public:
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseAttachContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseAttachContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *ATTACH();
|
||||
PartitionClauseContext *partitionClause();
|
||||
antlr4::tree::TerminalNode *FROM();
|
||||
TableIdentifierContext *tableIdentifier();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseDropColumnContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseDropColumnContext(AlterTableClauseContext *ctx);
|
||||
@ -463,21 +408,6 @@ public:
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseClearContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseClearContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *CLEAR();
|
||||
antlr4::tree::TerminalNode *COLUMN();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
antlr4::tree::TerminalNode *IN();
|
||||
PartitionClauseContext *partitionClause();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseDetachContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseDetachContext(AlterTableClauseContext *ctx);
|
||||
@ -488,19 +418,6 @@ public:
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseDropIndexContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseDropIndexContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *DROP();
|
||||
antlr4::tree::TerminalNode *INDEX();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseAddIndexContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseAddIndexContext(AlterTableClauseContext *ctx);
|
||||
@ -527,6 +444,182 @@ public:
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseMaterializeIndexContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseMaterializeIndexContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *MATERIALIZE();
|
||||
antlr4::tree::TerminalNode *INDEX();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
antlr4::tree::TerminalNode *IN();
|
||||
PartitionClauseContext *partitionClause();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseMaterializeProjectionContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseMaterializeProjectionContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *MATERIALIZE();
|
||||
antlr4::tree::TerminalNode *PROJECTION();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
antlr4::tree::TerminalNode *IN();
|
||||
PartitionClauseContext *partitionClause();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseMovePartitionContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseMovePartitionContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *MOVE();
|
||||
PartitionClauseContext *partitionClause();
|
||||
antlr4::tree::TerminalNode *TO();
|
||||
antlr4::tree::TerminalNode *DISK();
|
||||
antlr4::tree::TerminalNode *STRING_LITERAL();
|
||||
antlr4::tree::TerminalNode *VOLUME();
|
||||
antlr4::tree::TerminalNode *TABLE();
|
||||
TableIdentifierContext *tableIdentifier();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseRenameContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseRenameContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *RENAME();
|
||||
antlr4::tree::TerminalNode *COLUMN();
|
||||
std::vector<NestedIdentifierContext *> nestedIdentifier();
|
||||
NestedIdentifierContext* nestedIdentifier(size_t i);
|
||||
antlr4::tree::TerminalNode *TO();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseFreezePartitionContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseFreezePartitionContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *FREEZE();
|
||||
PartitionClauseContext *partitionClause();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseClearColumnContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseClearColumnContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *CLEAR();
|
||||
antlr4::tree::TerminalNode *COLUMN();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
antlr4::tree::TerminalNode *IN();
|
||||
PartitionClauseContext *partitionClause();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseModifyContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseModifyContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *MODIFY();
|
||||
antlr4::tree::TerminalNode *COLUMN();
|
||||
TableColumnDfntContext *tableColumnDfnt();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseClearIndexContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseClearIndexContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *CLEAR();
|
||||
antlr4::tree::TerminalNode *INDEX();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
antlr4::tree::TerminalNode *IN();
|
||||
PartitionClauseContext *partitionClause();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseRemoveTTLContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseRemoveTTLContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *REMOVE();
|
||||
antlr4::tree::TerminalNode *TTL();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseModifyCodecContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseModifyCodecContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *MODIFY();
|
||||
antlr4::tree::TerminalNode *COLUMN();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
CodecExprContext *codecExpr();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseAttachContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseAttachContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *ATTACH();
|
||||
PartitionClauseContext *partitionClause();
|
||||
antlr4::tree::TerminalNode *FROM();
|
||||
TableIdentifierContext *tableIdentifier();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseDropProjectionContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseDropProjectionContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *DROP();
|
||||
antlr4::tree::TerminalNode *PROJECTION();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseDropIndexContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseDropIndexContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *DROP();
|
||||
antlr4::tree::TerminalNode *INDEX();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseModifyCommentContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseModifyCommentContext(AlterTableClauseContext *ctx);
|
||||
@ -552,18 +645,18 @@ public:
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class AlterTableClauseMovePartitionContext : public AlterTableClauseContext {
|
||||
class AlterTableClauseAddProjectionContext : public AlterTableClauseContext {
|
||||
public:
|
||||
AlterTableClauseMovePartitionContext(AlterTableClauseContext *ctx);
|
||||
AlterTableClauseAddProjectionContext(AlterTableClauseContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *MOVE();
|
||||
PartitionClauseContext *partitionClause();
|
||||
antlr4::tree::TerminalNode *TO();
|
||||
antlr4::tree::TerminalNode *DISK();
|
||||
antlr4::tree::TerminalNode *STRING_LITERAL();
|
||||
antlr4::tree::TerminalNode *VOLUME();
|
||||
antlr4::tree::TerminalNode *TABLE();
|
||||
TableIdentifierContext *tableIdentifier();
|
||||
antlr4::tree::TerminalNode *ADD();
|
||||
antlr4::tree::TerminalNode *PROJECTION();
|
||||
TableProjectionDfntContext *tableProjectionDfnt();
|
||||
antlr4::tree::TerminalNode *IF();
|
||||
antlr4::tree::TerminalNode *NOT();
|
||||
antlr4::tree::TerminalNode *EXISTS();
|
||||
antlr4::tree::TerminalNode *AFTER();
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
@ -1257,6 +1350,16 @@ public:
|
||||
|
||||
};
|
||||
|
||||
class TableElementExprProjectionContext : public TableElementExprContext {
|
||||
public:
|
||||
TableElementExprProjectionContext(TableElementExprContext *ctx);
|
||||
|
||||
antlr4::tree::TerminalNode *PROJECTION();
|
||||
TableProjectionDfntContext *tableProjectionDfnt();
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
};
|
||||
|
||||
class TableElementExprConstraintContext : public TableElementExprContext {
|
||||
public:
|
||||
TableElementExprConstraintContext(TableElementExprContext *ctx);
|
||||
@ -1344,6 +1447,20 @@ public:
|
||||
|
||||
TableIndexDfntContext* tableIndexDfnt();
|
||||
|
||||
class TableProjectionDfntContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
TableProjectionDfntContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
NestedIdentifierContext *nestedIdentifier();
|
||||
ProjectionSelectStmtContext *projectionSelectStmt();
|
||||
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
TableProjectionDfntContext* tableProjectionDfnt();
|
||||
|
||||
class CodecExprContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
CodecExprContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
@ -1671,6 +1788,25 @@ public:
|
||||
|
||||
RenameStmtContext* renameStmt();
|
||||
|
||||
class ProjectionSelectStmtContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
ProjectionSelectStmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *LPAREN();
|
||||
antlr4::tree::TerminalNode *SELECT();
|
||||
ColumnExprListContext *columnExprList();
|
||||
antlr4::tree::TerminalNode *RPAREN();
|
||||
WithClauseContext *withClause();
|
||||
GroupByClauseContext *groupByClause();
|
||||
ProjectionOrderByClauseContext *projectionOrderByClause();
|
||||
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
ProjectionSelectStmtContext* projectionSelectStmt();
|
||||
|
||||
class SelectUnionStmtContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
SelectUnionStmtContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
@ -1874,6 +2010,21 @@ public:
|
||||
|
||||
OrderByClauseContext* orderByClause();
|
||||
|
||||
class ProjectionOrderByClauseContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
ProjectionOrderByClauseContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
virtual size_t getRuleIndex() const override;
|
||||
antlr4::tree::TerminalNode *ORDER();
|
||||
antlr4::tree::TerminalNode *BY();
|
||||
ColumnExprListContext *columnExprList();
|
||||
|
||||
|
||||
virtual antlrcpp::Any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
|
||||
|
||||
};
|
||||
|
||||
ProjectionOrderByClauseContext* projectionOrderByClause();
|
||||
|
||||
class LimitByClauseContext : public antlr4::ParserRuleContext {
|
||||
public:
|
||||
LimitByClauseContext(antlr4::ParserRuleContext *parent, size_t invokingState);
|
||||
@ -3273,6 +3424,7 @@ public:
|
||||
antlr4::tree::TerminalNode *LIVE();
|
||||
antlr4::tree::TerminalNode *LOCAL();
|
||||
antlr4::tree::TerminalNode *LOGS();
|
||||
antlr4::tree::TerminalNode *MATERIALIZE();
|
||||
antlr4::tree::TerminalNode *MATERIALIZED();
|
||||
antlr4::tree::TerminalNode *MAX();
|
||||
antlr4::tree::TerminalNode *MERGES();
|
||||
|
@ -30,9 +30,15 @@ public:
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseAddIndex(ClickHouseParser::AlterTableClauseAddIndexContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseAddProjection(ClickHouseParser::AlterTableClauseAddProjectionContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseAttach(ClickHouseParser::AlterTableClauseAttachContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseClear(ClickHouseParser::AlterTableClauseClearContext *context) = 0;
|
||||
virtual antlrcpp::Any visitAlterTableClauseClearColumn(ClickHouseParser::AlterTableClauseClearColumnContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseClearIndex(ClickHouseParser::AlterTableClauseClearIndexContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseClearProjection(ClickHouseParser::AlterTableClauseClearProjectionContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseComment(ClickHouseParser::AlterTableClauseCommentContext *context) = 0;
|
||||
|
||||
@ -44,10 +50,16 @@ public:
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseDropIndex(ClickHouseParser::AlterTableClauseDropIndexContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseDropProjection(ClickHouseParser::AlterTableClauseDropProjectionContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseDropPartition(ClickHouseParser::AlterTableClauseDropPartitionContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseFreezePartition(ClickHouseParser::AlterTableClauseFreezePartitionContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseMaterializeIndex(ClickHouseParser::AlterTableClauseMaterializeIndexContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseMaterializeProjection(ClickHouseParser::AlterTableClauseMaterializeProjectionContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseModifyCodec(ClickHouseParser::AlterTableClauseModifyCodecContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitAlterTableClauseModifyComment(ClickHouseParser::AlterTableClauseModifyCommentContext *context) = 0;
|
||||
@ -146,12 +158,16 @@ public:
|
||||
|
||||
virtual antlrcpp::Any visitTableElementExprIndex(ClickHouseParser::TableElementExprIndexContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitTableElementExprProjection(ClickHouseParser::TableElementExprProjectionContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitTableColumnDfnt(ClickHouseParser::TableColumnDfntContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitTableColumnPropertyExpr(ClickHouseParser::TableColumnPropertyExprContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitTableIndexDfnt(ClickHouseParser::TableIndexDfntContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitTableProjectionDfnt(ClickHouseParser::TableProjectionDfntContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitCodecExpr(ClickHouseParser::CodecExprContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitCodecArgExpr(ClickHouseParser::CodecArgExprContext *context) = 0;
|
||||
@ -186,6 +202,8 @@ public:
|
||||
|
||||
virtual antlrcpp::Any visitRenameStmt(ClickHouseParser::RenameStmtContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitProjectionSelectStmt(ClickHouseParser::ProjectionSelectStmtContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitSelectUnionStmt(ClickHouseParser::SelectUnionStmtContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitSelectStmtWithParens(ClickHouseParser::SelectStmtWithParensContext *context) = 0;
|
||||
@ -210,6 +228,8 @@ public:
|
||||
|
||||
virtual antlrcpp::Any visitOrderByClause(ClickHouseParser::OrderByClauseContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitProjectionOrderByClause(ClickHouseParser::ProjectionOrderByClauseContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitLimitByClause(ClickHouseParser::LimitByClauseContext *context) = 0;
|
||||
|
||||
virtual antlrcpp::Any visitLimitClause(ClickHouseParser::LimitClauseContext *context) = 0;
|
||||
|
@ -19,15 +19,21 @@ public:
|
||||
// AlterTableQuery
|
||||
antlrcpp::Any visitAlterTableClauseAddColumn(ClickHouseParser::AlterTableClauseAddColumnContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseAddIndex(ClickHouseParser::AlterTableClauseAddIndexContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseAddProjection(ClickHouseParser::AlterTableClauseAddProjectionContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseAttach(ClickHouseParser::AlterTableClauseAttachContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseClear(ClickHouseParser::AlterTableClauseClearContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseClearColumn(ClickHouseParser::AlterTableClauseClearColumnContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseClearIndex(ClickHouseParser::AlterTableClauseClearIndexContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseClearProjection(ClickHouseParser::AlterTableClauseClearProjectionContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseComment(ClickHouseParser::AlterTableClauseCommentContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseDelete(ClickHouseParser::AlterTableClauseDeleteContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseDetach(ClickHouseParser::AlterTableClauseDetachContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseDropColumn(ClickHouseParser::AlterTableClauseDropColumnContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseDropIndex(ClickHouseParser::AlterTableClauseDropIndexContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseDropProjection(ClickHouseParser::AlterTableClauseDropProjectionContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseDropPartition(ClickHouseParser::AlterTableClauseDropPartitionContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseFreezePartition(ClickHouseParser::AlterTableClauseFreezePartitionContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseMaterializeIndex(ClickHouseParser::AlterTableClauseMaterializeIndexContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseMaterializeProjection(ClickHouseParser::AlterTableClauseMaterializeProjectionContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseModify(ClickHouseParser::AlterTableClauseModifyContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseModifyCodec(ClickHouseParser::AlterTableClauseModifyCodecContext * ctx) override;
|
||||
antlrcpp::Any visitAlterTableClauseModifyComment(ClickHouseParser::AlterTableClauseModifyCommentContext * ctx) override;
|
||||
@ -162,6 +168,7 @@ public:
|
||||
antlrcpp::Any visitRenameStmt(ClickHouseParser::RenameStmtContext * ctx) override;
|
||||
|
||||
// SelectUnionQuery
|
||||
antlrcpp::Any visitProjectionSelectStmt(ClickHouseParser::ProjectionSelectStmtContext * ctx) override;
|
||||
antlrcpp::Any visitSelectStmt(ClickHouseParser::SelectStmtContext * ctx) override;
|
||||
antlrcpp::Any visitSelectStmtWithParens(ClickHouseParser::SelectStmtWithParensContext * ctx) override;
|
||||
antlrcpp::Any visitSelectUnionStmt(ClickHouseParser::SelectUnionStmtContext * ctx) override;
|
||||
@ -190,7 +197,9 @@ public:
|
||||
antlrcpp::Any visitTableElementExprColumn(ClickHouseParser::TableElementExprColumnContext * ctx) override;
|
||||
antlrcpp::Any visitTableElementExprConstraint(ClickHouseParser::TableElementExprConstraintContext * ctx) override;
|
||||
antlrcpp::Any visitTableElementExprIndex(ClickHouseParser::TableElementExprIndexContext * ctx) override;
|
||||
antlrcpp::Any visitTableElementExprProjection(ClickHouseParser::TableElementExprProjectionContext * ctx) override;
|
||||
antlrcpp::Any visitTableIndexDfnt(ClickHouseParser::TableIndexDfntContext * ctx) override;
|
||||
antlrcpp::Any visitTableProjectionDfnt(ClickHouseParser::TableProjectionDfntContext * ctx) override;
|
||||
|
||||
// TableExpr
|
||||
antlrcpp::Any visitTableArgExpr(ClickHouseParser::TableArgExprContext * ctx) override;
|
||||
@ -236,6 +245,7 @@ public:
|
||||
antlrcpp::Any visitGroupByClause(ClickHouseParser::GroupByClauseContext *ctx) override;
|
||||
antlrcpp::Any visitHavingClause(ClickHouseParser::HavingClauseContext *ctx) override;
|
||||
antlrcpp::Any visitOrderByClause(ClickHouseParser::OrderByClauseContext *ctx) override;
|
||||
antlrcpp::Any visitProjectionOrderByClause(ClickHouseParser::ProjectionOrderByClauseContext *ctx) override;
|
||||
antlrcpp::Any visitLimitByClause(ClickHouseParser::LimitByClauseContext *ctx) override;
|
||||
antlrcpp::Any visitLimitClause(ClickHouseParser::LimitClauseContext *ctx) override;
|
||||
antlrcpp::Any visitSettingsClause(ClickHouseParser::SettingsClauseContext *ctx) override;
|
||||
|
@ -177,8 +177,7 @@ bool ParserProjectionDeclaration::parseImpl(Pos & pos, ASTPtr & node, Expected &
|
||||
|
||||
auto projection = std::make_shared<ASTProjectionDeclaration>();
|
||||
projection->name = name->as<ASTIdentifier &>().name();
|
||||
projection->query = query;
|
||||
projection->children.emplace_back(projection->query);
|
||||
projection->set(projection->query, query);
|
||||
node = projection;
|
||||
|
||||
return true;
|
||||
|
@ -17,20 +17,15 @@ bool ParserProjectionSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected &
|
||||
|
||||
ParserKeyword s_with("WITH");
|
||||
ParserKeyword s_select("SELECT");
|
||||
ParserKeyword s_distinct("DISTINCT");
|
||||
ParserKeyword s_where("WHERE");
|
||||
ParserKeyword s_group_by("GROUP BY");
|
||||
ParserKeyword s_order_by("ORDER BY");
|
||||
|
||||
ParserNotEmptyExpressionList exp_list(false);
|
||||
ParserNotEmptyExpressionList exp_list_for_with_clause(false);
|
||||
ParserNotEmptyExpressionList exp_list_for_select_clause(true); /// Allows aliases without AS keyword.
|
||||
ParserExpressionWithOptionalAlias exp_elem(false);
|
||||
ParserExpression order_expression_p;
|
||||
|
||||
ASTPtr with_expression_list;
|
||||
ASTPtr select_expression_list;
|
||||
ASTPtr where_expression;
|
||||
ASTPtr group_expression_list;
|
||||
ASTPtr order_expression;
|
||||
|
||||
@ -48,21 +43,10 @@ bool ParserProjectionSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected &
|
||||
if (!s_select.ignore(pos, expected))
|
||||
return false;
|
||||
|
||||
if (s_distinct.ignore(pos, expected))
|
||||
select_query->distinct = true;
|
||||
|
||||
if (!exp_list_for_select_clause.parse(pos, select_expression_list, expected))
|
||||
return false;
|
||||
}
|
||||
|
||||
// TODO: wait for condition normalizer to land
|
||||
/// WHERE expr
|
||||
// if (s_where.ignore(pos, expected))
|
||||
// {
|
||||
// if (!exp_elem.parse(pos, where_expression, expected))
|
||||
// return false;
|
||||
// }
|
||||
|
||||
// If group by is specified, AggregatingMergeTree engine is used, and the group by keys are implied to be order by keys
|
||||
if (s_group_by.ignore(pos, expected))
|
||||
{
|
||||
@ -70,6 +54,7 @@ bool ParserProjectionSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected &
|
||||
.parse(pos, group_expression_list, expected))
|
||||
return false;
|
||||
}
|
||||
|
||||
if (s_order_by.ignore(pos, expected))
|
||||
{
|
||||
ASTPtr expr_list;
|
||||
@ -92,7 +77,6 @@ bool ParserProjectionSelectQuery::parseImpl(Pos & pos, ASTPtr & node, Expected &
|
||||
|
||||
select_query->setExpression(ASTProjectionSelectQuery::Expression::WITH, std::move(with_expression_list));
|
||||
select_query->setExpression(ASTProjectionSelectQuery::Expression::SELECT, std::move(select_expression_list));
|
||||
// select_query->setExpression(ASTProjectionSelectQuery::Expression::WHERE, std::move(where_expression));
|
||||
select_query->setExpression(ASTProjectionSelectQuery::Expression::GROUP_BY, std::move(group_expression_list));
|
||||
select_query->setExpression(ASTProjectionSelectQuery::Expression::ORDER_BY, std::move(order_expression));
|
||||
return true;
|
||||
|
@ -397,9 +397,6 @@
|
||||
"01475_read_subcolumns_storages",
|
||||
"01674_clickhouse_client_query_param_cte",
|
||||
"01666_merge_tree_max_query_limit",
|
||||
"01710_projections",
|
||||
"01710_normal_projections",
|
||||
"01710_aggregate_projections",
|
||||
"01786_explain_merge_tree",
|
||||
"01666_merge_tree_max_query_limit",
|
||||
"01802_test_postgresql_protocol_with_row_policy", /// It cannot parse DROP ROW POLICY
|
||||
|
Loading…
Reference in New Issue
Block a user