Skip to content

Commit

Permalink
feat(hogql): HogQLX (#18097)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariusandra authored Oct 26, 2023
1 parent d6d259a commit 15e3e85
Show file tree
Hide file tree
Showing 32 changed files with 4,398 additions and 3,351 deletions.
872 changes: 440 additions & 432 deletions hogql_parser/HogQLLexer.cpp

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions hogql_parser/HogQLLexer.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ class HogQLLexer : public antlr4::Lexer {
UNION = 176, UPDATE = 177, USE = 178, USING = 179, UUID = 180, VALUES = 181,
VIEW = 182, VOLUME = 183, WATCH = 184, WEEK = 185, WHEN = 186, WHERE = 187,
WINDOW = 188, WITH = 189, YEAR = 190, JSON_FALSE = 191, JSON_TRUE = 192,
ESCAPE_CHAR = 193, IDENTIFIER = 194, FLOATING_LITERAL = 195, OCTAL_LITERAL = 196,
DECIMAL_LITERAL = 197, HEXADECIMAL_LITERAL = 198, STRING_LITERAL = 199,
PLACEHOLDER = 200, ARROW = 201, ASTERISK = 202, BACKQUOTE = 203, BACKSLASH = 204,
COLON = 205, COMMA = 206, CONCAT = 207, DASH = 208, DOLLAR = 209, DOT = 210,
EQ_DOUBLE = 211, EQ_SINGLE = 212, GT_EQ = 213, GT = 214, HASH = 215,
IREGEX_SINGLE = 216, IREGEX_DOUBLE = 217, LBRACE = 218, LBRACKET = 219,
LPAREN = 220, LT_EQ = 221, LT = 222, NOT_EQ = 223, NOT_IREGEX = 224,
NOT_REGEX = 225, NULLISH = 226, PERCENT = 227, PLUS = 228, QUERY = 229,
QUOTE_DOUBLE = 230, QUOTE_SINGLE = 231, REGEX_SINGLE = 232, REGEX_DOUBLE = 233,
RBRACE = 234, RBRACKET = 235, RPAREN = 236, SEMICOLON = 237, SLASH = 238,
UNDERSCORE = 239, MULTI_LINE_COMMENT = 240, SINGLE_LINE_COMMENT = 241,
ESCAPE_CHAR_SINGLE = 193, ESCAPE_CHAR_DOUBLE = 194, IDENTIFIER = 195,
FLOATING_LITERAL = 196, OCTAL_LITERAL = 197, DECIMAL_LITERAL = 198,
HEXADECIMAL_LITERAL = 199, STRING_LITERAL = 200, ARROW = 201, ASTERISK = 202,
BACKQUOTE = 203, BACKSLASH = 204, COLON = 205, COMMA = 206, CONCAT = 207,
DASH = 208, DOLLAR = 209, DOT = 210, EQ_DOUBLE = 211, EQ_SINGLE = 212,
GT_EQ = 213, GT = 214, HASH = 215, IREGEX_SINGLE = 216, IREGEX_DOUBLE = 217,
LBRACE = 218, LBRACKET = 219, LPAREN = 220, LT_EQ = 221, LT = 222, NOT_EQ = 223,
NOT_IREGEX = 224, NOT_REGEX = 225, NULLISH = 226, PERCENT = 227, PLUS = 228,
QUERY = 229, QUOTE_DOUBLE = 230, QUOTE_SINGLE = 231, REGEX_SINGLE = 232,
REGEX_DOUBLE = 233, RBRACE = 234, RBRACKET = 235, RPAREN = 236, SEMICOLON = 237,
SLASH = 238, UNDERSCORE = 239, MULTI_LINE_COMMENT = 240, SINGLE_LINE_COMMENT = 241,
WHITESPACE = 242
};

Expand Down
10 changes: 5 additions & 5 deletions hogql_parser/HogQLLexer.interp

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions hogql_parser/HogQLLexer.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ WITH=189
YEAR=190
JSON_FALSE=191
JSON_TRUE=192
ESCAPE_CHAR=193
IDENTIFIER=194
FLOATING_LITERAL=195
OCTAL_LITERAL=196
DECIMAL_LITERAL=197
HEXADECIMAL_LITERAL=198
STRING_LITERAL=199
PLACEHOLDER=200
ESCAPE_CHAR_SINGLE=193
ESCAPE_CHAR_DOUBLE=194
IDENTIFIER=195
FLOATING_LITERAL=196
OCTAL_LITERAL=197
DECIMAL_LITERAL=198
HEXADECIMAL_LITERAL=199
STRING_LITERAL=200
ARROW=201
ASTERISK=202
BACKQUOTE=203
Expand Down
2,297 changes: 1,313 additions & 984 deletions hogql_parser/HogQLParser.cpp

Large diffs are not rendered by default.

116 changes: 95 additions & 21 deletions hogql_parser/HogQLParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,17 @@ class HogQLParser : public antlr4::Parser {
UNION = 176, UPDATE = 177, USE = 178, USING = 179, UUID = 180, VALUES = 181,
VIEW = 182, VOLUME = 183, WATCH = 184, WEEK = 185, WHEN = 186, WHERE = 187,
WINDOW = 188, WITH = 189, YEAR = 190, JSON_FALSE = 191, JSON_TRUE = 192,
ESCAPE_CHAR = 193, IDENTIFIER = 194, FLOATING_LITERAL = 195, OCTAL_LITERAL = 196,
DECIMAL_LITERAL = 197, HEXADECIMAL_LITERAL = 198, STRING_LITERAL = 199,
PLACEHOLDER = 200, ARROW = 201, ASTERISK = 202, BACKQUOTE = 203, BACKSLASH = 204,
COLON = 205, COMMA = 206, CONCAT = 207, DASH = 208, DOLLAR = 209, DOT = 210,
EQ_DOUBLE = 211, EQ_SINGLE = 212, GT_EQ = 213, GT = 214, HASH = 215,
IREGEX_SINGLE = 216, IREGEX_DOUBLE = 217, LBRACE = 218, LBRACKET = 219,
LPAREN = 220, LT_EQ = 221, LT = 222, NOT_EQ = 223, NOT_IREGEX = 224,
NOT_REGEX = 225, NULLISH = 226, PERCENT = 227, PLUS = 228, QUERY = 229,
QUOTE_DOUBLE = 230, QUOTE_SINGLE = 231, REGEX_SINGLE = 232, REGEX_DOUBLE = 233,
RBRACE = 234, RBRACKET = 235, RPAREN = 236, SEMICOLON = 237, SLASH = 238,
UNDERSCORE = 239, MULTI_LINE_COMMENT = 240, SINGLE_LINE_COMMENT = 241,
ESCAPE_CHAR_SINGLE = 193, ESCAPE_CHAR_DOUBLE = 194, IDENTIFIER = 195,
FLOATING_LITERAL = 196, OCTAL_LITERAL = 197, DECIMAL_LITERAL = 198,
HEXADECIMAL_LITERAL = 199, STRING_LITERAL = 200, ARROW = 201, ASTERISK = 202,
BACKQUOTE = 203, BACKSLASH = 204, COLON = 205, COMMA = 206, CONCAT = 207,
DASH = 208, DOLLAR = 209, DOT = 210, EQ_DOUBLE = 211, EQ_SINGLE = 212,
GT_EQ = 213, GT = 214, HASH = 215, IREGEX_SINGLE = 216, IREGEX_DOUBLE = 217,
LBRACE = 218, LBRACKET = 219, LPAREN = 220, LT_EQ = 221, LT = 222, NOT_EQ = 223,
NOT_IREGEX = 224, NOT_REGEX = 225, NULLISH = 226, PERCENT = 227, PLUS = 228,
QUERY = 229, QUOTE_DOUBLE = 230, QUOTE_SINGLE = 231, REGEX_SINGLE = 232,
REGEX_DOUBLE = 233, RBRACE = 234, RBRACKET = 235, RPAREN = 236, SEMICOLON = 237,
SLASH = 238, UNDERSCORE = 239, MULTI_LINE_COMMENT = 240, SINGLE_LINE_COMMENT = 241,
WHITESPACE = 242
};

Expand All @@ -73,12 +73,13 @@ class HogQLParser : public antlr4::Parser {
RuleWinPartitionByClause = 29, RuleWinOrderByClause = 30, RuleWinFrameClause = 31,
RuleWinFrameExtend = 32, RuleWinFrameBound = 33, RuleExpr = 34, RuleColumnTypeExpr = 35,
RuleColumnExprList = 36, RuleColumnExpr = 37, RuleColumnArgList = 38,
RuleColumnArgExpr = 39, RuleColumnLambdaExpr = 40, RuleWithExprList = 41,
RuleWithExpr = 42, RuleColumnIdentifier = 43, RuleNestedIdentifier = 44,
RuleTableExpr = 45, RuleTableFunctionExpr = 46, RuleTableIdentifier = 47,
RuleTableArgList = 48, RuleDatabaseIdentifier = 49, RuleFloatingLiteral = 50,
RuleNumberLiteral = 51, RuleLiteral = 52, RuleInterval = 53, RuleKeyword = 54,
RuleKeywordForAlias = 55, RuleAlias = 56, RuleIdentifier = 57, RuleEnumValue = 58
RuleColumnArgExpr = 39, RuleColumnLambdaExpr = 40, RuleHogqlxTagElement = 41,
RuleHogqlxTagAttribute = 42, RuleWithExprList = 43, RuleWithExpr = 44,
RuleColumnIdentifier = 45, RuleNestedIdentifier = 46, RuleTableExpr = 47,
RuleTableFunctionExpr = 48, RuleTableIdentifier = 49, RuleTableArgList = 50,
RuleDatabaseIdentifier = 51, RuleFloatingLiteral = 52, RuleNumberLiteral = 53,
RuleLiteral = 54, RuleInterval = 55, RuleKeyword = 56, RuleKeywordForAlias = 57,
RuleAlias = 58, RuleIdentifier = 59, RuleEnumValue = 60, RulePlaceholder = 61
};

explicit HogQLParser(antlr4::TokenStream *input);
Expand Down Expand Up @@ -139,6 +140,8 @@ class HogQLParser : public antlr4::Parser {
class ColumnArgListContext;
class ColumnArgExprContext;
class ColumnLambdaExprContext;
class HogqlxTagElementContext;
class HogqlxTagAttributeContext;
class WithExprListContext;
class WithExprContext;
class ColumnIdentifierContext;
Expand All @@ -156,7 +159,8 @@ class HogQLParser : public antlr4::Parser {
class KeywordForAliasContext;
class AliasContext;
class IdentifierContext;
class EnumValueContext;
class EnumValueContext;
class PlaceholderContext;

class SelectContext : public antlr4::ParserRuleContext {
public:
Expand All @@ -165,6 +169,7 @@ class HogQLParser : public antlr4::Parser {
antlr4::tree::TerminalNode *EOF();
SelectUnionStmtContext *selectUnionStmt();
SelectStmtContext *selectStmt();
HogqlxTagElementContext *hogqlxTagElement();


virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
Expand Down Expand Up @@ -675,7 +680,7 @@ class HogQLParser : public antlr4::Parser {
public:
RatioExprContext(antlr4::ParserRuleContext *parent, size_t invokingState);
virtual size_t getRuleIndex() const override;
antlr4::tree::TerminalNode *PLACEHOLDER();
PlaceholderContext *placeholder();
std::vector<NumberLiteralContext *> numberLiteral();
NumberLiteralContext* numberLiteral(size_t i);
antlr4::tree::TerminalNode *SLASH();
Expand Down Expand Up @@ -1194,6 +1199,15 @@ class HogQLParser : public antlr4::Parser {
virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
};

class ColumnExprTagElementContext : public ColumnExprContext {
public:
ColumnExprTagElementContext(ColumnExprContext *ctx);

HogqlxTagElementContext *hogqlxTagElement();

virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
};

class ColumnExprTupleContext : public ColumnExprContext {
public:
ColumnExprTupleContext(ColumnExprContext *ctx);
Expand Down Expand Up @@ -1440,6 +1454,42 @@ class HogQLParser : public antlr4::Parser {

ColumnLambdaExprContext* columnLambdaExpr();

class HogqlxTagElementContext : public antlr4::ParserRuleContext {
public:
HogqlxTagElementContext(antlr4::ParserRuleContext *parent, size_t invokingState);
virtual size_t getRuleIndex() const override;
antlr4::tree::TerminalNode *LT();
IdentifierContext *identifier();
antlr4::tree::TerminalNode *SLASH();
antlr4::tree::TerminalNode *GT();
std::vector<HogqlxTagAttributeContext *> hogqlxTagAttribute();
HogqlxTagAttributeContext* hogqlxTagAttribute(size_t i);


virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;

};

HogqlxTagElementContext* hogqlxTagElement();

class HogqlxTagAttributeContext : public antlr4::ParserRuleContext {
public:
HogqlxTagAttributeContext(antlr4::ParserRuleContext *parent, size_t invokingState);
virtual size_t getRuleIndex() const override;
IdentifierContext *identifier();
antlr4::tree::TerminalNode *EQ_SINGLE();
antlr4::tree::TerminalNode *STRING_LITERAL();
antlr4::tree::TerminalNode *LBRACE();
ColumnExprContext *columnExpr();
antlr4::tree::TerminalNode *RBRACE();


virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;

};

HogqlxTagAttributeContext* hogqlxTagAttribute();

class WithExprListContext : public antlr4::ParserRuleContext {
public:
WithExprListContext(antlr4::ParserRuleContext *parent, size_t invokingState);
Expand Down Expand Up @@ -1499,7 +1549,7 @@ class HogQLParser : public antlr4::Parser {
public:
ColumnIdentifierContext(antlr4::ParserRuleContext *parent, size_t invokingState);
virtual size_t getRuleIndex() const override;
antlr4::tree::TerminalNode *PLACEHOLDER();
PlaceholderContext *placeholder();
NestedIdentifierContext *nestedIdentifier();
TableIdentifierContext *tableIdentifier();
antlr4::tree::TerminalNode *DOT();
Expand Down Expand Up @@ -1540,6 +1590,15 @@ class HogQLParser : public antlr4::Parser {

};

class TableExprTagContext : public TableExprContext {
public:
TableExprTagContext(TableExprContext *ctx);

HogqlxTagElementContext *hogqlxTagElement();

virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
};

class TableExprIdentifierContext : public TableExprContext {
public:
TableExprIdentifierContext(TableExprContext *ctx);
Expand All @@ -1553,7 +1612,7 @@ class HogQLParser : public antlr4::Parser {
public:
TableExprPlaceholderContext(TableExprContext *ctx);

antlr4::tree::TerminalNode *PLACEHOLDER();
PlaceholderContext *placeholder();

virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;
};
Expand Down Expand Up @@ -1974,6 +2033,21 @@ class HogQLParser : public antlr4::Parser {

EnumValueContext* enumValue();

class PlaceholderContext : public antlr4::ParserRuleContext {
public:
PlaceholderContext(antlr4::ParserRuleContext *parent, size_t invokingState);
virtual size_t getRuleIndex() const override;
antlr4::tree::TerminalNode *LBRACE();
IdentifierContext *identifier();
antlr4::tree::TerminalNode *RBRACE();


virtual std::any accept(antlr4::tree::ParseTreeVisitor *visitor) override;

};

PlaceholderContext* placeholder();


bool sempred(antlr4::RuleContext *_localctx, size_t ruleIndex, size_t predicateIndex) override;

Expand Down
9 changes: 6 additions & 3 deletions hogql_parser/HogQLParser.interp

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions hogql_parser/HogQLParser.tokens
Original file line number Diff line number Diff line change
Expand Up @@ -190,14 +190,14 @@ WITH=189
YEAR=190
JSON_FALSE=191
JSON_TRUE=192
ESCAPE_CHAR=193
IDENTIFIER=194
FLOATING_LITERAL=195
OCTAL_LITERAL=196
DECIMAL_LITERAL=197
HEXADECIMAL_LITERAL=198
STRING_LITERAL=199
PLACEHOLDER=200
ESCAPE_CHAR_SINGLE=193
ESCAPE_CHAR_DOUBLE=194
IDENTIFIER=195
FLOATING_LITERAL=196
OCTAL_LITERAL=197
DECIMAL_LITERAL=198
HEXADECIMAL_LITERAL=199
STRING_LITERAL=200
ARROW=201
ASTERISK=202
BACKQUOTE=203
Expand Down
20 changes: 20 additions & 0 deletions hogql_parser/HogQLParserBaseVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,10 @@ class HogQLParserBaseVisitor : public HogQLParserVisitor {
return visitChildren(ctx);
}

virtual std::any visitColumnExprTagElement(HogQLParser::ColumnExprTagElementContext *ctx) override {
return visitChildren(ctx);
}

virtual std::any visitColumnExprTuple(HogQLParser::ColumnExprTupleContext *ctx) override {
return visitChildren(ctx);
}
Expand Down Expand Up @@ -347,6 +351,14 @@ class HogQLParserBaseVisitor : public HogQLParserVisitor {
return visitChildren(ctx);
}

virtual std::any visitHogqlxTagElement(HogQLParser::HogqlxTagElementContext *ctx) override {
return visitChildren(ctx);
}

virtual std::any visitHogqlxTagAttribute(HogQLParser::HogqlxTagAttributeContext *ctx) override {
return visitChildren(ctx);
}

virtual std::any visitWithExprList(HogQLParser::WithExprListContext *ctx) override {
return visitChildren(ctx);
}
Expand All @@ -367,6 +379,10 @@ class HogQLParserBaseVisitor : public HogQLParserVisitor {
return visitChildren(ctx);
}

virtual std::any visitTableExprTag(HogQLParser::TableExprTagContext *ctx) override {
return visitChildren(ctx);
}

virtual std::any visitTableExprIdentifier(HogQLParser::TableExprIdentifierContext *ctx) override {
return visitChildren(ctx);
}
Expand Down Expand Up @@ -439,6 +455,10 @@ class HogQLParserBaseVisitor : public HogQLParserVisitor {
return visitChildren(ctx);
}

virtual std::any visitPlaceholder(HogQLParser::PlaceholderContext *ctx) override {
return visitChildren(ctx);
}


};

10 changes: 10 additions & 0 deletions hogql_parser/HogQLParserVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ class HogQLParserVisitor : public antlr4::tree::AbstractParseTreeVisitor {

virtual std::any visitColumnExprTrim(HogQLParser::ColumnExprTrimContext *context) = 0;

virtual std::any visitColumnExprTagElement(HogQLParser::ColumnExprTagElementContext *context) = 0;

virtual std::any visitColumnExprTuple(HogQLParser::ColumnExprTupleContext *context) = 0;

virtual std::any visitColumnExprArrayAccess(HogQLParser::ColumnExprArrayAccessContext *context) = 0;
Expand Down Expand Up @@ -185,6 +187,10 @@ class HogQLParserVisitor : public antlr4::tree::AbstractParseTreeVisitor {

virtual std::any visitColumnLambdaExpr(HogQLParser::ColumnLambdaExprContext *context) = 0;

virtual std::any visitHogqlxTagElement(HogQLParser::HogqlxTagElementContext *context) = 0;

virtual std::any visitHogqlxTagAttribute(HogQLParser::HogqlxTagAttributeContext *context) = 0;

virtual std::any visitWithExprList(HogQLParser::WithExprListContext *context) = 0;

virtual std::any visitWithExprSubquery(HogQLParser::WithExprSubqueryContext *context) = 0;
Expand All @@ -195,6 +201,8 @@ class HogQLParserVisitor : public antlr4::tree::AbstractParseTreeVisitor {

virtual std::any visitNestedIdentifier(HogQLParser::NestedIdentifierContext *context) = 0;

virtual std::any visitTableExprTag(HogQLParser::TableExprTagContext *context) = 0;

virtual std::any visitTableExprIdentifier(HogQLParser::TableExprIdentifierContext *context) = 0;

virtual std::any visitTableExprPlaceholder(HogQLParser::TableExprPlaceholderContext *context) = 0;
Expand Down Expand Up @@ -231,6 +239,8 @@ class HogQLParserVisitor : public antlr4::tree::AbstractParseTreeVisitor {

virtual std::any visitEnumValue(HogQLParser::EnumValueContext *context) = 0;

virtual std::any visitPlaceholder(HogQLParser::PlaceholderContext *context) = 0;


};

Loading

0 comments on commit 15e3e85

Please sign in to comment.