From 7e4419531caa5b4d5c198e14929d4d697b856382 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Wed, 8 Feb 2023 11:42:45 +0100 Subject: [PATCH 1/7] feat(hogql): select statements --- frontend/src/queries/schema.json | 57 +++--- frontend/src/queries/schema.ts | 14 +- posthog/hogql/ast.py | 28 ++- posthog/hogql/constants.py | 3 + posthog/hogql/context.py | 5 + posthog/hogql/parser.py | 185 +++++++++++++++--- posthog/hogql/printer.py | 73 ++++++- posthog/hogql/test/test_parser.py | 238 ++++++++++++++++++++++- posthog/hogql/test/test_printer.py | 97 +++++++++ posthog/models/event/query_event_list.py | 10 +- posthog/schema.py | 6 +- 11 files changed, 641 insertions(+), 75 deletions(-) diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json index 1ac0c8e20d62e..58353872860da 100644 --- a/frontend/src/queries/schema.json +++ b/frontend/src/queries/schema.json @@ -1600,34 +1600,8 @@ "type": "array" }, "response": { - "additionalProperties": false, - "description": "Cached query response", - "properties": { - "columns": { - "items": { - "type": "string" - }, - "type": "array" - }, - "hasMore": { - "type": "boolean" - }, - "results": { - "items": { - "items": {}, - "type": "array" - }, - "type": "array" - }, - "types": { - "items": { - "type": "string" - }, - "type": "array" - } - }, - "required": ["columns", "types", "results"], - "type": "object" + "$ref": "#/definitions/EventsQueryResponse", + "description": "Cached query response" }, "select": { "description": "Return a limited set of data. Required.", @@ -1647,6 +1621,33 @@ "required": ["kind", "select"], "type": "object" }, + "EventsQueryResponse": { + "additionalProperties": false, + "properties": { + "columns": { + "items": {}, + "type": "array" + }, + "hasMore": { + "type": "boolean" + }, + "results": { + "items": { + "items": {}, + "type": "array" + }, + "type": "array" + }, + "types": { + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": ["columns", "types", "results"], + "type": "object" + }, "FeaturePropertyFilter": { "additionalProperties": false, "properties": { diff --git a/frontend/src/queries/schema.ts b/frontend/src/queries/schema.ts index 5bfebc91f3c6c..161b0b349c4d1 100644 --- a/frontend/src/queries/schema.ts +++ b/frontend/src/queries/schema.ts @@ -134,6 +134,13 @@ export interface NewEntityNode extends EntityNode { event?: string | null } +export interface EventsQueryResponse { + columns: any[] + types: string[] + results: any[][] + hasMore?: boolean +} + export interface EventsQuery extends DataNode { kind: NodeKind.EventsQuery /** Return a limited set of data. Required. */ @@ -170,12 +177,7 @@ export interface EventsQuery extends DataNode { /** Columns to order by */ orderBy?: string[] - response?: { - columns: string[] - types: string[] - results: any[][] - hasMore?: boolean - } + response?: EventsQueryResponse } export interface PersonsNode extends DataNode { diff --git a/posthog/hogql/ast.py b/posthog/hogql/ast.py index afba1f5cb50d5..b43b558fccc23 100644 --- a/posthog/hogql/ast.py +++ b/posthog/hogql/ast.py @@ -1,6 +1,6 @@ import re from enum import Enum -from typing import Any, List, Literal +from typing import Any, List, Literal, Optional, Union from pydantic import BaseModel, Extra @@ -102,3 +102,29 @@ class Placeholder(Expr): class Call(Expr): name: str args: List[Expr] + + +class JoinExpr(Expr): + table: Optional[Union["SelectQuery", Field]] = None + table_final: Optional[bool] = None + alias: Optional[str] = None + join_type: Optional[str] = None + join_constraint: Optional[Expr] = None + join_expr: Optional["JoinExpr"] = None + + +class SelectQuery(Expr): + select: List[Expr] + select_from: Optional[JoinExpr] = None + where: Optional[Expr] = None + prewhere: Optional[Expr] = None + having: Optional[Expr] = None + group_by: Optional[List[Expr]] = None + order_by: Optional[List[OrderExpr]] = None + limit: Optional[int] = None + offset: Optional[int] = None + distinct: Optional[bool] = None + + +JoinExpr.update_forward_refs(SelectQuery=SelectQuery) +JoinExpr.update_forward_refs(JoinExpr=JoinExpr) diff --git a/posthog/hogql/constants.py b/posthog/hogql/constants.py index 2f2359c104562..a7f7a8357c7ff 100644 --- a/posthog/hogql/constants.py +++ b/posthog/hogql/constants.py @@ -124,3 +124,6 @@ "person.created_at", "person.properties", ] + +# Never return more rows than this in top level HogQL SELECT statements +MAX_SELECT_RETURNED_ROWS = 65535 diff --git a/posthog/hogql/context.py b/posthog/hogql/context.py index 6e2221a3d7348..df3aabbd97e12 100644 --- a/posthog/hogql/context.py +++ b/posthog/hogql/context.py @@ -20,4 +20,9 @@ class HogQLContext: field_access_logs: List[HogQLFieldAccess] = field(default_factory=list) # Did the last calls to translate_hogql since setting these to False contain any of the following found_aggregation: bool = False + # Do we need to join the persons table or not using_person_on_events: bool = True + # If set, allows printing full SELECT queries in ClickHouse + select_team_id: Optional[int] = None + # Do we apply a limit of MAX_SELECT_RETURNED_ROWS=65535 to the topmost select query? + limit_top_select: bool = True diff --git a/posthog/hogql/parser.py b/posthog/hogql/parser.py index bc3eca9e61c15..b1891dddad6fe 100644 --- a/posthog/hogql/parser.py +++ b/posthog/hogql/parser.py @@ -1,4 +1,4 @@ -from typing import Dict, Optional +from typing import Dict, Literal, Optional, cast from antlr4 import CommonTokenStream, InputStream, ParseTreeVisitor from antlr4.error.ErrorListener import ErrorListener @@ -18,6 +18,14 @@ def parse_expr(expr: str, placeholders: Optional[Dict[str, ast.Expr]] = None) -> return node +def parse_select(statement: str, placeholders: Optional[Dict[str, ast.Expr]] = None) -> ast.Expr: + parse_tree = get_parser(statement).select() + node = HogQLParseTreeConverter().visit(parse_tree) + if placeholders: + node = replace_placeholders(node, placeholders) + return node + + def get_parser(query: str) -> HogQLParser: input_stream = InputStream(data=query) lexer = HogQLLexer(input_stream) @@ -35,16 +43,69 @@ def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e): class HogQLParseTreeConverter(ParseTreeVisitor): def visitSelect(self, ctx: HogQLParser.SelectContext): - raise NotImplementedError(f"Unsupported node: SelectQuery") + return self.visit(ctx.selectUnionStmt() or ctx.selectStmt()) def visitSelectUnionStmt(self, ctx: HogQLParser.SelectUnionStmtContext): - raise NotImplementedError(f"Unsupported node: SelectUnionStmt") + selects = ctx.selectStmtWithParens() + if len(selects) != 1: + raise NotImplementedError(f"Unsupported: UNION ALL") + return self.visit(selects[0]) def visitSelectStmtWithParens(self, ctx: HogQLParser.SelectStmtWithParensContext): - raise NotImplementedError(f"Unsupported node: SelectStmtWithParens") + return self.visit(ctx.selectStmt() or ctx.selectUnionStmt()) def visitSelectStmt(self, ctx: HogQLParser.SelectStmtContext): - raise NotImplementedError(f"Unsupported node: SelectStmt") + select = self.visit(ctx.columnExprList()) if ctx.columnExprList() else [] + select_from = self.visit(ctx.fromClause()) if ctx.fromClause() else None + where = self.visit(ctx.whereClause()) if ctx.whereClause() else None + prewhere = self.visit(ctx.prewhereClause()) if ctx.prewhereClause() else None + having = self.visit(ctx.havingClause()) if ctx.havingClause() else None + group_by = self.visit(ctx.groupByClause()) if ctx.groupByClause() else None + order_by = self.visit(ctx.orderByClause()) if ctx.orderByClause() else None + + limit = None + offset = None + if ctx.limitClause() and ctx.limitClause().limitExpr(): + limit_expr = ctx.limitClause().limitExpr() + limit_node = self.visit(limit_expr.columnExpr(0)) + if limit_node is not None: + if isinstance(limit_node, ast.Constant) and isinstance(limit_node.value, int): + limit = limit_node.value + else: + raise Exception(f"LIMIT must be an integer") + if limit_expr.columnExpr(1): + offset_node = self.visit(limit_expr.columnExpr(1)) + if offset_node is not None: + if isinstance(offset_node, ast.Constant) and isinstance(offset_node.value, int): + offset = offset_node.value + else: + raise Exception(f"OFFSET must be an integer") + + if ctx.withClause(): + raise NotImplementedError(f"Unsupported: SelectStmt.withClause()") + if ctx.topClause(): + raise NotImplementedError(f"Unsupported: SelectStmt.topClause()") + if ctx.arrayJoinClause(): + raise NotImplementedError(f"Unsupported: SelectStmt.arrayJoinClause()") + if ctx.windowClause(): + raise NotImplementedError(f"Unsupported: SelectStmt.windowClause()") + if ctx.limitByClause(): + raise NotImplementedError(f"Unsupported: SelectStmt.limitByClause()") + if ctx.settingsClause(): + raise NotImplementedError(f"Unsupported: SelectStmt.settingsClause()") + + return ast.SelectQuery( + select=select, + distinct=True if ctx.DISTINCT() else None, + select_from=select_from, + where=where, + prewhere=prewhere, + having=having, + group_by=group_by, + order_by=order_by, + limit=limit, + offset=offset, + ) def visitWithClause(self, ctx: HogQLParser.WithClauseContext): raise NotImplementedError(f"Unsupported node: WithClause") @@ -53,7 +114,7 @@ def visitTopClause(self, ctx: HogQLParser.TopClauseContext): raise NotImplementedError(f"Unsupported node: TopClause") def visitFromClause(self, ctx: HogQLParser.FromClauseContext): - raise NotImplementedError(f"Unsupported node: FromClause") + return self.visit(ctx.joinExpr()) def visitArrayJoinClause(self, ctx: HogQLParser.ArrayJoinClauseContext): raise NotImplementedError(f"Unsupported node: ArrayJoinClause") @@ -62,19 +123,19 @@ def visitWindowClause(self, ctx: HogQLParser.WindowClauseContext): raise NotImplementedError(f"Unsupported node: WindowClause") def visitPrewhereClause(self, ctx: HogQLParser.PrewhereClauseContext): - raise NotImplementedError(f"Unsupported node: PrewhereClause") + return self.visit(ctx.columnExpr()) def visitWhereClause(self, ctx: HogQLParser.WhereClauseContext): - raise NotImplementedError(f"Unsupported node: WhereClause") + return self.visit(ctx.columnExpr()) def visitGroupByClause(self, ctx: HogQLParser.GroupByClauseContext): - raise NotImplementedError(f"Unsupported node: GroupByClause") + return self.visit(ctx.columnExprList()) def visitHavingClause(self, ctx: HogQLParser.HavingClauseContext): - raise NotImplementedError(f"Unsupported node: HavingClause") + return self.visit(ctx.columnExpr()) def visitOrderByClause(self, ctx: HogQLParser.OrderByClauseContext): - raise NotImplementedError(f"Unsupported node: OrderByClause") + return self.visit(ctx.orderExprList()) def visitProjectionOrderByClause(self, ctx: HogQLParser.ProjectionOrderByClauseContext): raise NotImplementedError(f"Unsupported node: ProjectionOrderByClause") @@ -89,31 +150,102 @@ def visitSettingsClause(self, ctx: HogQLParser.SettingsClauseContext): raise NotImplementedError(f"Unsupported node: SettingsClause") def visitJoinExprOp(self, ctx: HogQLParser.JoinExprOpContext): - raise NotImplementedError(f"Unsupported node: JoinExprOp") + if ctx.GLOBAL(): + raise NotImplementedError(f"Unsupported: GLOBAL JOIN") + if ctx.LOCAL(): + raise NotImplementedError(f"Unsupported: LOCAL JOIN") + + join1: ast.JoinExpr = self.visit(ctx.joinExpr(0)) + join2: ast.JoinExpr = self.visit(ctx.joinExpr(1)) + + if ctx.joinOp(): + join_type = f"{self.visit(ctx.joinOp())} JOIN" + else: + join_type = "JOIN" + join_constraint = self.visit(ctx.joinConstraintClause()) + + join_without_next_expr = join1 + while join_without_next_expr.join_expr: + join_without_next_expr = join_without_next_expr.join_expr + + join_without_next_expr.join_expr = join2 + join_without_next_expr.join_constraint = join_constraint + join_without_next_expr.join_type = join_type + return join1 def visitJoinExprTable(self, ctx: HogQLParser.JoinExprTableContext): - raise NotImplementedError(f"Unsupported node: JoinExprTable") + if ctx.sampleClause(): + raise NotImplementedError(f"Unsupported: SAMPLE (JoinExprTable.sampleClause)") + table = self.visit(ctx.tableExpr()) + table_final = True if ctx.FINAL() else None + if isinstance(table, ast.JoinExpr): + # visitTableExprAlias returns a JoinExpr to pass the alias + table.table_final = table_final + return table + return ast.JoinExpr(table=table, table_final=table_final) def visitJoinExprParens(self, ctx: HogQLParser.JoinExprParensContext): - raise NotImplementedError(f"Unsupported node: JoinExprParens") + return self.visit(ctx.joinExpr()) def visitJoinExprCrossOp(self, ctx: HogQLParser.JoinExprCrossOpContext): raise NotImplementedError(f"Unsupported node: JoinExprCrossOp") def visitJoinOpInner(self, ctx: HogQLParser.JoinOpInnerContext): - raise NotImplementedError(f"Unsupported node: JoinOpInner") + tokens = [] + if ctx.LEFT(): + tokens.append("INNER") + if ctx.ALL(): + tokens.append("ALL") + if ctx.ANTI(): + tokens.append("ANTI") + if ctx.ANY(): + tokens.append("ANY") + if ctx.ASOF(): + tokens.append("ASOF") + return " ".join(tokens) def visitJoinOpLeftRight(self, ctx: HogQLParser.JoinOpLeftRightContext): - raise NotImplementedError(f"Unsupported node: JoinOpLeftRight") + tokens = [] + if ctx.LEFT(): + tokens.append("LEFT") + if ctx.RIGHT(): + tokens.append("RIGHT") + if ctx.OUTER(): + tokens.append("OUTER") + if ctx.SEMI(): + tokens.append("SEMI") + if ctx.ALL(): + tokens.append("ALL") + if ctx.ANTI(): + tokens.append("ANTI") + if ctx.ANY(): + tokens.append("ANY") + if ctx.ASOF(): + tokens.append("ASOF") + return " ".join(tokens) def visitJoinOpFull(self, ctx: HogQLParser.JoinOpFullContext): - raise NotImplementedError(f"Unsupported node: JoinOpFull") + tokens = [] + if ctx.LEFT(): + tokens.append("FULL") + if ctx.OUTER(): + tokens.append("OUTER") + if ctx.ALL(): + tokens.append("ALL") + if ctx.ANY(): + tokens.append("ANY") + return " ".join(tokens) def visitJoinOpCross(self, ctx: HogQLParser.JoinOpCrossContext): raise NotImplementedError(f"Unsupported node: JoinOpCross") def visitJoinConstraintClause(self, ctx: HogQLParser.JoinConstraintClauseContext): - raise NotImplementedError(f"Unsupported node: JoinConstraintClause") + if ctx.USING(): + raise NotImplementedError(f"Unsupported: JOIN ... USING") + column_expr_list = self.visit(ctx.columnExprList()) + if len(column_expr_list) != 1: + raise NotImplementedError(f"Unsupported: JOIN ... ON with multiple expressions") + return column_expr_list[0] def visitSampleClause(self, ctx: HogQLParser.SampleClauseContext): raise NotImplementedError(f"Unsupported node: SampleClause") @@ -122,10 +254,11 @@ def visitLimitExpr(self, ctx: HogQLParser.LimitExprContext): raise NotImplementedError(f"Unsupported node: LimitExpr") def visitOrderExprList(self, ctx: HogQLParser.OrderExprListContext): - raise NotImplementedError(f"Unsupported node: OrderExprList") + return [self.visit(expr) for expr in ctx.orderExpr()] def visitOrderExpr(self, ctx: HogQLParser.OrderExprContext): - raise NotImplementedError(f"Unsupported node: OrderExpr") + order = "DESC" if ctx.DESC() or ctx.DESCENDING() else "ASC" + return ast.OrderExpr(expr=self.visit(ctx.columnExpr()), order=cast(Literal["ASC", "DESC"], order)) def visitRatioExpr(self, ctx: HogQLParser.RatioExprContext): raise NotImplementedError(f"Unsupported node: RatioExpr") @@ -209,7 +342,7 @@ def visitColumnExprNegate(self, ctx: HogQLParser.ColumnExprNegateContext): raise NotImplementedError(f"Unsupported node: ColumnExprNegate") def visitColumnExprSubquery(self, ctx: HogQLParser.ColumnExprSubqueryContext): - raise NotImplementedError(f"Unsupported node: ColumnExprSubquery") + return self.visit(ctx.selectUnionStmt()) def visitColumnExprLiteral(self, ctx: HogQLParser.ColumnExprLiteralContext): return self.visitChildren(ctx) @@ -410,17 +543,17 @@ def visitColumnIdentifier(self, ctx: HogQLParser.ColumnIdentifierContext): return ast.Field(chain=table + nested) def visitNestedIdentifier(self, ctx: HogQLParser.NestedIdentifierContext): - chain = [self.visit(identifier) for identifier in ctx.identifier()] - return chain + return [self.visit(identifier) for identifier in ctx.identifier()] def visitTableExprIdentifier(self, ctx: HogQLParser.TableExprIdentifierContext): - raise NotImplementedError(f"Unsupported node: TableExprIdentifier") + chain = self.visit(ctx.tableIdentifier()) + return ast.Field(chain=chain) def visitTableExprSubquery(self, ctx: HogQLParser.TableExprSubqueryContext): - raise NotImplementedError(f"Unsupported node: TableExprSubquery") + return self.visit(ctx.selectUnionStmt()) def visitTableExprAlias(self, ctx: HogQLParser.TableExprAliasContext): - raise NotImplementedError(f"Unsupported node: TableExprAlias") + return ast.JoinExpr(table=self.visit(ctx.tableExpr()), alias=self.visit(ctx.alias() or ctx.identifier())) def visitTableExprFunction(self, ctx: HogQLParser.TableExprFunctionContext): raise NotImplementedError(f"Unsupported node: TableExprFunction") diff --git a/posthog/hogql/printer.py b/posthog/hogql/printer.py index 61c2ee7020d1b..dfba9de265867 100644 --- a/posthog/hogql/printer.py +++ b/posthog/hogql/printer.py @@ -7,6 +7,7 @@ EVENT_PERSON_FIELDS, HOGQL_AGGREGATIONS, KEYWORDS, + MAX_SELECT_RETURNED_ROWS, SELECT_STAR_FROM_EVENTS_FIELDS, ) from posthog.hogql.context import HogQLContext, HogQLFieldAccess @@ -14,13 +15,83 @@ from posthog.hogql.print_string import print_hogql_identifier +def guard_where_team_id(where: ast.Expr, context: HogQLContext) -> ast.Expr: + """Add a mandatory "and(team_id, ...)" filter around the expression.""" + if not context.select_team_id: + raise ValueError("context.select_team_id not found") + + from posthog.hogql.parser import parse_expr + + team_clause = parse_expr("team_id = {team_id}", {"team_id": ast.Constant(value=context.select_team_id)}) + if isinstance(where, ast.And): + where = ast.And(exprs=[team_clause] + where.exprs) + elif where: + where = ast.And(exprs=[team_clause, where]) + else: + where = team_clause + return where + + def print_ast( node: ast.AST, stack: List[ast.AST], context: HogQLContext, dialect: Literal["hogql", "clickhouse"] ) -> str: """Translate a parsed HogQL expression in the shape of a Python AST into a Clickhouse expression.""" stack.append(node) - if isinstance(node, ast.BinaryOperation): + if isinstance(node, ast.SelectQuery): + if dialect == "clickhouse" and not context.select_team_id: + raise ValueError("Full SELECT queries are disabled if select_team_id is not set") + + columns = [print_ast(column, stack, context, dialect) for column in node.select] if node.select else ["1"] + + from_table = None + if node.select_from: + if node.select_from.alias is not None: + raise ValueError("Table aliases not yet supported") + if isinstance(node.select_from.table, ast.Field): + if node.select_from.table.chain != ["events"]: + raise ValueError('Only selecting from the "events" table is supported') + from_table = "events" + elif isinstance(node.select_from.table, ast.SelectQuery): + from_table = f"({print_ast(node.select_from.table, stack, context, dialect)})" + else: + raise ValueError("Only selecting from a table or a subquery is supported") + + where = node.where + # Guard with team_id if selecting from the events table and printing ClickHouse SQL + # We do this in the printer, and not in a separate step, to be really sure this gets added. + if dialect == "clickhouse" and from_table == "events": + where = guard_where_team_id(where, context) + where = print_ast(where, stack, context, dialect) if where else None + + having = print_ast(node.having, stack, context, dialect) if node.having else None + prewhere = print_ast(node.prewhere, stack, context, dialect) if node.prewhere else None + group_by = [print_ast(column, stack, context, dialect) for column in node.group_by] if node.group_by else None + order_by = [print_ast(column, stack, context, dialect) for column in node.order_by] if node.order_by else None + + limit = node.limit + if context.limit_top_select: + if limit is not None: + limit = max(0, min(node.limit, MAX_SELECT_RETURNED_ROWS)) + if len(stack) == 1 and limit is None: + limit = MAX_SELECT_RETURNED_ROWS + + clauses = [ + f"SELECT {'DISTINCT ' if node.distinct else ''}{', '.join(columns)}", + f"FROM {from_table}" if from_table else None, + "WHERE " + where if where else None, + f"GROUP BY {', '.join(group_by)}" if group_by and len(group_by) > 0 else None, + "HAVING " + having if having else None, + "PREWHERE " + prewhere if prewhere else None, + f"ORDER BY {', '.join(order_by)}" if order_by and len(order_by) > 0 else None, + f"LIMIT {limit}" if limit is not None else None, + f"OFFSET {node.offset}" if node.offset is not None else None, + ] + response = " ".join([clause for clause in clauses if clause]) + if len(stack) > 1: + response = f"({response})" + + elif isinstance(node, ast.BinaryOperation): if node.op == ast.BinaryOperationType.Add: response = f"plus({print_ast(node.left, stack, context, dialect)}, {print_ast(node.right, stack, context, dialect)})" elif node.op == ast.BinaryOperationType.Sub: diff --git a/posthog/hogql/test/test_parser.py b/posthog/hogql/test/test_parser.py index dfe0d7b169d36..2c6b34a4e5719 100644 --- a/posthog/hogql/test/test_parser.py +++ b/posthog/hogql/test/test_parser.py @@ -1,5 +1,5 @@ from posthog.hogql import ast -from posthog.hogql.parser import parse_expr +from posthog.hogql.parser import parse_expr, parse_select from posthog.test.base import BaseTest @@ -354,3 +354,239 @@ def test_placeholders(self): right=ast.Constant(value=123), ), ) + + def test_select_columns(self): + self.assertEqual(parse_select("select 1"), ast.SelectQuery(select=[ast.Constant(value=1)])) + self.assertEqual( + parse_select("select 1, 4, 'string'"), + ast.SelectQuery(select=[ast.Constant(value=1), ast.Constant(value=4), ast.Constant(value="string")]), + ) + + def test_select_columns_distinct(self): + self.assertEqual( + parse_select("select distinct 1"), ast.SelectQuery(select=[ast.Constant(value=1)], distinct=True) + ) + + def test_select_where(self): + self.assertEqual( + parse_select("select 1 where true"), + ast.SelectQuery(select=[ast.Constant(value=1)], where=ast.Constant(value=True)), + ) + self.assertEqual( + parse_select("select 1 where 1 == 2"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + where=ast.CompareOperation( + op=ast.CompareOperationType.Eq, left=ast.Constant(value=1), right=ast.Constant(value=2) + ), + ), + ) + + def test_select_prewhere(self): + self.assertEqual( + parse_select("select 1 prewhere true"), + ast.SelectQuery(select=[ast.Constant(value=1)], prewhere=ast.Constant(value=True)), + ) + self.assertEqual( + parse_select("select 1 prewhere 1 == 2"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + prewhere=ast.CompareOperation( + op=ast.CompareOperationType.Eq, left=ast.Constant(value=1), right=ast.Constant(value=2) + ), + ), + ) + + def test_select_having(self): + self.assertEqual( + parse_select("select 1 having true"), + ast.SelectQuery(select=[ast.Constant(value=1)], having=ast.Constant(value=True)), + ) + self.assertEqual( + parse_select("select 1 having 1 == 2"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + having=ast.CompareOperation( + op=ast.CompareOperationType.Eq, left=ast.Constant(value=1), right=ast.Constant(value=2) + ), + ), + ) + + def test_select_complex_wheres(self): + self.assertEqual( + parse_select("select 1 prewhere 2 != 3 where 1 == 2 having 'string' like '%a%'"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + where=ast.CompareOperation( + op=ast.CompareOperationType.Eq, left=ast.Constant(value=1), right=ast.Constant(value=2) + ), + prewhere=ast.CompareOperation( + op=ast.CompareOperationType.NotEq, left=ast.Constant(value=2), right=ast.Constant(value=3) + ), + having=ast.CompareOperation( + op=ast.CompareOperationType.Like, left=ast.Constant(value="string"), right=ast.Constant(value="%a%") + ), + ), + ) + + def test_select_from(self): + self.assertEqual( + parse_select("select 1 from events"), + ast.SelectQuery( + select=[ast.Constant(value=1)], select_from=ast.JoinExpr(table=ast.Field(chain=["events"])) + ), + ) + self.assertEqual( + parse_select("select 1 from events as e"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr(table=ast.Field(chain=["events"]), alias="e"), + ), + ) + self.assertEqual( + parse_select("select 1 from complex.table"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr(table=ast.Field(chain=["complex", "table"])), + ), + ) + self.assertEqual( + parse_select("select 1 from complex.table as a"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr(table=ast.Field(chain=["complex", "table"]), alias="a"), + ), + ) + self.assertEqual( + parse_select("select 1 from (select 1 from events)"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr( + table=ast.SelectQuery( + select=[ast.Constant(value=1)], select_from=ast.JoinExpr(table=ast.Field(chain=["events"])) + ) + ), + ), + ) + self.assertEqual( + parse_select("select 1 from (select 1 from events) as sq"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr( + table=ast.SelectQuery( + select=[ast.Constant(value=1)], select_from=ast.JoinExpr(table=ast.Field(chain=["events"])) + ), + alias="sq", + ), + ), + ) + + def test_select_from_join(self): + self.assertEqual( + parse_select("select 1 from events JOIN events2 ON 1"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr( + table=ast.Field(chain=["events"]), + join_type="JOIN", + join_constraint=ast.Constant(value=1), + join_expr=ast.JoinExpr(table=ast.Field(chain=["events2"])), + ), + ), + ) + self.assertEqual( + parse_select("select * from events LEFT OUTER JOIN events2 ON 1"), + ast.SelectQuery( + select=[ast.Field(chain=["*"])], + select_from=ast.JoinExpr( + table=ast.Field(chain=["events"]), + join_type="LEFT OUTER JOIN", + join_constraint=ast.Constant(value=1), + join_expr=ast.JoinExpr(table=ast.Field(chain=["events2"])), + ), + ), + ) + self.assertEqual( + parse_select("select 1 from events LEFT OUTER JOIN events2 ON 1 ANY RIGHT JOIN events3 ON 2"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr( + table=ast.Field(chain=["events"]), + join_type="LEFT OUTER JOIN", + join_constraint=ast.Constant(value=1), + join_expr=ast.JoinExpr( + table=ast.Field(chain=["events2"]), + join_type="RIGHT ANY JOIN", + join_constraint=ast.Constant(value=2), + join_expr=ast.JoinExpr(table=ast.Field(chain=["events3"])), + ), + ), + ), + ) + + def test_select_group_by(self): + self.assertEqual( + parse_select("select 1 from events GROUP BY 1, event"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), + group_by=[ast.Constant(value=1), ast.Field(chain=["event"])], + ), + ) + + def test_select_order_by(self): + self.assertEqual( + parse_select("select 1 from events ORDER BY 1 ASC, event, timestamp DESC"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), + order_by=[ + ast.OrderExpr(expr=ast.Constant(value=1), order="ASC"), + ast.OrderExpr(expr=ast.Field(chain=["event"]), order="ASC"), + ast.OrderExpr(expr=ast.Field(chain=["timestamp"]), order="DESC"), + ], + ), + ) + + def test_select_limit_offset(self): + self.assertEqual( + parse_select("select 1 from events LIMIT 1"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), + limit=1, + ), + ) + self.assertEqual( + parse_select("select 1 from events LIMIT 1 OFFSET 3"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), + limit=1, + offset=3, + ), + ) + + def test_select_placeholders(self): + self.assertEqual( + parse_select("select 1 where 1 == {hogql_val_1}"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + where=ast.CompareOperation( + op=ast.CompareOperationType.Eq, + left=ast.Constant(value=1), + right=ast.Placeholder(field="hogql_val_1"), + ), + ), + ) + self.assertEqual( + parse_select("select 1 where 1 == {hogql_val_1}", {"hogql_val_1": ast.Constant(value="bar")}), + ast.SelectQuery( + select=[ast.Constant(value=1)], + where=ast.CompareOperation( + op=ast.CompareOperationType.Eq, + left=ast.Constant(value=1), + right=ast.Constant(value="bar"), + ), + ), + ) diff --git a/posthog/hogql/test/test_printer.py b/posthog/hogql/test/test_printer.py index 80e15dcb5f3d2..ded3198704c69 100644 --- a/posthog/hogql/test/test_printer.py +++ b/posthog/hogql/test/test_printer.py @@ -13,6 +13,12 @@ def _expr( ) -> str: return translate_hogql(query, context or HogQLContext(), dialect) + # Helper to always translate HogQL with a blank context, + def _select( + self, query: str, context: Optional[HogQLContext] = None, dialect: Literal["hogql", "clickhouse"] = "clickhouse" + ) -> str: + return translate_hogql(query, context or HogQLContext(select_team_id=42), dialect) + def _assert_expr_error(self, expr, expected_error, dialect: Literal["hogql", "clickhouse"] = "clickhouse"): with self.assertRaises(ValueError) as context: self._expr(expr, None, dialect) @@ -20,6 +26,13 @@ def _assert_expr_error(self, expr, expected_error, dialect: Literal["hogql", "cl raise AssertionError(f"Expected '{expected_error}' in '{str(context.exception)}'") self.assertTrue(expected_error in str(context.exception)) + def _assert_select_error(self, statement, expected_error, dialect: Literal["hogql", "clickhouse"] = "clickhouse"): + with self.assertRaises(ValueError) as context: + self._select(statement, None, dialect) + if expected_error not in str(context.exception): + raise AssertionError(f"Expected '{expected_error}' in '{str(context.exception)}'") + self.assertTrue(expected_error in str(context.exception)) + def test_literals(self): self.assertEqual(self._expr("1 + 2"), "plus(1, 2)") self.assertEqual(self._expr("-1 + 2"), "plus(-1, 2)") @@ -330,3 +343,87 @@ def test_values(self): def test_no_alias_yet(self): self._assert_expr_error("1 as team_id", "Unknown AST node Alias") self._assert_expr_error("1 as `-- select team_id`", "Unknown AST node Alias") + + def test_select(self): + self.assertEqual(self._select("select 1"), "SELECT 1 LIMIT 65535") + self.assertEqual(self._select("select 1 + 2"), "SELECT plus(1, 2) LIMIT 65535") + self.assertEqual(self._select("select 1 + 2, 3"), "SELECT plus(1, 2), 3 LIMIT 65535") + self.assertEqual( + self._select("select 1 + 2, 3 + 4 from events"), + "SELECT plus(1, 2), plus(3, 4) FROM events WHERE equals(team_id, 42) LIMIT 65535", + ) + + def test_select_alias(self): + # currently not supported! + self._assert_select_error("select 1 as b", "Unknown AST node Alias") + self._assert_select_error("select 1 from events as e", "Table aliases not yet supported") + + def test_select_from(self): + self.assertEqual( + self._select("select 1 from events"), "SELECT 1 FROM events WHERE equals(team_id, 42) LIMIT 65535" + ) + self._assert_select_error("select 1 from other", 'Only selecting from the "events" table is supported') + + def test_select_where(self): + self.assertEqual( + self._select("select 1 from events where 1 == 2"), + "SELECT 1 FROM events WHERE and(equals(team_id, 42), equals(1, 2)) LIMIT 65535", + ) + + def test_select_having(self): + self.assertEqual( + self._select("select 1 from events having 1 == 2"), + "SELECT 1 FROM events WHERE equals(team_id, 42) HAVING equals(1, 2) LIMIT 65535", + ) + + def test_select_prewhere(self): + self.assertEqual( + self._select("select 1 from events prewhere 1 == 2"), + "SELECT 1 FROM events WHERE equals(team_id, 42) PREWHERE equals(1, 2) LIMIT 65535", + ) + + def test_select_order_by(self): + self.assertEqual( + self._select("select event from events order by event"), + "SELECT event FROM events WHERE equals(team_id, 42) ORDER BY event ASC LIMIT 65535", + ) + self.assertEqual( + self._select("select event from events order by event desc"), + "SELECT event FROM events WHERE equals(team_id, 42) ORDER BY event DESC LIMIT 65535", + ) + self.assertEqual( + self._select("select event from events order by event desc, timestamp"), + "SELECT event FROM events WHERE equals(team_id, 42) ORDER BY event DESC, timestamp ASC LIMIT 65535", + ) + + def test_select_limit(self): + self.assertEqual( + self._select("select event from events limit 10"), + "SELECT event FROM events WHERE equals(team_id, 42) LIMIT 10", + ) + self.assertEqual( + self._select("select event from events limit 10000000"), + "SELECT event FROM events WHERE equals(team_id, 42) LIMIT 65535", + ) + + def test_select_offset(self): + self.assertEqual( + self._select("select event from events limit 10 offset 10"), + "SELECT event FROM events WHERE equals(team_id, 42) LIMIT 10 OFFSET 10", + ) + self.assertEqual( + self._select("select event from events limit 10 offset 0"), + "SELECT event FROM events WHERE equals(team_id, 42) LIMIT 10 OFFSET 0", + ) + + def test_select_group_by(self): + self.assertEqual( + self._select("select event from events group by event, timestamp"), + "SELECT event FROM events WHERE equals(team_id, 42) GROUP BY event, timestamp LIMIT 65535", + ) + + def test_select_distinct(self): + self.assertEqual( + self._select("select distinct event from events group by event, timestamp"), + "SELECT DISTINCT event FROM events WHERE equals(team_id, 42) GROUP BY event, timestamp LIMIT 65535", + ) diff --git a/posthog/models/event/query_event_list.py b/posthog/models/event/query_event_list.py index 847369a2fc951..878bf00e4ed32 100644 --- a/posthog/models/event/query_event_list.py +++ b/posthog/models/event/query_event_list.py @@ -4,7 +4,6 @@ from dateutil.parser import isoparse from django.utils.timezone import now -from pydantic import BaseModel from posthog.api.utils import get_pk_or_uuid from posthog.clickhouse.client.connection import Workload @@ -22,7 +21,7 @@ from posthog.models.event.util import ElementSerializer from posthog.models.property.util import parse_prop_grouped_clauses from posthog.queries.insight import insight_query_with_columns, insight_sync_execute -from posthog.schema import EventsQuery +from posthog.schema import EventsQuery, EventsQueryResponse from posthog.utils import relative_date_parse # Return at most this number of events in CSV export @@ -31,13 +30,6 @@ QUERY_MAXIMUM_LIMIT = 100_000 -class EventsQueryResponse(BaseModel): - columns: List[str] - types: List[str] - results: List[List] - hasMore: bool - - def determine_event_conditions(conditions: Dict[str, Union[None, str, List[str]]]) -> Tuple[str, Dict]: result = "" params: Dict[str, Union[str, List[str]]] = {} diff --git a/posthog/schema.py b/posthog/schema.py index 28bad7dd7ad5e..a9c22bf6e7321 100644 --- a/posthog/schema.py +++ b/posthog/schema.py @@ -176,11 +176,11 @@ class Config: results: List[EventType] -class Response1(BaseModel): +class EventsQueryResponse(BaseModel): class Config: extra = Extra.forbid - columns: List[str] + columns: List hasMore: Optional[bool] = None results: List[List] types: List[str] @@ -668,7 +668,7 @@ class Config: ] ] ] = Field(None, description="Properties configurable in the interface") - response: Optional[Response1] = Field(None, description="Cached query response") + response: Optional[EventsQueryResponse] = Field(None, description="Cached query response") select: List[str] = Field(..., description="Return a limited set of data. Required.") where: Optional[List[str]] = Field(None, description="HogQL filters to apply on returned data") From a87115f5fa42eb0fa7441fbae6a7b3033c6ed7bf Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Wed, 8 Feb 2023 15:16:35 +0100 Subject: [PATCH 2/7] visitor --- posthog/hogql/hogql.py | 7 +++++-- posthog/hogql/test/test_visitor.py | 24 ++++++++++++++++++++++++ posthog/hogql/visitor.py | 26 ++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/posthog/hogql/hogql.py b/posthog/hogql/hogql.py index 81257157e08db..dc16b3cf8e9f6 100644 --- a/posthog/hogql/hogql.py +++ b/posthog/hogql/hogql.py @@ -1,7 +1,7 @@ from typing import Literal from posthog.hogql.context import HogQLContext -from posthog.hogql.parser import parse_expr +from posthog.hogql.parser import parse_expr, parse_select from posthog.hogql.printer import print_ast @@ -11,7 +11,10 @@ def translate_hogql(query: str, context: HogQLContext, dialect: Literal["hogql", raise ValueError("Empty query") try: - node = parse_expr(query) + if context.select_team_id: + node = parse_select(query) + else: + node = parse_expr(query) except SyntaxError as err: raise ValueError(f"SyntaxError: {err.msg}") except NotImplementedError as err: diff --git a/posthog/hogql/test/test_visitor.py b/posthog/hogql/test/test_visitor.py index 42857388f890d..f60812f53aab8 100644 --- a/posthog/hogql/test/test_visitor.py +++ b/posthog/hogql/test/test_visitor.py @@ -65,6 +65,30 @@ def test_everything_visitor(self): ], ) ), + ast.Alias(expr=ast.SelectQuery(select=[ast.Field(chain=["timestamp"])]), alias="f"), + ast.SelectQuery( + select=[ast.Field(chain=["a"])], + select_from=ast.JoinExpr( + table=ast.Field(chain=["b"]), + table_final=True, + alias="c", + join_type="INNER", + join_constraint=ast.CompareOperation( + op=ast.CompareOperationType.Eq, + left=ast.Field(chain=["d"]), + right=ast.Field(chain=["e"]), + ), + join_expr=ast.JoinExpr(table=ast.Field(chain=["f"])), + ), + where=ast.Constant(value=True), + prewhere=ast.Constant(value=True), + having=ast.Constant(value=True), + group_by=[ast.Constant(value=True)], + order_by=[ast.OrderExpr(expr=ast.Constant(value=True), order="DESC")], + limit=1, + offset=0, + distinct=True, + ), ] ) self.assertEqual(node, EverythingVisitor().visit(node)) diff --git a/posthog/hogql/visitor.py b/posthog/hogql/visitor.py index e36ec7d6af6e4..1bca4d05a78f4 100644 --- a/posthog/hogql/visitor.py +++ b/posthog/hogql/visitor.py @@ -3,6 +3,8 @@ class Visitor(object): def visit(self, node: ast.AST): + if node is None: + return node return node.accept(self) @@ -59,3 +61,27 @@ def visit_call(self, call: ast.Call): name=call.name, args=[self.visit(arg) for arg in call.args], ) + + def visit_join_expr(self, node: ast.JoinExpr): + return ast.JoinExpr( + table=self.visit(node.table), + join_expr=self.visit(node.join_expr), + table_final=node.table_final, + alias=node.alias, + join_type=node.join_type, + join_constraint=self.visit(node.join_constraint), + ) + + def visit_select_query(self, node: ast.SelectQuery): + return ast.SelectQuery( + select=[self.visit(expr) for expr in node.select] if node.select else None, + select_from=self.visit(node.select_from), + where=self.visit(node.where), + prewhere=self.visit(node.prewhere), + having=self.visit(node.having), + group_by=[self.visit(expr) for expr in node.group_by] if node.group_by else None, + order_by=[self.visit(expr) for expr in node.order_by] if node.order_by else None, + limit=node.limit, + offset=node.offset, + distinct=node.distinct, + ) From c55f170b9c26f3f6cf5329b0637b4fc30c9ac9ec Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Wed, 8 Feb 2023 15:23:08 +0100 Subject: [PATCH 3/7] cleanup --- posthog/hogql/printer.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/posthog/hogql/printer.py b/posthog/hogql/printer.py index dfba9de265867..d07599d080e21 100644 --- a/posthog/hogql/printer.py +++ b/posthog/hogql/printer.py @@ -20,8 +20,6 @@ def guard_where_team_id(where: ast.Expr, context: HogQLContext) -> ast.Expr: if not context.select_team_id: raise ValueError("context.select_team_id not found") - from posthog.hogql.parser import parse_expr - team_clause = parse_expr("team_id = {team_id}", {"team_id": ast.Constant(value=context.select_team_id)}) if isinstance(where, ast.And): where = ast.And(exprs=[team_clause] + where.exprs) @@ -58,9 +56,10 @@ def print_ast( raise ValueError("Only selecting from a table or a subquery is supported") where = node.where - # Guard with team_id if selecting from the events table and printing ClickHouse SQL + # Guard with team_id if selecting from a table and printing ClickHouse SQL # We do this in the printer, and not in a separate step, to be really sure this gets added. - if dialect == "clickhouse" and from_table == "events": + # This will be improved when we add proper table and column alias support. For now, let's just be safe. + if dialect == "clickhouse" and from_table is not None: where = guard_where_team_id(where, context) where = print_ast(where, stack, context, dialect) if where else None From d47bc616d9905a56ba540df096858cf5ce68f59b Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Wed, 8 Feb 2023 16:03:43 +0100 Subject: [PATCH 4/7] parse limit by --- posthog/hogql/ast.py | 8 ++-- posthog/hogql/parser.py | 64 ++++++++++++------------------- posthog/hogql/test/test_parser.py | 26 +++++++++++-- 3 files changed, 52 insertions(+), 46 deletions(-) diff --git a/posthog/hogql/ast.py b/posthog/hogql/ast.py index b43b558fccc23..012a9b9a8b57a 100644 --- a/posthog/hogql/ast.py +++ b/posthog/hogql/ast.py @@ -115,15 +115,17 @@ class JoinExpr(Expr): class SelectQuery(Expr): select: List[Expr] + distinct: Optional[bool] = None select_from: Optional[JoinExpr] = None where: Optional[Expr] = None prewhere: Optional[Expr] = None having: Optional[Expr] = None group_by: Optional[List[Expr]] = None order_by: Optional[List[OrderExpr]] = None - limit: Optional[int] = None - offset: Optional[int] = None - distinct: Optional[bool] = None + limit: Optional[Expr] = None + limit_by: Optional[List[Expr]] = None + limit_with_ties: Optional[bool] = None + offset: Optional[Expr] = None JoinExpr.update_forward_refs(SelectQuery=SelectQuery) diff --git a/posthog/hogql/parser.py b/posthog/hogql/parser.py index b1891dddad6fe..f393769960196 100644 --- a/posthog/hogql/parser.py +++ b/posthog/hogql/parser.py @@ -55,31 +55,28 @@ def visitSelectStmtWithParens(self, ctx: HogQLParser.SelectStmtWithParensContext return self.visit(ctx.selectStmt() or ctx.selectUnionStmt()) def visitSelectStmt(self, ctx: HogQLParser.SelectStmtContext): - select = self.visit(ctx.columnExprList()) if ctx.columnExprList() else [] - select_from = self.visit(ctx.fromClause()) if ctx.fromClause() else None - where = self.visit(ctx.whereClause()) if ctx.whereClause() else None - prewhere = self.visit(ctx.prewhereClause()) if ctx.prewhereClause() else None - having = self.visit(ctx.havingClause()) if ctx.havingClause() else None - group_by = self.visit(ctx.groupByClause()) if ctx.groupByClause() else None - order_by = self.visit(ctx.orderByClause()) if ctx.orderByClause() else None - - limit = None - offset = None - if ctx.limitClause() and ctx.limitClause().limitExpr(): - limit_expr = ctx.limitClause().limitExpr() - limit_node = self.visit(limit_expr.columnExpr(0)) - if limit_node is not None: - if isinstance(limit_node, ast.Constant) and isinstance(limit_node.value, int): - limit = limit_node.value - else: - raise Exception(f"LIMIT must be an integer") + select_query = ast.SelectQuery( + select=self.visit(ctx.columnExprList()) if ctx.columnExprList() else [], + distinct=True if ctx.DISTINCT() else None, + select_from=self.visit(ctx.fromClause()) if ctx.fromClause() else None, + where=self.visit(ctx.whereClause()) if ctx.whereClause() else None, + prewhere=self.visit(ctx.prewhereClause()) if ctx.prewhereClause() else None, + having=self.visit(ctx.havingClause()) if ctx.havingClause() else None, + group_by=self.visit(ctx.groupByClause()) if ctx.groupByClause() else None, + order_by=self.visit(ctx.orderByClause()) if ctx.orderByClause() else None, + ) + + any_limit_clause = ctx.limitClause() or ctx.limitByClause() + if any_limit_clause and any_limit_clause.limitExpr(): + limit_expr = any_limit_clause.limitExpr() + if limit_expr.columnExpr(0): + select_query.limit = self.visit(limit_expr.columnExpr(0)) if limit_expr.columnExpr(1): - offset_node = self.visit(limit_expr.columnExpr(1)) - if offset_node is not None: - if isinstance(offset_node, ast.Constant) and isinstance(offset_node.value, int): - offset = offset_node.value - else: - raise Exception(f"OFFSET must be an integer") + select_query.offset = self.visit(limit_expr.columnExpr(1)) + if ctx.limitClause() and ctx.limitClause().WITH() and ctx.limitClause().TIES(): + select_query.limit_with_ties = True + if ctx.limitByClause() and ctx.limitByClause().columnExprList(): + select_query.limit_by = self.visit(ctx.limitByClause().columnExprList()) if ctx.withClause(): raise NotImplementedError(f"Unsupported: SelectStmt.withClause()") @@ -89,23 +86,10 @@ def visitSelectStmt(self, ctx: HogQLParser.SelectStmtContext): raise NotImplementedError(f"Unsupported: SelectStmt.arrayJoinClause()") if ctx.windowClause(): raise NotImplementedError(f"Unsupported: SelectStmt.windowClause()") - if ctx.limitByClause(): - raise NotImplementedError(f"Unsupported: SelectStmt.limitByClause()") if ctx.settingsClause(): raise NotImplementedError(f"Unsupported: SelectStmt.settingsClause()") - return ast.SelectQuery( - select=select, - distinct=True if ctx.DISTINCT() else None, - select_from=select_from, - where=where, - prewhere=prewhere, - having=having, - group_by=group_by, - order_by=order_by, - limit=limit, - offset=offset, - ) + return select_query def visitWithClause(self, ctx: HogQLParser.WithClauseContext): raise NotImplementedError(f"Unsupported node: WithClause") @@ -141,10 +125,10 @@ def visitProjectionOrderByClause(self, ctx: HogQLParser.ProjectionOrderByClauseC raise NotImplementedError(f"Unsupported node: ProjectionOrderByClause") def visitLimitByClause(self, ctx: HogQLParser.LimitByClauseContext): - raise NotImplementedError(f"Unsupported node: LimitByClause") + raise Exception(f"Parsed as part of SelectStmt, can't parse directly.") def visitLimitClause(self, ctx: HogQLParser.LimitClauseContext): - raise NotImplementedError(f"Unsupported node: LimitClause") + raise Exception(f"Parsed as part of SelectStmt, can't parse directly.") def visitSettingsClause(self, ctx: HogQLParser.SettingsClauseContext): raise NotImplementedError(f"Unsupported node: SettingsClause") diff --git a/posthog/hogql/test/test_parser.py b/posthog/hogql/test/test_parser.py index 2c6b34a4e5719..55d943a1d197e 100644 --- a/posthog/hogql/test/test_parser.py +++ b/posthog/hogql/test/test_parser.py @@ -554,7 +554,7 @@ def test_select_limit_offset(self): ast.SelectQuery( select=[ast.Constant(value=1)], select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), - limit=1, + limit=ast.Constant(value=1), ), ) self.assertEqual( @@ -562,8 +562,28 @@ def test_select_limit_offset(self): ast.SelectQuery( select=[ast.Constant(value=1)], select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), - limit=1, - offset=3, + limit=ast.Constant(value=1), + offset=ast.Constant(value=3), + ), + ) + self.assertEqual( + parse_select("select 1 from events LIMIT 1 OFFSET 3 WITH TIES"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), + limit=ast.Constant(value=1), + limit_with_ties=True, + offset=ast.Constant(value=3), + ), + ) + self.assertEqual( + parse_select("select 1 from events LIMIT 1 OFFSET 3 BY 1, event"), + ast.SelectQuery( + select=[ast.Constant(value=1)], + select_from=ast.JoinExpr(table=ast.Field(chain=["events"])), + limit=ast.Constant(value=1), + offset=ast.Constant(value=3), + limit_by=[ast.Constant(value=1), ast.Field(chain=["event"])], ), ) From 839d5059b60a3fb5efab513c44b84741d4f2675c Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Wed, 8 Feb 2023 16:16:18 +0100 Subject: [PATCH 5/7] parse limit by --- posthog/hogql/printer.py | 20 +++++++++++++++----- posthog/hogql/test/test_printer.py | 19 +++++++++++++++++++ posthog/hogql/test/test_visitor.py | 6 ++++-- posthog/hogql/visitor.py | 6 ++++-- 4 files changed, 42 insertions(+), 9 deletions(-) diff --git a/posthog/hogql/printer.py b/posthog/hogql/printer.py index d07599d080e21..e2ebe83dc4d23 100644 --- a/posthog/hogql/printer.py +++ b/posthog/hogql/printer.py @@ -71,9 +71,12 @@ def print_ast( limit = node.limit if context.limit_top_select: if limit is not None: - limit = max(0, min(node.limit, MAX_SELECT_RETURNED_ROWS)) - if len(stack) == 1 and limit is None: - limit = MAX_SELECT_RETURNED_ROWS + if isinstance(limit, ast.Constant) and isinstance(limit.value, int): + limit.value = min(limit.value, MAX_SELECT_RETURNED_ROWS) + else: + limit = ast.Call(name="min2", args=[ast.Constant(value=MAX_SELECT_RETURNED_ROWS), limit]) + elif len(stack) == 1: + limit = ast.Constant(value=MAX_SELECT_RETURNED_ROWS) clauses = [ f"SELECT {'DISTINCT ' if node.distinct else ''}{', '.join(columns)}", @@ -83,9 +86,16 @@ def print_ast( "HAVING " + having if having else None, "PREWHERE " + prewhere if prewhere else None, f"ORDER BY {', '.join(order_by)}" if order_by and len(order_by) > 0 else None, - f"LIMIT {limit}" if limit is not None else None, - f"OFFSET {node.offset}" if node.offset is not None else None, ] + if limit is not None: + clauses.append(f"LIMIT {print_ast(limit, stack, context, dialect)}"), + if node.offset is not None: + clauses.append(f"OFFSET {print_ast(node.offset, stack, context, dialect)}") + if node.limit_by is not None: + clauses.append(f"BY {', '.join([print_ast(expr, stack, context, dialect) for expr in node.limit_by])}") + if node.limit_with_ties: + clauses.append("WITH TIES") + response = " ".join([clause for clause in clauses if clause]) if len(stack) > 1: response = f"({response})" diff --git a/posthog/hogql/test/test_printer.py b/posthog/hogql/test/test_printer.py index ded3198704c69..e1e67e8106497 100644 --- a/posthog/hogql/test/test_printer.py +++ b/posthog/hogql/test/test_printer.py @@ -405,6 +405,15 @@ def test_select_limit(self): self._select("select event from events limit 10000000"), "SELECT event FROM events WHERE equals(team_id, 42) LIMIT 65535", ) + self.assertEqual( + self._select("select event from events limit (select 1000000000)"), + "SELECT event FROM events WHERE equals(team_id, 42) LIMIT min2(65535, (SELECT 1000000000))", + ) + + self.assertEqual( + self._select("select event from events limit (select 1000000000) with ties"), + "SELECT event FROM events WHERE equals(team_id, 42) LIMIT min2(65535, (SELECT 1000000000)) WITH TIES", + ) def test_select_offset(self): self.assertEqual( @@ -415,6 +424,16 @@ def test_select_offset(self): self._select("select event from events limit 10 offset 0"), "SELECT event FROM events WHERE equals(team_id, 42) LIMIT 10 OFFSET 0", ) + self.assertEqual( + self._select("select event from events limit 10 offset 0 with ties"), + "SELECT event FROM events WHERE equals(team_id, 42) LIMIT 10 OFFSET 0 WITH TIES", + ) + + def test_select_limit_by(self): + self.assertEqual( + self._select("select event from events limit 10 offset 0 by 1,event"), + "SELECT event FROM events WHERE equals(team_id, 42) LIMIT 10 OFFSET 0 BY 1, event", + ) def test_select_group_by(self): self.assertEqual( diff --git a/posthog/hogql/test/test_visitor.py b/posthog/hogql/test/test_visitor.py index f60812f53aab8..738b4ac3aed12 100644 --- a/posthog/hogql/test/test_visitor.py +++ b/posthog/hogql/test/test_visitor.py @@ -85,8 +85,10 @@ def test_everything_visitor(self): having=ast.Constant(value=True), group_by=[ast.Constant(value=True)], order_by=[ast.OrderExpr(expr=ast.Constant(value=True), order="DESC")], - limit=1, - offset=0, + limit=ast.Constant(value=1), + limit_by=[ast.Constant(value=True)], + limit_with_ties=True, + offset=ast.Or(exprs=[ast.Constant(value=1)]), distinct=True, ), ] diff --git a/posthog/hogql/visitor.py b/posthog/hogql/visitor.py index 1bca4d05a78f4..66365f368bbc1 100644 --- a/posthog/hogql/visitor.py +++ b/posthog/hogql/visitor.py @@ -81,7 +81,9 @@ def visit_select_query(self, node: ast.SelectQuery): having=self.visit(node.having), group_by=[self.visit(expr) for expr in node.group_by] if node.group_by else None, order_by=[self.visit(expr) for expr in node.order_by] if node.order_by else None, - limit=node.limit, - offset=node.offset, + limit_by=[self.visit(expr) for expr in node.limit_by] if node.limit_by else None, + limit=self.visit(node.limit), + limit_with_ties=node.limit_with_ties, + offset=self.visit(node.offset), distinct=node.distinct, ) From fef94635ccaa2fc29568f8b11d15e21d4fb3d668 Mon Sep 17 00:00:00 2001 From: Marius Andra Date: Wed, 8 Feb 2023 16:55:45 +0100 Subject: [PATCH 6/7] merge limit clauses --- posthog/hogql/grammar/HogQLParser.g4 | 4 +- posthog/hogql/grammar/HogQLParser.interp | 3 +- posthog/hogql/grammar/HogQLParser.py | 2164 +++++++++---------- posthog/hogql/grammar/HogQLParserVisitor.py | 5 - posthog/hogql/parser.py | 17 +- posthog/hogql/printer.py | 2 +- 6 files changed, 1063 insertions(+), 1132 deletions(-) diff --git a/posthog/hogql/grammar/HogQLParser.g4 b/posthog/hogql/grammar/HogQLParser.g4 index a2726834f1bca..757cb726f5ce7 100644 --- a/posthog/hogql/grammar/HogQLParser.g4 +++ b/posthog/hogql/grammar/HogQLParser.g4 @@ -21,7 +21,6 @@ selectStmt: groupByClause? (WITH (CUBE | ROLLUP))? (WITH TOTALS)? havingClause? orderByClause? - limitByClause? limitClause? settingsClause? ; @@ -37,8 +36,7 @@ groupByClause: GROUP BY ((CUBE | ROLLUP) LPAREN columnExprList RPAREN | columnEx havingClause: HAVING columnExpr; orderByClause: ORDER BY orderExprList; projectionOrderByClause: ORDER BY columnExprList; -limitByClause: LIMIT limitExpr BY columnExprList; -limitClause: LIMIT limitExpr (WITH TIES)?; +limitClause: LIMIT limitExpr ((WITH TIES) | BY columnExprList)?; settingsClause: SETTINGS settingExprList; joinExpr diff --git a/posthog/hogql/grammar/HogQLParser.interp b/posthog/hogql/grammar/HogQLParser.interp index a48298cae9931..e9aab592cff5b 100644 --- a/posthog/hogql/grammar/HogQLParser.interp +++ b/posthog/hogql/grammar/HogQLParser.interp @@ -488,7 +488,6 @@ groupByClause havingClause orderByClause projectionOrderByClause -limitByClause limitClause settingsClause joinExpr @@ -537,4 +536,4 @@ enumValue atn: -[4, 1, 234, 891, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 2, 60, 7, 60, 1, 0, 1, 0, 3, 0, 125, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 133, 8, 1, 10, 1, 12, 1, 136, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 143, 8, 2, 1, 3, 3, 3, 146, 8, 3, 1, 3, 1, 3, 3, 3, 150, 8, 3, 1, 3, 3, 3, 153, 8, 3, 1, 3, 1, 3, 3, 3, 157, 8, 3, 1, 3, 3, 3, 160, 8, 3, 1, 3, 3, 3, 163, 8, 3, 1, 3, 3, 3, 166, 8, 3, 1, 3, 3, 3, 169, 8, 3, 1, 3, 3, 3, 172, 8, 3, 1, 3, 1, 3, 3, 3, 176, 8, 3, 1, 3, 1, 3, 3, 3, 180, 8, 3, 1, 3, 3, 3, 183, 8, 3, 1, 3, 3, 3, 186, 8, 3, 1, 3, 3, 3, 189, 8, 3, 1, 3, 3, 3, 192, 8, 3, 1, 3, 3, 3, 195, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 204, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 3, 7, 210, 8, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 237, 8, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 259, 8, 16, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 18, 3, 18, 267, 8, 18, 1, 18, 3, 18, 270, 8, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 276, 8, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 1, 18, 3, 18, 284, 8, 18, 1, 18, 3, 18, 287, 8, 18, 1, 18, 1, 18, 1, 18, 1, 18, 5, 18, 293, 8, 18, 10, 18, 12, 18, 296, 9, 18, 1, 19, 3, 19, 299, 8, 19, 1, 19, 1, 19, 1, 19, 3, 19, 304, 8, 19, 1, 19, 3, 19, 307, 8, 19, 1, 19, 3, 19, 310, 8, 19, 1, 19, 1, 19, 3, 19, 314, 8, 19, 1, 19, 1, 19, 3, 19, 318, 8, 19, 1, 19, 3, 19, 321, 8, 19, 3, 19, 323, 8, 19, 1, 19, 3, 19, 326, 8, 19, 1, 19, 1, 19, 3, 19, 330, 8, 19, 1, 19, 1, 19, 3, 19, 334, 8, 19, 1, 19, 3, 19, 337, 8, 19, 3, 19, 339, 8, 19, 3, 19, 341, 8, 19, 1, 20, 3, 20, 344, 8, 20, 1, 20, 1, 20, 1, 20, 3, 20, 349, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 360, 8, 21, 1, 22, 1, 22, 1, 22, 1, 22, 3, 22, 366, 8, 22, 1, 23, 1, 23, 1, 23, 3, 23, 371, 8, 23, 1, 24, 1, 24, 1, 24, 5, 24, 376, 8, 24, 10, 24, 12, 24, 379, 9, 24, 1, 25, 1, 25, 3, 25, 383, 8, 25, 1, 25, 1, 25, 3, 25, 387, 8, 25, 1, 25, 1, 25, 3, 25, 391, 8, 25, 1, 26, 1, 26, 1, 26, 3, 26, 396, 8, 26, 1, 27, 1, 27, 1, 27, 5, 27, 401, 8, 27, 10, 27, 12, 27, 404, 9, 27, 1, 28, 1, 28, 1, 28, 1, 28, 1, 29, 3, 29, 411, 8, 29, 1, 29, 3, 29, 414, 8, 29, 1, 29, 3, 29, 417, 8, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 3, 33, 436, 8, 33, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 1, 34, 3, 34, 450, 8, 34, 1, 35, 1, 35, 1, 35, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 464, 8, 36, 10, 36, 12, 36, 467, 9, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 476, 8, 36, 10, 36, 12, 36, 479, 9, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 5, 36, 488, 8, 36, 10, 36, 12, 36, 491, 9, 36, 1, 36, 1, 36, 1, 36, 1, 36, 1, 36, 3, 36, 498, 8, 36, 1, 36, 1, 36, 3, 36, 502, 8, 36, 1, 37, 1, 37, 1, 37, 5, 37, 507, 8, 37, 10, 37, 12, 37, 510, 9, 37, 1, 38, 1, 38, 1, 38, 3, 38, 515, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 523, 8, 38, 1, 39, 1, 39, 1, 39, 3, 39, 528, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 4, 39, 535, 8, 39, 11, 39, 12, 39, 536, 1, 39, 1, 39, 3, 39, 541, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 572, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 589, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 601, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 611, 8, 39, 1, 39, 3, 39, 614, 8, 39, 1, 39, 1, 39, 3, 39, 618, 8, 39, 1, 39, 3, 39, 621, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 633, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 650, 8, 39, 1, 39, 1, 39, 3, 39, 654, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 660, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 667, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 679, 8, 39, 1, 39, 3, 39, 682, 8, 39, 1, 39, 1, 39, 3, 39, 686, 8, 39, 1, 39, 3, 39, 689, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 700, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 724, 8, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 1, 39, 3, 39, 733, 8, 39, 5, 39, 735, 8, 39, 10, 39, 12, 39, 738, 9, 39, 1, 40, 1, 40, 1, 40, 5, 40, 743, 8, 40, 10, 40, 12, 40, 746, 9, 40, 1, 41, 1, 41, 3, 41, 750, 8, 41, 1, 42, 1, 42, 1, 42, 1, 42, 5, 42, 756, 8, 42, 10, 42, 12, 42, 759, 9, 42, 1, 42, 1, 42, 1, 42, 1, 42, 1, 42, 5, 42, 766, 8, 42, 10, 42, 12, 42, 769, 9, 42, 3, 42, 771, 8, 42, 1, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 43, 3, 43, 780, 8, 43, 1, 43, 3, 43, 783, 8, 43, 1, 44, 1, 44, 1, 44, 5, 44, 788, 8, 44, 10, 44, 12, 44, 791, 9, 44, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 1, 45, 3, 45, 800, 8, 45, 1, 45, 1, 45, 1, 45, 1, 45, 3, 45, 806, 8, 45, 5, 45, 808, 8, 45, 10, 45, 12, 45, 811, 9, 45, 1, 46, 1, 46, 1, 46, 3, 46, 816, 8, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 3, 47, 823, 8, 47, 1, 47, 1, 47, 1, 48, 1, 48, 1, 48, 5, 48, 830, 8, 48, 10, 48, 12, 48, 833, 9, 48, 1, 49, 1, 49, 1, 49, 3, 49, 838, 8, 49, 1, 50, 1, 50, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 3, 51, 848, 8, 51, 3, 51, 850, 8, 51, 1, 52, 3, 52, 853, 8, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 1, 52, 3, 52, 861, 8, 52, 1, 53, 1, 53, 1, 53, 3, 53, 866, 8, 53, 1, 54, 1, 54, 1, 55, 1, 55, 1, 56, 1, 56, 1, 57, 1, 57, 3, 57, 876, 8, 57, 1, 58, 1, 58, 1, 58, 3, 58, 881, 8, 58, 1, 59, 1, 59, 3, 59, 885, 8, 59, 1, 60, 1, 60, 1, 60, 1, 60, 1, 60, 0, 3, 36, 78, 90, 61, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 0, 18, 2, 0, 31, 31, 140, 140, 2, 0, 83, 83, 95, 95, 2, 0, 70, 70, 100, 100, 3, 0, 4, 4, 8, 8, 12, 12, 4, 0, 4, 4, 7, 8, 12, 12, 146, 146, 2, 0, 95, 95, 139, 139, 2, 0, 4, 4, 8, 8, 2, 0, 117, 117, 205, 205, 2, 0, 11, 11, 41, 42, 2, 0, 61, 61, 92, 92, 2, 0, 132, 132, 142, 142, 3, 0, 17, 17, 94, 94, 169, 169, 2, 0, 78, 78, 97, 97, 1, 0, 195, 196, 2, 0, 207, 207, 222, 222, 8, 0, 36, 36, 75, 75, 107, 107, 109, 109, 131, 131, 144, 144, 184, 184, 189, 189, 12, 0, 2, 35, 37, 74, 76, 80, 82, 106, 108, 108, 110, 111, 113, 114, 116, 129, 132, 143, 145, 183, 185, 188, 190, 191, 4, 0, 35, 35, 61, 61, 76, 76, 90, 90, 1000, 0, 124, 1, 0, 0, 0, 2, 128, 1, 0, 0, 0, 4, 142, 1, 0, 0, 0, 6, 145, 1, 0, 0, 0, 8, 196, 1, 0, 0, 0, 10, 199, 1, 0, 0, 0, 12, 205, 1, 0, 0, 0, 14, 209, 1, 0, 0, 0, 16, 215, 1, 0, 0, 0, 18, 222, 1, 0, 0, 0, 20, 225, 1, 0, 0, 0, 22, 228, 1, 0, 0, 0, 24, 238, 1, 0, 0, 0, 26, 241, 1, 0, 0, 0, 28, 245, 1, 0, 0, 0, 30, 249, 1, 0, 0, 0, 32, 254, 1, 0, 0, 0, 34, 260, 1, 0, 0, 0, 36, 275, 1, 0, 0, 0, 38, 340, 1, 0, 0, 0, 40, 348, 1, 0, 0, 0, 42, 359, 1, 0, 0, 0, 44, 361, 1, 0, 0, 0, 46, 367, 1, 0, 0, 0, 48, 372, 1, 0, 0, 0, 50, 380, 1, 0, 0, 0, 52, 392, 1, 0, 0, 0, 54, 397, 1, 0, 0, 0, 56, 405, 1, 0, 0, 0, 58, 410, 1, 0, 0, 0, 60, 418, 1, 0, 0, 0, 62, 422, 1, 0, 0, 0, 64, 426, 1, 0, 0, 0, 66, 435, 1, 0, 0, 0, 68, 449, 1, 0, 0, 0, 70, 451, 1, 0, 0, 0, 72, 501, 1, 0, 0, 0, 74, 503, 1, 0, 0, 0, 76, 522, 1, 0, 0, 0, 78, 653, 1, 0, 0, 0, 80, 739, 1, 0, 0, 0, 82, 749, 1, 0, 0, 0, 84, 770, 1, 0, 0, 0, 86, 782, 1, 0, 0, 0, 88, 784, 1, 0, 0, 0, 90, 799, 1, 0, 0, 0, 92, 812, 1, 0, 0, 0, 94, 822, 1, 0, 0, 0, 96, 826, 1, 0, 0, 0, 98, 837, 1, 0, 0, 0, 100, 839, 1, 0, 0, 0, 102, 849, 1, 0, 0, 0, 104, 852, 1, 0, 0, 0, 106, 865, 1, 0, 0, 0, 108, 867, 1, 0, 0, 0, 110, 869, 1, 0, 0, 0, 112, 871, 1, 0, 0, 0, 114, 875, 1, 0, 0, 0, 116, 880, 1, 0, 0, 0, 118, 884, 1, 0, 0, 0, 120, 886, 1, 0, 0, 0, 122, 125, 3, 2, 1, 0, 123, 125, 3, 6, 3, 0, 124, 122, 1, 0, 0, 0, 124, 123, 1, 0, 0, 0, 125, 126, 1, 0, 0, 0, 126, 127, 5, 0, 0, 1, 127, 1, 1, 0, 0, 0, 128, 134, 3, 4, 2, 0, 129, 130, 5, 175, 0, 0, 130, 131, 5, 4, 0, 0, 131, 133, 3, 4, 2, 0, 132, 129, 1, 0, 0, 0, 133, 136, 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 135, 3, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 137, 143, 3, 6, 3, 0, 138, 139, 5, 218, 0, 0, 139, 140, 3, 2, 1, 0, 140, 141, 5, 228, 0, 0, 141, 143, 1, 0, 0, 0, 142, 137, 1, 0, 0, 0, 142, 138, 1, 0, 0, 0, 143, 5, 1, 0, 0, 0, 144, 146, 3, 8, 4, 0, 145, 144, 1, 0, 0, 0, 145, 146, 1, 0, 0, 0, 146, 147, 1, 0, 0, 0, 147, 149, 5, 145, 0, 0, 148, 150, 5, 48, 0, 0, 149, 148, 1, 0, 0, 0, 149, 150, 1, 0, 0, 0, 150, 152, 1, 0, 0, 0, 151, 153, 3, 10, 5, 0, 152, 151, 1, 0, 0, 0, 152, 153, 1, 0, 0, 0, 153, 154, 1, 0, 0, 0, 154, 156, 3, 74, 37, 0, 155, 157, 3, 12, 6, 0, 156, 155, 1, 0, 0, 0, 156, 157, 1, 0, 0, 0, 157, 159, 1, 0, 0, 0, 158, 160, 3, 14, 7, 0, 159, 158, 1, 0, 0, 0, 159, 160, 1, 0, 0, 0, 160, 162, 1, 0, 0, 0, 161, 163, 3, 16, 8, 0, 162, 161, 1, 0, 0, 0, 162, 163, 1, 0, 0, 0, 163, 165, 1, 0, 0, 0, 164, 166, 3, 18, 9, 0, 165, 164, 1, 0, 0, 0, 165, 166, 1, 0, 0, 0, 166, 168, 1, 0, 0, 0, 167, 169, 3, 20, 10, 0, 168, 167, 1, 0, 0, 0, 168, 169, 1, 0, 0, 0, 169, 171, 1, 0, 0, 0, 170, 172, 3, 22, 11, 0, 171, 170, 1, 0, 0, 0, 171, 172, 1, 0, 0, 0, 172, 175, 1, 0, 0, 0, 173, 174, 5, 188, 0, 0, 174, 176, 7, 0, 0, 0, 175, 173, 1, 0, 0, 0, 175, 176, 1, 0, 0, 0, 176, 179, 1, 0, 0, 0, 177, 178, 5, 188, 0, 0, 178, 180, 5, 168, 0, 0, 179, 177, 1, 0, 0, 0, 179, 180, 1, 0, 0, 0, 180, 182, 1, 0, 0, 0, 181, 183, 3, 24, 12, 0, 182, 181, 1, 0, 0, 0, 182, 183, 1, 0, 0, 0, 183, 185, 1, 0, 0, 0, 184, 186, 3, 26, 13, 0, 185, 184, 1, 0, 0, 0, 185, 186, 1, 0, 0, 0, 186, 188, 1, 0, 0, 0, 187, 189, 3, 30, 15, 0, 188, 187, 1, 0, 0, 0, 188, 189, 1, 0, 0, 0, 189, 191, 1, 0, 0, 0, 190, 192, 3, 32, 16, 0, 191, 190, 1, 0, 0, 0, 191, 192, 1, 0, 0, 0, 192, 194, 1, 0, 0, 0, 193, 195, 3, 34, 17, 0, 194, 193, 1, 0, 0, 0, 194, 195, 1, 0, 0, 0, 195, 7, 1, 0, 0, 0, 196, 197, 5, 188, 0, 0, 197, 198, 3, 74, 37, 0, 198, 9, 1, 0, 0, 0, 199, 200, 5, 167, 0, 0, 200, 203, 5, 196, 0, 0, 201, 202, 5, 188, 0, 0, 202, 204, 5, 163, 0, 0, 203, 201, 1, 0, 0, 0, 203, 204, 1, 0, 0, 0, 204, 11, 1, 0, 0, 0, 205, 206, 5, 67, 0, 0, 206, 207, 3, 36, 18, 0, 207, 13, 1, 0, 0, 0, 208, 210, 7, 1, 0, 0, 209, 208, 1, 0, 0, 0, 209, 210, 1, 0, 0, 0, 210, 211, 1, 0, 0, 0, 211, 212, 5, 9, 0, 0, 212, 213, 5, 89, 0, 0, 213, 214, 3, 74, 37, 0, 214, 15, 1, 0, 0, 0, 215, 216, 5, 187, 0, 0, 216, 217, 3, 116, 58, 0, 217, 218, 5, 10, 0, 0, 218, 219, 5, 218, 0, 0, 219, 220, 3, 58, 29, 0, 220, 221, 5, 228, 0, 0, 221, 17, 1, 0, 0, 0, 222, 223, 5, 128, 0, 0, 223, 224, 3, 78, 39, 0, 224, 19, 1, 0, 0, 0, 225, 226, 5, 186, 0, 0, 226, 227, 3, 78, 39, 0, 227, 21, 1, 0, 0, 0, 228, 229, 5, 72, 0, 0, 229, 236, 5, 18, 0, 0, 230, 231, 7, 0, 0, 0, 231, 232, 5, 218, 0, 0, 232, 233, 3, 74, 37, 0, 233, 234, 5, 228, 0, 0, 234, 237, 1, 0, 0, 0, 235, 237, 3, 74, 37, 0, 236, 230, 1, 0, 0, 0, 236, 235, 1, 0, 0, 0, 237, 23, 1, 0, 0, 0, 238, 239, 5, 73, 0, 0, 239, 240, 3, 78, 39, 0, 240, 25, 1, 0, 0, 0, 241, 242, 5, 121, 0, 0, 242, 243, 5, 18, 0, 0, 243, 244, 3, 48, 24, 0, 244, 27, 1, 0, 0, 0, 245, 246, 5, 121, 0, 0, 246, 247, 5, 18, 0, 0, 247, 248, 3, 74, 37, 0, 248, 29, 1, 0, 0, 0, 249, 250, 5, 98, 0, 0, 250, 251, 3, 46, 23, 0, 251, 252, 5, 18, 0, 0, 252, 253, 3, 74, 37, 0, 253, 31, 1, 0, 0, 0, 254, 255, 5, 98, 0, 0, 255, 258, 3, 46, 23, 0, 256, 257, 5, 188, 0, 0, 257, 259, 5, 163, 0, 0, 258, 256, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 33, 1, 0, 0, 0, 260, 261, 5, 149, 0, 0, 261, 262, 3, 54, 27, 0, 262, 35, 1, 0, 0, 0, 263, 264, 6, 18, -1, 0, 264, 266, 3, 90, 45, 0, 265, 267, 5, 60, 0, 0, 266, 265, 1, 0, 0, 0, 266, 267, 1, 0, 0, 0, 267, 269, 1, 0, 0, 0, 268, 270, 3, 44, 22, 0, 269, 268, 1, 0, 0, 0, 269, 270, 1, 0, 0, 0, 270, 276, 1, 0, 0, 0, 271, 272, 5, 218, 0, 0, 272, 273, 3, 36, 18, 0, 273, 274, 5, 228, 0, 0, 274, 276, 1, 0, 0, 0, 275, 263, 1, 0, 0, 0, 275, 271, 1, 0, 0, 0, 276, 294, 1, 0, 0, 0, 277, 278, 10, 3, 0, 0, 278, 279, 3, 40, 20, 0, 279, 280, 3, 36, 18, 4, 280, 293, 1, 0, 0, 0, 281, 283, 10, 4, 0, 0, 282, 284, 7, 2, 0, 0, 283, 282, 1, 0, 0, 0, 283, 284, 1, 0, 0, 0, 284, 286, 1, 0, 0, 0, 285, 287, 3, 38, 19, 0, 286, 285, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 288, 1, 0, 0, 0, 288, 289, 5, 89, 0, 0, 289, 290, 3, 36, 18, 0, 290, 291, 3, 42, 21, 0, 291, 293, 1, 0, 0, 0, 292, 277, 1, 0, 0, 0, 292, 281, 1, 0, 0, 0, 293, 296, 1, 0, 0, 0, 294, 292, 1, 0, 0, 0, 294, 295, 1, 0, 0, 0, 295, 37, 1, 0, 0, 0, 296, 294, 1, 0, 0, 0, 297, 299, 7, 3, 0, 0, 298, 297, 1, 0, 0, 0, 298, 299, 1, 0, 0, 0, 299, 300, 1, 0, 0, 0, 300, 307, 5, 83, 0, 0, 301, 303, 5, 83, 0, 0, 302, 304, 7, 3, 0, 0, 303, 302, 1, 0, 0, 0, 303, 304, 1, 0, 0, 0, 304, 307, 1, 0, 0, 0, 305, 307, 7, 3, 0, 0, 306, 298, 1, 0, 0, 0, 306, 301, 1, 0, 0, 0, 306, 305, 1, 0, 0, 0, 307, 341, 1, 0, 0, 0, 308, 310, 7, 4, 0, 0, 309, 308, 1, 0, 0, 0, 309, 310, 1, 0, 0, 0, 310, 311, 1, 0, 0, 0, 311, 313, 7, 5, 0, 0, 312, 314, 5, 122, 0, 0, 313, 312, 1, 0, 0, 0, 313, 314, 1, 0, 0, 0, 314, 323, 1, 0, 0, 0, 315, 317, 7, 5, 0, 0, 316, 318, 5, 122, 0, 0, 317, 316, 1, 0, 0, 0, 317, 318, 1, 0, 0, 0, 318, 320, 1, 0, 0, 0, 319, 321, 7, 4, 0, 0, 320, 319, 1, 0, 0, 0, 320, 321, 1, 0, 0, 0, 321, 323, 1, 0, 0, 0, 322, 309, 1, 0, 0, 0, 322, 315, 1, 0, 0, 0, 323, 341, 1, 0, 0, 0, 324, 326, 7, 6, 0, 0, 325, 324, 1, 0, 0, 0, 325, 326, 1, 0, 0, 0, 326, 327, 1, 0, 0, 0, 327, 329, 5, 68, 0, 0, 328, 330, 5, 122, 0, 0, 329, 328, 1, 0, 0, 0, 329, 330, 1, 0, 0, 0, 330, 339, 1, 0, 0, 0, 331, 333, 5, 68, 0, 0, 332, 334, 5, 122, 0, 0, 333, 332, 1, 0, 0, 0, 333, 334, 1, 0, 0, 0, 334, 336, 1, 0, 0, 0, 335, 337, 7, 6, 0, 0, 336, 335, 1, 0, 0, 0, 336, 337, 1, 0, 0, 0, 337, 339, 1, 0, 0, 0, 338, 325, 1, 0, 0, 0, 338, 331, 1, 0, 0, 0, 339, 341, 1, 0, 0, 0, 340, 306, 1, 0, 0, 0, 340, 322, 1, 0, 0, 0, 340, 338, 1, 0, 0, 0, 341, 39, 1, 0, 0, 0, 342, 344, 7, 2, 0, 0, 343, 342, 1, 0, 0, 0, 343, 344, 1, 0, 0, 0, 344, 345, 1, 0, 0, 0, 345, 346, 5, 30, 0, 0, 346, 349, 5, 89, 0, 0, 347, 349, 5, 205, 0, 0, 348, 343, 1, 0, 0, 0, 348, 347, 1, 0, 0, 0, 349, 41, 1, 0, 0, 0, 350, 351, 5, 118, 0, 0, 351, 360, 3, 74, 37, 0, 352, 353, 5, 178, 0, 0, 353, 354, 5, 218, 0, 0, 354, 355, 3, 74, 37, 0, 355, 356, 5, 228, 0, 0, 356, 360, 1, 0, 0, 0, 357, 358, 5, 178, 0, 0, 358, 360, 3, 74, 37, 0, 359, 350, 1, 0, 0, 0, 359, 352, 1, 0, 0, 0, 359, 357, 1, 0, 0, 0, 360, 43, 1, 0, 0, 0, 361, 362, 5, 143, 0, 0, 362, 365, 3, 52, 26, 0, 363, 364, 5, 117, 0, 0, 364, 366, 3, 52, 26, 0, 365, 363, 1, 0, 0, 0, 365, 366, 1, 0, 0, 0, 366, 45, 1, 0, 0, 0, 367, 370, 3, 78, 39, 0, 368, 369, 7, 7, 0, 0, 369, 371, 3, 78, 39, 0, 370, 368, 1, 0, 0, 0, 370, 371, 1, 0, 0, 0, 371, 47, 1, 0, 0, 0, 372, 377, 3, 50, 25, 0, 373, 374, 5, 205, 0, 0, 374, 376, 3, 50, 25, 0, 375, 373, 1, 0, 0, 0, 376, 379, 1, 0, 0, 0, 377, 375, 1, 0, 0, 0, 377, 378, 1, 0, 0, 0, 378, 49, 1, 0, 0, 0, 379, 377, 1, 0, 0, 0, 380, 382, 3, 78, 39, 0, 381, 383, 7, 8, 0, 0, 382, 381, 1, 0, 0, 0, 382, 383, 1, 0, 0, 0, 383, 386, 1, 0, 0, 0, 384, 385, 5, 116, 0, 0, 385, 387, 7, 9, 0, 0, 386, 384, 1, 0, 0, 0, 386, 387, 1, 0, 0, 0, 387, 390, 1, 0, 0, 0, 388, 389, 5, 25, 0, 0, 389, 391, 5, 198, 0, 0, 390, 388, 1, 0, 0, 0, 390, 391, 1, 0, 0, 0, 391, 51, 1, 0, 0, 0, 392, 395, 3, 104, 52, 0, 393, 394, 5, 230, 0, 0, 394, 396, 3, 104, 52, 0, 395, 393, 1, 0, 0, 0, 395, 396, 1, 0, 0, 0, 396, 53, 1, 0, 0, 0, 397, 402, 3, 56, 28, 0, 398, 399, 5, 205, 0, 0, 399, 401, 3, 56, 28, 0, 400, 398, 1, 0, 0, 0, 401, 404, 1, 0, 0, 0, 402, 400, 1, 0, 0, 0, 402, 403, 1, 0, 0, 0, 403, 55, 1, 0, 0, 0, 404, 402, 1, 0, 0, 0, 405, 406, 3, 116, 58, 0, 406, 407, 5, 211, 0, 0, 407, 408, 3, 106, 53, 0, 408, 57, 1, 0, 0, 0, 409, 411, 3, 60, 30, 0, 410, 409, 1, 0, 0, 0, 410, 411, 1, 0, 0, 0, 411, 413, 1, 0, 0, 0, 412, 414, 3, 62, 31, 0, 413, 412, 1, 0, 0, 0, 413, 414, 1, 0, 0, 0, 414, 416, 1, 0, 0, 0, 415, 417, 3, 64, 32, 0, 416, 415, 1, 0, 0, 0, 416, 417, 1, 0, 0, 0, 417, 59, 1, 0, 0, 0, 418, 419, 5, 125, 0, 0, 419, 420, 5, 18, 0, 0, 420, 421, 3, 74, 37, 0, 421, 61, 1, 0, 0, 0, 422, 423, 5, 121, 0, 0, 423, 424, 5, 18, 0, 0, 424, 425, 3, 48, 24, 0, 425, 63, 1, 0, 0, 0, 426, 427, 7, 10, 0, 0, 427, 428, 3, 66, 33, 0, 428, 65, 1, 0, 0, 0, 429, 436, 3, 68, 34, 0, 430, 431, 5, 16, 0, 0, 431, 432, 3, 68, 34, 0, 432, 433, 5, 6, 0, 0, 433, 434, 3, 68, 34, 0, 434, 436, 1, 0, 0, 0, 435, 429, 1, 0, 0, 0, 435, 430, 1, 0, 0, 0, 436, 67, 1, 0, 0, 0, 437, 438, 5, 32, 0, 0, 438, 450, 5, 141, 0, 0, 439, 440, 5, 174, 0, 0, 440, 450, 5, 127, 0, 0, 441, 442, 5, 174, 0, 0, 442, 450, 5, 63, 0, 0, 443, 444, 3, 104, 52, 0, 444, 445, 5, 127, 0, 0, 445, 450, 1, 0, 0, 0, 446, 447, 3, 104, 52, 0, 447, 448, 5, 63, 0, 0, 448, 450, 1, 0, 0, 0, 449, 437, 1, 0, 0, 0, 449, 439, 1, 0, 0, 0, 449, 441, 1, 0, 0, 0, 449, 443, 1, 0, 0, 0, 449, 446, 1, 0, 0, 0, 450, 69, 1, 0, 0, 0, 451, 452, 3, 78, 39, 0, 452, 453, 5, 0, 0, 1, 453, 71, 1, 0, 0, 0, 454, 502, 3, 116, 58, 0, 455, 456, 3, 116, 58, 0, 456, 457, 5, 218, 0, 0, 457, 458, 3, 116, 58, 0, 458, 465, 3, 72, 36, 0, 459, 460, 5, 205, 0, 0, 460, 461, 3, 116, 58, 0, 461, 462, 3, 72, 36, 0, 462, 464, 1, 0, 0, 0, 463, 459, 1, 0, 0, 0, 464, 467, 1, 0, 0, 0, 465, 463, 1, 0, 0, 0, 465, 466, 1, 0, 0, 0, 466, 468, 1, 0, 0, 0, 467, 465, 1, 0, 0, 0, 468, 469, 5, 228, 0, 0, 469, 502, 1, 0, 0, 0, 470, 471, 3, 116, 58, 0, 471, 472, 5, 218, 0, 0, 472, 477, 3, 120, 60, 0, 473, 474, 5, 205, 0, 0, 474, 476, 3, 120, 60, 0, 475, 473, 1, 0, 0, 0, 476, 479, 1, 0, 0, 0, 477, 475, 1, 0, 0, 0, 477, 478, 1, 0, 0, 0, 478, 480, 1, 0, 0, 0, 479, 477, 1, 0, 0, 0, 480, 481, 5, 228, 0, 0, 481, 502, 1, 0, 0, 0, 482, 483, 3, 116, 58, 0, 483, 484, 5, 218, 0, 0, 484, 489, 3, 72, 36, 0, 485, 486, 5, 205, 0, 0, 486, 488, 3, 72, 36, 0, 487, 485, 1, 0, 0, 0, 488, 491, 1, 0, 0, 0, 489, 487, 1, 0, 0, 0, 489, 490, 1, 0, 0, 0, 490, 492, 1, 0, 0, 0, 491, 489, 1, 0, 0, 0, 492, 493, 5, 228, 0, 0, 493, 502, 1, 0, 0, 0, 494, 495, 3, 116, 58, 0, 495, 497, 5, 218, 0, 0, 496, 498, 3, 74, 37, 0, 497, 496, 1, 0, 0, 0, 497, 498, 1, 0, 0, 0, 498, 499, 1, 0, 0, 0, 499, 500, 5, 228, 0, 0, 500, 502, 1, 0, 0, 0, 501, 454, 1, 0, 0, 0, 501, 455, 1, 0, 0, 0, 501, 470, 1, 0, 0, 0, 501, 482, 1, 0, 0, 0, 501, 494, 1, 0, 0, 0, 502, 73, 1, 0, 0, 0, 503, 508, 3, 76, 38, 0, 504, 505, 5, 205, 0, 0, 505, 507, 3, 76, 38, 0, 506, 504, 1, 0, 0, 0, 507, 510, 1, 0, 0, 0, 508, 506, 1, 0, 0, 0, 508, 509, 1, 0, 0, 0, 509, 75, 1, 0, 0, 0, 510, 508, 1, 0, 0, 0, 511, 512, 3, 94, 47, 0, 512, 513, 5, 209, 0, 0, 513, 515, 1, 0, 0, 0, 514, 511, 1, 0, 0, 0, 514, 515, 1, 0, 0, 0, 515, 516, 1, 0, 0, 0, 516, 523, 5, 201, 0, 0, 517, 518, 5, 218, 0, 0, 518, 519, 3, 2, 1, 0, 519, 520, 5, 228, 0, 0, 520, 523, 1, 0, 0, 0, 521, 523, 3, 78, 39, 0, 522, 514, 1, 0, 0, 0, 522, 517, 1, 0, 0, 0, 522, 521, 1, 0, 0, 0, 523, 77, 1, 0, 0, 0, 524, 525, 6, 39, -1, 0, 525, 527, 5, 19, 0, 0, 526, 528, 3, 78, 39, 0, 527, 526, 1, 0, 0, 0, 527, 528, 1, 0, 0, 0, 528, 534, 1, 0, 0, 0, 529, 530, 5, 185, 0, 0, 530, 531, 3, 78, 39, 0, 531, 532, 5, 162, 0, 0, 532, 533, 3, 78, 39, 0, 533, 535, 1, 0, 0, 0, 534, 529, 1, 0, 0, 0, 535, 536, 1, 0, 0, 0, 536, 534, 1, 0, 0, 0, 536, 537, 1, 0, 0, 0, 537, 540, 1, 0, 0, 0, 538, 539, 5, 51, 0, 0, 539, 541, 3, 78, 39, 0, 540, 538, 1, 0, 0, 0, 540, 541, 1, 0, 0, 0, 541, 542, 1, 0, 0, 0, 542, 543, 5, 52, 0, 0, 543, 654, 1, 0, 0, 0, 544, 545, 5, 20, 0, 0, 545, 546, 5, 218, 0, 0, 546, 547, 3, 78, 39, 0, 547, 548, 5, 10, 0, 0, 548, 549, 3, 72, 36, 0, 549, 550, 5, 228, 0, 0, 550, 654, 1, 0, 0, 0, 551, 552, 5, 35, 0, 0, 552, 654, 5, 198, 0, 0, 553, 554, 5, 58, 0, 0, 554, 555, 5, 218, 0, 0, 555, 556, 3, 108, 54, 0, 556, 557, 5, 67, 0, 0, 557, 558, 3, 78, 39, 0, 558, 559, 5, 228, 0, 0, 559, 654, 1, 0, 0, 0, 560, 561, 5, 85, 0, 0, 561, 562, 3, 78, 39, 0, 562, 563, 3, 108, 54, 0, 563, 654, 1, 0, 0, 0, 564, 565, 5, 154, 0, 0, 565, 566, 5, 218, 0, 0, 566, 567, 3, 78, 39, 0, 567, 568, 5, 67, 0, 0, 568, 571, 3, 78, 39, 0, 569, 570, 5, 64, 0, 0, 570, 572, 3, 78, 39, 0, 571, 569, 1, 0, 0, 0, 571, 572, 1, 0, 0, 0, 572, 573, 1, 0, 0, 0, 573, 574, 5, 228, 0, 0, 574, 654, 1, 0, 0, 0, 575, 576, 5, 165, 0, 0, 576, 654, 5, 198, 0, 0, 577, 578, 5, 170, 0, 0, 578, 579, 5, 218, 0, 0, 579, 580, 7, 11, 0, 0, 580, 581, 5, 198, 0, 0, 581, 582, 5, 67, 0, 0, 582, 583, 3, 78, 39, 0, 583, 584, 5, 228, 0, 0, 584, 654, 1, 0, 0, 0, 585, 586, 3, 116, 58, 0, 586, 588, 5, 218, 0, 0, 587, 589, 3, 74, 37, 0, 588, 587, 1, 0, 0, 0, 588, 589, 1, 0, 0, 0, 589, 590, 1, 0, 0, 0, 590, 591, 5, 228, 0, 0, 591, 592, 1, 0, 0, 0, 592, 593, 5, 124, 0, 0, 593, 594, 5, 218, 0, 0, 594, 595, 3, 58, 29, 0, 595, 596, 5, 228, 0, 0, 596, 654, 1, 0, 0, 0, 597, 598, 3, 116, 58, 0, 598, 600, 5, 218, 0, 0, 599, 601, 3, 74, 37, 0, 600, 599, 1, 0, 0, 0, 600, 601, 1, 0, 0, 0, 601, 602, 1, 0, 0, 0, 602, 603, 5, 228, 0, 0, 603, 604, 1, 0, 0, 0, 604, 605, 5, 124, 0, 0, 605, 606, 3, 116, 58, 0, 606, 654, 1, 0, 0, 0, 607, 613, 3, 116, 58, 0, 608, 610, 5, 218, 0, 0, 609, 611, 3, 74, 37, 0, 610, 609, 1, 0, 0, 0, 610, 611, 1, 0, 0, 0, 611, 612, 1, 0, 0, 0, 612, 614, 5, 228, 0, 0, 613, 608, 1, 0, 0, 0, 613, 614, 1, 0, 0, 0, 614, 615, 1, 0, 0, 0, 615, 617, 5, 218, 0, 0, 616, 618, 5, 48, 0, 0, 617, 616, 1, 0, 0, 0, 617, 618, 1, 0, 0, 0, 618, 620, 1, 0, 0, 0, 619, 621, 3, 80, 40, 0, 620, 619, 1, 0, 0, 0, 620, 621, 1, 0, 0, 0, 621, 622, 1, 0, 0, 0, 622, 623, 5, 228, 0, 0, 623, 654, 1, 0, 0, 0, 624, 654, 3, 106, 53, 0, 625, 626, 5, 207, 0, 0, 626, 654, 3, 78, 39, 17, 627, 628, 5, 114, 0, 0, 628, 654, 3, 78, 39, 12, 629, 630, 3, 94, 47, 0, 630, 631, 5, 209, 0, 0, 631, 633, 1, 0, 0, 0, 632, 629, 1, 0, 0, 0, 632, 633, 1, 0, 0, 0, 633, 634, 1, 0, 0, 0, 634, 654, 5, 201, 0, 0, 635, 636, 5, 218, 0, 0, 636, 637, 3, 2, 1, 0, 637, 638, 5, 228, 0, 0, 638, 654, 1, 0, 0, 0, 639, 640, 5, 218, 0, 0, 640, 641, 3, 78, 39, 0, 641, 642, 5, 228, 0, 0, 642, 654, 1, 0, 0, 0, 643, 644, 5, 218, 0, 0, 644, 645, 3, 74, 37, 0, 645, 646, 5, 228, 0, 0, 646, 654, 1, 0, 0, 0, 647, 649, 5, 216, 0, 0, 648, 650, 3, 74, 37, 0, 649, 648, 1, 0, 0, 0, 649, 650, 1, 0, 0, 0, 650, 651, 1, 0, 0, 0, 651, 654, 5, 227, 0, 0, 652, 654, 3, 86, 43, 0, 653, 524, 1, 0, 0, 0, 653, 544, 1, 0, 0, 0, 653, 551, 1, 0, 0, 0, 653, 553, 1, 0, 0, 0, 653, 560, 1, 0, 0, 0, 653, 564, 1, 0, 0, 0, 653, 575, 1, 0, 0, 0, 653, 577, 1, 0, 0, 0, 653, 585, 1, 0, 0, 0, 653, 597, 1, 0, 0, 0, 653, 607, 1, 0, 0, 0, 653, 624, 1, 0, 0, 0, 653, 625, 1, 0, 0, 0, 653, 627, 1, 0, 0, 0, 653, 632, 1, 0, 0, 0, 653, 635, 1, 0, 0, 0, 653, 639, 1, 0, 0, 0, 653, 643, 1, 0, 0, 0, 653, 647, 1, 0, 0, 0, 653, 652, 1, 0, 0, 0, 654, 736, 1, 0, 0, 0, 655, 659, 10, 16, 0, 0, 656, 660, 5, 201, 0, 0, 657, 660, 5, 230, 0, 0, 658, 660, 5, 221, 0, 0, 659, 656, 1, 0, 0, 0, 659, 657, 1, 0, 0, 0, 659, 658, 1, 0, 0, 0, 660, 661, 1, 0, 0, 0, 661, 735, 3, 78, 39, 17, 662, 666, 10, 15, 0, 0, 663, 667, 5, 222, 0, 0, 664, 667, 5, 207, 0, 0, 665, 667, 5, 206, 0, 0, 666, 663, 1, 0, 0, 0, 666, 664, 1, 0, 0, 0, 666, 665, 1, 0, 0, 0, 667, 668, 1, 0, 0, 0, 668, 735, 3, 78, 39, 16, 669, 688, 10, 14, 0, 0, 670, 689, 5, 210, 0, 0, 671, 689, 5, 211, 0, 0, 672, 689, 5, 220, 0, 0, 673, 689, 5, 217, 0, 0, 674, 689, 5, 212, 0, 0, 675, 689, 5, 219, 0, 0, 676, 689, 5, 213, 0, 0, 677, 679, 5, 70, 0, 0, 678, 677, 1, 0, 0, 0, 678, 679, 1, 0, 0, 0, 679, 681, 1, 0, 0, 0, 680, 682, 5, 114, 0, 0, 681, 680, 1, 0, 0, 0, 681, 682, 1, 0, 0, 0, 682, 683, 1, 0, 0, 0, 683, 689, 5, 79, 0, 0, 684, 686, 5, 114, 0, 0, 685, 684, 1, 0, 0, 0, 685, 686, 1, 0, 0, 0, 686, 687, 1, 0, 0, 0, 687, 689, 7, 12, 0, 0, 688, 670, 1, 0, 0, 0, 688, 671, 1, 0, 0, 0, 688, 672, 1, 0, 0, 0, 688, 673, 1, 0, 0, 0, 688, 674, 1, 0, 0, 0, 688, 675, 1, 0, 0, 0, 688, 676, 1, 0, 0, 0, 688, 678, 1, 0, 0, 0, 688, 685, 1, 0, 0, 0, 689, 690, 1, 0, 0, 0, 690, 735, 3, 78, 39, 15, 691, 692, 10, 11, 0, 0, 692, 693, 5, 6, 0, 0, 693, 735, 3, 78, 39, 12, 694, 695, 10, 10, 0, 0, 695, 696, 5, 120, 0, 0, 696, 735, 3, 78, 39, 11, 697, 699, 10, 9, 0, 0, 698, 700, 5, 114, 0, 0, 699, 698, 1, 0, 0, 0, 699, 700, 1, 0, 0, 0, 700, 701, 1, 0, 0, 0, 701, 702, 5, 16, 0, 0, 702, 703, 3, 78, 39, 0, 703, 704, 5, 6, 0, 0, 704, 705, 3, 78, 39, 10, 705, 735, 1, 0, 0, 0, 706, 707, 10, 8, 0, 0, 707, 708, 5, 223, 0, 0, 708, 709, 3, 78, 39, 0, 709, 710, 5, 204, 0, 0, 710, 711, 3, 78, 39, 8, 711, 735, 1, 0, 0, 0, 712, 713, 10, 19, 0, 0, 713, 714, 5, 216, 0, 0, 714, 715, 3, 78, 39, 0, 715, 716, 5, 227, 0, 0, 716, 735, 1, 0, 0, 0, 717, 718, 10, 18, 0, 0, 718, 719, 5, 209, 0, 0, 719, 735, 5, 196, 0, 0, 720, 721, 10, 13, 0, 0, 721, 723, 5, 87, 0, 0, 722, 724, 5, 114, 0, 0, 723, 722, 1, 0, 0, 0, 723, 724, 1, 0, 0, 0, 724, 725, 1, 0, 0, 0, 725, 735, 5, 115, 0, 0, 726, 732, 10, 7, 0, 0, 727, 733, 3, 114, 57, 0, 728, 729, 5, 10, 0, 0, 729, 733, 3, 116, 58, 0, 730, 731, 5, 10, 0, 0, 731, 733, 5, 198, 0, 0, 732, 727, 1, 0, 0, 0, 732, 728, 1, 0, 0, 0, 732, 730, 1, 0, 0, 0, 733, 735, 1, 0, 0, 0, 734, 655, 1, 0, 0, 0, 734, 662, 1, 0, 0, 0, 734, 669, 1, 0, 0, 0, 734, 691, 1, 0, 0, 0, 734, 694, 1, 0, 0, 0, 734, 697, 1, 0, 0, 0, 734, 706, 1, 0, 0, 0, 734, 712, 1, 0, 0, 0, 734, 717, 1, 0, 0, 0, 734, 720, 1, 0, 0, 0, 734, 726, 1, 0, 0, 0, 735, 738, 1, 0, 0, 0, 736, 734, 1, 0, 0, 0, 736, 737, 1, 0, 0, 0, 737, 79, 1, 0, 0, 0, 738, 736, 1, 0, 0, 0, 739, 744, 3, 82, 41, 0, 740, 741, 5, 205, 0, 0, 741, 743, 3, 82, 41, 0, 742, 740, 1, 0, 0, 0, 743, 746, 1, 0, 0, 0, 744, 742, 1, 0, 0, 0, 744, 745, 1, 0, 0, 0, 745, 81, 1, 0, 0, 0, 746, 744, 1, 0, 0, 0, 747, 750, 3, 84, 42, 0, 748, 750, 3, 78, 39, 0, 749, 747, 1, 0, 0, 0, 749, 748, 1, 0, 0, 0, 750, 83, 1, 0, 0, 0, 751, 752, 5, 218, 0, 0, 752, 757, 3, 116, 58, 0, 753, 754, 5, 205, 0, 0, 754, 756, 3, 116, 58, 0, 755, 753, 1, 0, 0, 0, 756, 759, 1, 0, 0, 0, 757, 755, 1, 0, 0, 0, 757, 758, 1, 0, 0, 0, 758, 760, 1, 0, 0, 0, 759, 757, 1, 0, 0, 0, 760, 761, 5, 228, 0, 0, 761, 771, 1, 0, 0, 0, 762, 767, 3, 116, 58, 0, 763, 764, 5, 205, 0, 0, 764, 766, 3, 116, 58, 0, 765, 763, 1, 0, 0, 0, 766, 769, 1, 0, 0, 0, 767, 765, 1, 0, 0, 0, 767, 768, 1, 0, 0, 0, 768, 771, 1, 0, 0, 0, 769, 767, 1, 0, 0, 0, 770, 751, 1, 0, 0, 0, 770, 762, 1, 0, 0, 0, 771, 772, 1, 0, 0, 0, 772, 773, 5, 200, 0, 0, 773, 774, 3, 78, 39, 0, 774, 85, 1, 0, 0, 0, 775, 783, 5, 199, 0, 0, 776, 777, 3, 94, 47, 0, 777, 778, 5, 209, 0, 0, 778, 780, 1, 0, 0, 0, 779, 776, 1, 0, 0, 0, 779, 780, 1, 0, 0, 0, 780, 781, 1, 0, 0, 0, 781, 783, 3, 88, 44, 0, 782, 775, 1, 0, 0, 0, 782, 779, 1, 0, 0, 0, 783, 87, 1, 0, 0, 0, 784, 789, 3, 116, 58, 0, 785, 786, 5, 209, 0, 0, 786, 788, 3, 116, 58, 0, 787, 785, 1, 0, 0, 0, 788, 791, 1, 0, 0, 0, 789, 787, 1, 0, 0, 0, 789, 790, 1, 0, 0, 0, 790, 89, 1, 0, 0, 0, 791, 789, 1, 0, 0, 0, 792, 793, 6, 45, -1, 0, 793, 800, 3, 94, 47, 0, 794, 800, 3, 92, 46, 0, 795, 796, 5, 218, 0, 0, 796, 797, 3, 2, 1, 0, 797, 798, 5, 228, 0, 0, 798, 800, 1, 0, 0, 0, 799, 792, 1, 0, 0, 0, 799, 794, 1, 0, 0, 0, 799, 795, 1, 0, 0, 0, 800, 809, 1, 0, 0, 0, 801, 805, 10, 1, 0, 0, 802, 806, 3, 114, 57, 0, 803, 804, 5, 10, 0, 0, 804, 806, 3, 116, 58, 0, 805, 802, 1, 0, 0, 0, 805, 803, 1, 0, 0, 0, 806, 808, 1, 0, 0, 0, 807, 801, 1, 0, 0, 0, 808, 811, 1, 0, 0, 0, 809, 807, 1, 0, 0, 0, 809, 810, 1, 0, 0, 0, 810, 91, 1, 0, 0, 0, 811, 809, 1, 0, 0, 0, 812, 813, 3, 116, 58, 0, 813, 815, 5, 218, 0, 0, 814, 816, 3, 96, 48, 0, 815, 814, 1, 0, 0, 0, 815, 816, 1, 0, 0, 0, 816, 817, 1, 0, 0, 0, 817, 818, 5, 228, 0, 0, 818, 93, 1, 0, 0, 0, 819, 820, 3, 100, 50, 0, 820, 821, 5, 209, 0, 0, 821, 823, 1, 0, 0, 0, 822, 819, 1, 0, 0, 0, 822, 823, 1, 0, 0, 0, 823, 824, 1, 0, 0, 0, 824, 825, 3, 116, 58, 0, 825, 95, 1, 0, 0, 0, 826, 831, 3, 98, 49, 0, 827, 828, 5, 205, 0, 0, 828, 830, 3, 98, 49, 0, 829, 827, 1, 0, 0, 0, 830, 833, 1, 0, 0, 0, 831, 829, 1, 0, 0, 0, 831, 832, 1, 0, 0, 0, 832, 97, 1, 0, 0, 0, 833, 831, 1, 0, 0, 0, 834, 838, 3, 88, 44, 0, 835, 838, 3, 92, 46, 0, 836, 838, 3, 106, 53, 0, 837, 834, 1, 0, 0, 0, 837, 835, 1, 0, 0, 0, 837, 836, 1, 0, 0, 0, 838, 99, 1, 0, 0, 0, 839, 840, 3, 116, 58, 0, 840, 101, 1, 0, 0, 0, 841, 850, 5, 194, 0, 0, 842, 843, 5, 209, 0, 0, 843, 850, 7, 13, 0, 0, 844, 845, 5, 196, 0, 0, 845, 847, 5, 209, 0, 0, 846, 848, 7, 13, 0, 0, 847, 846, 1, 0, 0, 0, 847, 848, 1, 0, 0, 0, 848, 850, 1, 0, 0, 0, 849, 841, 1, 0, 0, 0, 849, 842, 1, 0, 0, 0, 849, 844, 1, 0, 0, 0, 850, 103, 1, 0, 0, 0, 851, 853, 7, 14, 0, 0, 852, 851, 1, 0, 0, 0, 852, 853, 1, 0, 0, 0, 853, 860, 1, 0, 0, 0, 854, 861, 3, 102, 51, 0, 855, 861, 5, 195, 0, 0, 856, 861, 5, 196, 0, 0, 857, 861, 5, 197, 0, 0, 858, 861, 5, 81, 0, 0, 859, 861, 5, 112, 0, 0, 860, 854, 1, 0, 0, 0, 860, 855, 1, 0, 0, 0, 860, 856, 1, 0, 0, 0, 860, 857, 1, 0, 0, 0, 860, 858, 1, 0, 0, 0, 860, 859, 1, 0, 0, 0, 861, 105, 1, 0, 0, 0, 862, 866, 3, 104, 52, 0, 863, 866, 5, 198, 0, 0, 864, 866, 5, 115, 0, 0, 865, 862, 1, 0, 0, 0, 865, 863, 1, 0, 0, 0, 865, 864, 1, 0, 0, 0, 866, 107, 1, 0, 0, 0, 867, 868, 7, 15, 0, 0, 868, 109, 1, 0, 0, 0, 869, 870, 7, 16, 0, 0, 870, 111, 1, 0, 0, 0, 871, 872, 7, 17, 0, 0, 872, 113, 1, 0, 0, 0, 873, 876, 5, 193, 0, 0, 874, 876, 3, 112, 56, 0, 875, 873, 1, 0, 0, 0, 875, 874, 1, 0, 0, 0, 876, 115, 1, 0, 0, 0, 877, 881, 5, 193, 0, 0, 878, 881, 3, 108, 54, 0, 879, 881, 3, 110, 55, 0, 880, 877, 1, 0, 0, 0, 880, 878, 1, 0, 0, 0, 880, 879, 1, 0, 0, 0, 881, 117, 1, 0, 0, 0, 882, 885, 3, 116, 58, 0, 883, 885, 5, 115, 0, 0, 884, 882, 1, 0, 0, 0, 884, 883, 1, 0, 0, 0, 885, 119, 1, 0, 0, 0, 886, 887, 5, 198, 0, 0, 887, 888, 5, 211, 0, 0, 888, 889, 3, 104, 52, 0, 889, 121, 1, 0, 0, 0, 115, 124, 134, 142, 145, 149, 152, 156, 159, 162, 165, 168, 171, 175, 179, 182, 185, 188, 191, 194, 203, 209, 236, 258, 266, 269, 275, 283, 286, 292, 294, 298, 303, 306, 309, 313, 317, 320, 322, 325, 329, 333, 336, 338, 340, 343, 348, 359, 365, 370, 377, 382, 386, 390, 395, 402, 410, 413, 416, 435, 449, 465, 477, 489, 497, 501, 508, 514, 522, 527, 536, 540, 571, 588, 600, 610, 613, 617, 620, 632, 649, 653, 659, 666, 678, 681, 685, 688, 699, 723, 732, 734, 736, 744, 749, 757, 767, 770, 779, 782, 789, 799, 805, 809, 815, 822, 831, 837, 847, 849, 852, 860, 865, 875, 880, 884] \ No newline at end of file +[4, 1, 234, 883, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 2, 50, 7, 50, 2, 51, 7, 51, 2, 52, 7, 52, 2, 53, 7, 53, 2, 54, 7, 54, 2, 55, 7, 55, 2, 56, 7, 56, 2, 57, 7, 57, 2, 58, 7, 58, 2, 59, 7, 59, 1, 0, 1, 0, 3, 0, 123, 8, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 131, 8, 1, 10, 1, 12, 1, 134, 9, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 141, 8, 2, 1, 3, 3, 3, 144, 8, 3, 1, 3, 1, 3, 3, 3, 148, 8, 3, 1, 3, 3, 3, 151, 8, 3, 1, 3, 1, 3, 3, 3, 155, 8, 3, 1, 3, 3, 3, 158, 8, 3, 1, 3, 3, 3, 161, 8, 3, 1, 3, 3, 3, 164, 8, 3, 1, 3, 3, 3, 167, 8, 3, 1, 3, 3, 3, 170, 8, 3, 1, 3, 1, 3, 3, 3, 174, 8, 3, 1, 3, 1, 3, 3, 3, 178, 8, 3, 1, 3, 3, 3, 181, 8, 3, 1, 3, 3, 3, 184, 8, 3, 1, 3, 3, 3, 187, 8, 3, 1, 3, 3, 3, 190, 8, 3, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 3, 5, 199, 8, 5, 1, 6, 1, 6, 1, 6, 1, 7, 3, 7, 205, 8, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 3, 11, 232, 8, 11, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 3, 15, 251, 8, 15, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 3, 17, 259, 8, 17, 1, 17, 3, 17, 262, 8, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 268, 8, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 3, 17, 276, 8, 17, 1, 17, 3, 17, 279, 8, 17, 1, 17, 1, 17, 1, 17, 1, 17, 5, 17, 285, 8, 17, 10, 17, 12, 17, 288, 9, 17, 1, 18, 3, 18, 291, 8, 18, 1, 18, 1, 18, 1, 18, 3, 18, 296, 8, 18, 1, 18, 3, 18, 299, 8, 18, 1, 18, 3, 18, 302, 8, 18, 1, 18, 1, 18, 3, 18, 306, 8, 18, 1, 18, 1, 18, 3, 18, 310, 8, 18, 1, 18, 3, 18, 313, 8, 18, 3, 18, 315, 8, 18, 1, 18, 3, 18, 318, 8, 18, 1, 18, 1, 18, 3, 18, 322, 8, 18, 1, 18, 1, 18, 3, 18, 326, 8, 18, 1, 18, 3, 18, 329, 8, 18, 3, 18, 331, 8, 18, 3, 18, 333, 8, 18, 1, 19, 3, 19, 336, 8, 19, 1, 19, 1, 19, 1, 19, 3, 19, 341, 8, 19, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 1, 20, 3, 20, 352, 8, 20, 1, 21, 1, 21, 1, 21, 1, 21, 3, 21, 358, 8, 21, 1, 22, 1, 22, 1, 22, 3, 22, 363, 8, 22, 1, 23, 1, 23, 1, 23, 5, 23, 368, 8, 23, 10, 23, 12, 23, 371, 9, 23, 1, 24, 1, 24, 3, 24, 375, 8, 24, 1, 24, 1, 24, 3, 24, 379, 8, 24, 1, 24, 1, 24, 3, 24, 383, 8, 24, 1, 25, 1, 25, 1, 25, 3, 25, 388, 8, 25, 1, 26, 1, 26, 1, 26, 5, 26, 393, 8, 26, 10, 26, 12, 26, 396, 9, 26, 1, 27, 1, 27, 1, 27, 1, 27, 1, 28, 3, 28, 403, 8, 28, 1, 28, 3, 28, 406, 8, 28, 1, 28, 3, 28, 409, 8, 28, 1, 29, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 31, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 1, 32, 3, 32, 428, 8, 32, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 1, 33, 3, 33, 442, 8, 33, 1, 34, 1, 34, 1, 34, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 456, 8, 35, 10, 35, 12, 35, 459, 9, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 468, 8, 35, 10, 35, 12, 35, 471, 9, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 5, 35, 480, 8, 35, 10, 35, 12, 35, 483, 9, 35, 1, 35, 1, 35, 1, 35, 1, 35, 1, 35, 3, 35, 490, 8, 35, 1, 35, 1, 35, 3, 35, 494, 8, 35, 1, 36, 1, 36, 1, 36, 5, 36, 499, 8, 36, 10, 36, 12, 36, 502, 9, 36, 1, 37, 1, 37, 1, 37, 3, 37, 507, 8, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 1, 37, 3, 37, 515, 8, 37, 1, 38, 1, 38, 1, 38, 3, 38, 520, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 4, 38, 527, 8, 38, 11, 38, 12, 38, 528, 1, 38, 1, 38, 3, 38, 533, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 564, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 581, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 593, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 603, 8, 38, 1, 38, 3, 38, 606, 8, 38, 1, 38, 1, 38, 3, 38, 610, 8, 38, 1, 38, 3, 38, 613, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 625, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 642, 8, 38, 1, 38, 1, 38, 3, 38, 646, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 652, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 659, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 671, 8, 38, 1, 38, 3, 38, 674, 8, 38, 1, 38, 1, 38, 3, 38, 678, 8, 38, 1, 38, 3, 38, 681, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 692, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 716, 8, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 1, 38, 3, 38, 725, 8, 38, 5, 38, 727, 8, 38, 10, 38, 12, 38, 730, 9, 38, 1, 39, 1, 39, 1, 39, 5, 39, 735, 8, 39, 10, 39, 12, 39, 738, 9, 39, 1, 40, 1, 40, 3, 40, 742, 8, 40, 1, 41, 1, 41, 1, 41, 1, 41, 5, 41, 748, 8, 41, 10, 41, 12, 41, 751, 9, 41, 1, 41, 1, 41, 1, 41, 1, 41, 1, 41, 5, 41, 758, 8, 41, 10, 41, 12, 41, 761, 9, 41, 3, 41, 763, 8, 41, 1, 41, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 42, 3, 42, 772, 8, 42, 1, 42, 3, 42, 775, 8, 42, 1, 43, 1, 43, 1, 43, 5, 43, 780, 8, 43, 10, 43, 12, 43, 783, 9, 43, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 1, 44, 3, 44, 792, 8, 44, 1, 44, 1, 44, 1, 44, 1, 44, 3, 44, 798, 8, 44, 5, 44, 800, 8, 44, 10, 44, 12, 44, 803, 9, 44, 1, 45, 1, 45, 1, 45, 3, 45, 808, 8, 45, 1, 45, 1, 45, 1, 46, 1, 46, 1, 46, 3, 46, 815, 8, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 47, 5, 47, 822, 8, 47, 10, 47, 12, 47, 825, 9, 47, 1, 48, 1, 48, 1, 48, 3, 48, 830, 8, 48, 1, 49, 1, 49, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 1, 50, 3, 50, 840, 8, 50, 3, 50, 842, 8, 50, 1, 51, 3, 51, 845, 8, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 1, 51, 3, 51, 853, 8, 51, 1, 52, 1, 52, 1, 52, 3, 52, 858, 8, 52, 1, 53, 1, 53, 1, 54, 1, 54, 1, 55, 1, 55, 1, 56, 1, 56, 3, 56, 868, 8, 56, 1, 57, 1, 57, 1, 57, 3, 57, 873, 8, 57, 1, 58, 1, 58, 3, 58, 877, 8, 58, 1, 59, 1, 59, 1, 59, 1, 59, 1, 59, 0, 3, 34, 76, 88, 60, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 0, 18, 2, 0, 31, 31, 140, 140, 2, 0, 83, 83, 95, 95, 2, 0, 70, 70, 100, 100, 3, 0, 4, 4, 8, 8, 12, 12, 4, 0, 4, 4, 7, 8, 12, 12, 146, 146, 2, 0, 95, 95, 139, 139, 2, 0, 4, 4, 8, 8, 2, 0, 117, 117, 205, 205, 2, 0, 11, 11, 41, 42, 2, 0, 61, 61, 92, 92, 2, 0, 132, 132, 142, 142, 3, 0, 17, 17, 94, 94, 169, 169, 2, 0, 78, 78, 97, 97, 1, 0, 195, 196, 2, 0, 207, 207, 222, 222, 8, 0, 36, 36, 75, 75, 107, 107, 109, 109, 131, 131, 144, 144, 184, 184, 189, 189, 12, 0, 2, 35, 37, 74, 76, 80, 82, 106, 108, 108, 110, 111, 113, 114, 116, 129, 132, 143, 145, 183, 185, 188, 190, 191, 4, 0, 35, 35, 61, 61, 76, 76, 90, 90, 993, 0, 122, 1, 0, 0, 0, 2, 126, 1, 0, 0, 0, 4, 140, 1, 0, 0, 0, 6, 143, 1, 0, 0, 0, 8, 191, 1, 0, 0, 0, 10, 194, 1, 0, 0, 0, 12, 200, 1, 0, 0, 0, 14, 204, 1, 0, 0, 0, 16, 210, 1, 0, 0, 0, 18, 217, 1, 0, 0, 0, 20, 220, 1, 0, 0, 0, 22, 223, 1, 0, 0, 0, 24, 233, 1, 0, 0, 0, 26, 236, 1, 0, 0, 0, 28, 240, 1, 0, 0, 0, 30, 244, 1, 0, 0, 0, 32, 252, 1, 0, 0, 0, 34, 267, 1, 0, 0, 0, 36, 332, 1, 0, 0, 0, 38, 340, 1, 0, 0, 0, 40, 351, 1, 0, 0, 0, 42, 353, 1, 0, 0, 0, 44, 359, 1, 0, 0, 0, 46, 364, 1, 0, 0, 0, 48, 372, 1, 0, 0, 0, 50, 384, 1, 0, 0, 0, 52, 389, 1, 0, 0, 0, 54, 397, 1, 0, 0, 0, 56, 402, 1, 0, 0, 0, 58, 410, 1, 0, 0, 0, 60, 414, 1, 0, 0, 0, 62, 418, 1, 0, 0, 0, 64, 427, 1, 0, 0, 0, 66, 441, 1, 0, 0, 0, 68, 443, 1, 0, 0, 0, 70, 493, 1, 0, 0, 0, 72, 495, 1, 0, 0, 0, 74, 514, 1, 0, 0, 0, 76, 645, 1, 0, 0, 0, 78, 731, 1, 0, 0, 0, 80, 741, 1, 0, 0, 0, 82, 762, 1, 0, 0, 0, 84, 774, 1, 0, 0, 0, 86, 776, 1, 0, 0, 0, 88, 791, 1, 0, 0, 0, 90, 804, 1, 0, 0, 0, 92, 814, 1, 0, 0, 0, 94, 818, 1, 0, 0, 0, 96, 829, 1, 0, 0, 0, 98, 831, 1, 0, 0, 0, 100, 841, 1, 0, 0, 0, 102, 844, 1, 0, 0, 0, 104, 857, 1, 0, 0, 0, 106, 859, 1, 0, 0, 0, 108, 861, 1, 0, 0, 0, 110, 863, 1, 0, 0, 0, 112, 867, 1, 0, 0, 0, 114, 872, 1, 0, 0, 0, 116, 876, 1, 0, 0, 0, 118, 878, 1, 0, 0, 0, 120, 123, 3, 2, 1, 0, 121, 123, 3, 6, 3, 0, 122, 120, 1, 0, 0, 0, 122, 121, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 125, 5, 0, 0, 1, 125, 1, 1, 0, 0, 0, 126, 132, 3, 4, 2, 0, 127, 128, 5, 175, 0, 0, 128, 129, 5, 4, 0, 0, 129, 131, 3, 4, 2, 0, 130, 127, 1, 0, 0, 0, 131, 134, 1, 0, 0, 0, 132, 130, 1, 0, 0, 0, 132, 133, 1, 0, 0, 0, 133, 3, 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 135, 141, 3, 6, 3, 0, 136, 137, 5, 218, 0, 0, 137, 138, 3, 2, 1, 0, 138, 139, 5, 228, 0, 0, 139, 141, 1, 0, 0, 0, 140, 135, 1, 0, 0, 0, 140, 136, 1, 0, 0, 0, 141, 5, 1, 0, 0, 0, 142, 144, 3, 8, 4, 0, 143, 142, 1, 0, 0, 0, 143, 144, 1, 0, 0, 0, 144, 145, 1, 0, 0, 0, 145, 147, 5, 145, 0, 0, 146, 148, 5, 48, 0, 0, 147, 146, 1, 0, 0, 0, 147, 148, 1, 0, 0, 0, 148, 150, 1, 0, 0, 0, 149, 151, 3, 10, 5, 0, 150, 149, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 152, 1, 0, 0, 0, 152, 154, 3, 72, 36, 0, 153, 155, 3, 12, 6, 0, 154, 153, 1, 0, 0, 0, 154, 155, 1, 0, 0, 0, 155, 157, 1, 0, 0, 0, 156, 158, 3, 14, 7, 0, 157, 156, 1, 0, 0, 0, 157, 158, 1, 0, 0, 0, 158, 160, 1, 0, 0, 0, 159, 161, 3, 16, 8, 0, 160, 159, 1, 0, 0, 0, 160, 161, 1, 0, 0, 0, 161, 163, 1, 0, 0, 0, 162, 164, 3, 18, 9, 0, 163, 162, 1, 0, 0, 0, 163, 164, 1, 0, 0, 0, 164, 166, 1, 0, 0, 0, 165, 167, 3, 20, 10, 0, 166, 165, 1, 0, 0, 0, 166, 167, 1, 0, 0, 0, 167, 169, 1, 0, 0, 0, 168, 170, 3, 22, 11, 0, 169, 168, 1, 0, 0, 0, 169, 170, 1, 0, 0, 0, 170, 173, 1, 0, 0, 0, 171, 172, 5, 188, 0, 0, 172, 174, 7, 0, 0, 0, 173, 171, 1, 0, 0, 0, 173, 174, 1, 0, 0, 0, 174, 177, 1, 0, 0, 0, 175, 176, 5, 188, 0, 0, 176, 178, 5, 168, 0, 0, 177, 175, 1, 0, 0, 0, 177, 178, 1, 0, 0, 0, 178, 180, 1, 0, 0, 0, 179, 181, 3, 24, 12, 0, 180, 179, 1, 0, 0, 0, 180, 181, 1, 0, 0, 0, 181, 183, 1, 0, 0, 0, 182, 184, 3, 26, 13, 0, 183, 182, 1, 0, 0, 0, 183, 184, 1, 0, 0, 0, 184, 186, 1, 0, 0, 0, 185, 187, 3, 30, 15, 0, 186, 185, 1, 0, 0, 0, 186, 187, 1, 0, 0, 0, 187, 189, 1, 0, 0, 0, 188, 190, 3, 32, 16, 0, 189, 188, 1, 0, 0, 0, 189, 190, 1, 0, 0, 0, 190, 7, 1, 0, 0, 0, 191, 192, 5, 188, 0, 0, 192, 193, 3, 72, 36, 0, 193, 9, 1, 0, 0, 0, 194, 195, 5, 167, 0, 0, 195, 198, 5, 196, 0, 0, 196, 197, 5, 188, 0, 0, 197, 199, 5, 163, 0, 0, 198, 196, 1, 0, 0, 0, 198, 199, 1, 0, 0, 0, 199, 11, 1, 0, 0, 0, 200, 201, 5, 67, 0, 0, 201, 202, 3, 34, 17, 0, 202, 13, 1, 0, 0, 0, 203, 205, 7, 1, 0, 0, 204, 203, 1, 0, 0, 0, 204, 205, 1, 0, 0, 0, 205, 206, 1, 0, 0, 0, 206, 207, 5, 9, 0, 0, 207, 208, 5, 89, 0, 0, 208, 209, 3, 72, 36, 0, 209, 15, 1, 0, 0, 0, 210, 211, 5, 187, 0, 0, 211, 212, 3, 114, 57, 0, 212, 213, 5, 10, 0, 0, 213, 214, 5, 218, 0, 0, 214, 215, 3, 56, 28, 0, 215, 216, 5, 228, 0, 0, 216, 17, 1, 0, 0, 0, 217, 218, 5, 128, 0, 0, 218, 219, 3, 76, 38, 0, 219, 19, 1, 0, 0, 0, 220, 221, 5, 186, 0, 0, 221, 222, 3, 76, 38, 0, 222, 21, 1, 0, 0, 0, 223, 224, 5, 72, 0, 0, 224, 231, 5, 18, 0, 0, 225, 226, 7, 0, 0, 0, 226, 227, 5, 218, 0, 0, 227, 228, 3, 72, 36, 0, 228, 229, 5, 228, 0, 0, 229, 232, 1, 0, 0, 0, 230, 232, 3, 72, 36, 0, 231, 225, 1, 0, 0, 0, 231, 230, 1, 0, 0, 0, 232, 23, 1, 0, 0, 0, 233, 234, 5, 73, 0, 0, 234, 235, 3, 76, 38, 0, 235, 25, 1, 0, 0, 0, 236, 237, 5, 121, 0, 0, 237, 238, 5, 18, 0, 0, 238, 239, 3, 46, 23, 0, 239, 27, 1, 0, 0, 0, 240, 241, 5, 121, 0, 0, 241, 242, 5, 18, 0, 0, 242, 243, 3, 72, 36, 0, 243, 29, 1, 0, 0, 0, 244, 245, 5, 98, 0, 0, 245, 250, 3, 44, 22, 0, 246, 247, 5, 188, 0, 0, 247, 251, 5, 163, 0, 0, 248, 249, 5, 18, 0, 0, 249, 251, 3, 72, 36, 0, 250, 246, 1, 0, 0, 0, 250, 248, 1, 0, 0, 0, 250, 251, 1, 0, 0, 0, 251, 31, 1, 0, 0, 0, 252, 253, 5, 149, 0, 0, 253, 254, 3, 52, 26, 0, 254, 33, 1, 0, 0, 0, 255, 256, 6, 17, -1, 0, 256, 258, 3, 88, 44, 0, 257, 259, 5, 60, 0, 0, 258, 257, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 261, 1, 0, 0, 0, 260, 262, 3, 42, 21, 0, 261, 260, 1, 0, 0, 0, 261, 262, 1, 0, 0, 0, 262, 268, 1, 0, 0, 0, 263, 264, 5, 218, 0, 0, 264, 265, 3, 34, 17, 0, 265, 266, 5, 228, 0, 0, 266, 268, 1, 0, 0, 0, 267, 255, 1, 0, 0, 0, 267, 263, 1, 0, 0, 0, 268, 286, 1, 0, 0, 0, 269, 270, 10, 3, 0, 0, 270, 271, 3, 38, 19, 0, 271, 272, 3, 34, 17, 4, 272, 285, 1, 0, 0, 0, 273, 275, 10, 4, 0, 0, 274, 276, 7, 2, 0, 0, 275, 274, 1, 0, 0, 0, 275, 276, 1, 0, 0, 0, 276, 278, 1, 0, 0, 0, 277, 279, 3, 36, 18, 0, 278, 277, 1, 0, 0, 0, 278, 279, 1, 0, 0, 0, 279, 280, 1, 0, 0, 0, 280, 281, 5, 89, 0, 0, 281, 282, 3, 34, 17, 0, 282, 283, 3, 40, 20, 0, 283, 285, 1, 0, 0, 0, 284, 269, 1, 0, 0, 0, 284, 273, 1, 0, 0, 0, 285, 288, 1, 0, 0, 0, 286, 284, 1, 0, 0, 0, 286, 287, 1, 0, 0, 0, 287, 35, 1, 0, 0, 0, 288, 286, 1, 0, 0, 0, 289, 291, 7, 3, 0, 0, 290, 289, 1, 0, 0, 0, 290, 291, 1, 0, 0, 0, 291, 292, 1, 0, 0, 0, 292, 299, 5, 83, 0, 0, 293, 295, 5, 83, 0, 0, 294, 296, 7, 3, 0, 0, 295, 294, 1, 0, 0, 0, 295, 296, 1, 0, 0, 0, 296, 299, 1, 0, 0, 0, 297, 299, 7, 3, 0, 0, 298, 290, 1, 0, 0, 0, 298, 293, 1, 0, 0, 0, 298, 297, 1, 0, 0, 0, 299, 333, 1, 0, 0, 0, 300, 302, 7, 4, 0, 0, 301, 300, 1, 0, 0, 0, 301, 302, 1, 0, 0, 0, 302, 303, 1, 0, 0, 0, 303, 305, 7, 5, 0, 0, 304, 306, 5, 122, 0, 0, 305, 304, 1, 0, 0, 0, 305, 306, 1, 0, 0, 0, 306, 315, 1, 0, 0, 0, 307, 309, 7, 5, 0, 0, 308, 310, 5, 122, 0, 0, 309, 308, 1, 0, 0, 0, 309, 310, 1, 0, 0, 0, 310, 312, 1, 0, 0, 0, 311, 313, 7, 4, 0, 0, 312, 311, 1, 0, 0, 0, 312, 313, 1, 0, 0, 0, 313, 315, 1, 0, 0, 0, 314, 301, 1, 0, 0, 0, 314, 307, 1, 0, 0, 0, 315, 333, 1, 0, 0, 0, 316, 318, 7, 6, 0, 0, 317, 316, 1, 0, 0, 0, 317, 318, 1, 0, 0, 0, 318, 319, 1, 0, 0, 0, 319, 321, 5, 68, 0, 0, 320, 322, 5, 122, 0, 0, 321, 320, 1, 0, 0, 0, 321, 322, 1, 0, 0, 0, 322, 331, 1, 0, 0, 0, 323, 325, 5, 68, 0, 0, 324, 326, 5, 122, 0, 0, 325, 324, 1, 0, 0, 0, 325, 326, 1, 0, 0, 0, 326, 328, 1, 0, 0, 0, 327, 329, 7, 6, 0, 0, 328, 327, 1, 0, 0, 0, 328, 329, 1, 0, 0, 0, 329, 331, 1, 0, 0, 0, 330, 317, 1, 0, 0, 0, 330, 323, 1, 0, 0, 0, 331, 333, 1, 0, 0, 0, 332, 298, 1, 0, 0, 0, 332, 314, 1, 0, 0, 0, 332, 330, 1, 0, 0, 0, 333, 37, 1, 0, 0, 0, 334, 336, 7, 2, 0, 0, 335, 334, 1, 0, 0, 0, 335, 336, 1, 0, 0, 0, 336, 337, 1, 0, 0, 0, 337, 338, 5, 30, 0, 0, 338, 341, 5, 89, 0, 0, 339, 341, 5, 205, 0, 0, 340, 335, 1, 0, 0, 0, 340, 339, 1, 0, 0, 0, 341, 39, 1, 0, 0, 0, 342, 343, 5, 118, 0, 0, 343, 352, 3, 72, 36, 0, 344, 345, 5, 178, 0, 0, 345, 346, 5, 218, 0, 0, 346, 347, 3, 72, 36, 0, 347, 348, 5, 228, 0, 0, 348, 352, 1, 0, 0, 0, 349, 350, 5, 178, 0, 0, 350, 352, 3, 72, 36, 0, 351, 342, 1, 0, 0, 0, 351, 344, 1, 0, 0, 0, 351, 349, 1, 0, 0, 0, 352, 41, 1, 0, 0, 0, 353, 354, 5, 143, 0, 0, 354, 357, 3, 50, 25, 0, 355, 356, 5, 117, 0, 0, 356, 358, 3, 50, 25, 0, 357, 355, 1, 0, 0, 0, 357, 358, 1, 0, 0, 0, 358, 43, 1, 0, 0, 0, 359, 362, 3, 76, 38, 0, 360, 361, 7, 7, 0, 0, 361, 363, 3, 76, 38, 0, 362, 360, 1, 0, 0, 0, 362, 363, 1, 0, 0, 0, 363, 45, 1, 0, 0, 0, 364, 369, 3, 48, 24, 0, 365, 366, 5, 205, 0, 0, 366, 368, 3, 48, 24, 0, 367, 365, 1, 0, 0, 0, 368, 371, 1, 0, 0, 0, 369, 367, 1, 0, 0, 0, 369, 370, 1, 0, 0, 0, 370, 47, 1, 0, 0, 0, 371, 369, 1, 0, 0, 0, 372, 374, 3, 76, 38, 0, 373, 375, 7, 8, 0, 0, 374, 373, 1, 0, 0, 0, 374, 375, 1, 0, 0, 0, 375, 378, 1, 0, 0, 0, 376, 377, 5, 116, 0, 0, 377, 379, 7, 9, 0, 0, 378, 376, 1, 0, 0, 0, 378, 379, 1, 0, 0, 0, 379, 382, 1, 0, 0, 0, 380, 381, 5, 25, 0, 0, 381, 383, 5, 198, 0, 0, 382, 380, 1, 0, 0, 0, 382, 383, 1, 0, 0, 0, 383, 49, 1, 0, 0, 0, 384, 387, 3, 102, 51, 0, 385, 386, 5, 230, 0, 0, 386, 388, 3, 102, 51, 0, 387, 385, 1, 0, 0, 0, 387, 388, 1, 0, 0, 0, 388, 51, 1, 0, 0, 0, 389, 394, 3, 54, 27, 0, 390, 391, 5, 205, 0, 0, 391, 393, 3, 54, 27, 0, 392, 390, 1, 0, 0, 0, 393, 396, 1, 0, 0, 0, 394, 392, 1, 0, 0, 0, 394, 395, 1, 0, 0, 0, 395, 53, 1, 0, 0, 0, 396, 394, 1, 0, 0, 0, 397, 398, 3, 114, 57, 0, 398, 399, 5, 211, 0, 0, 399, 400, 3, 104, 52, 0, 400, 55, 1, 0, 0, 0, 401, 403, 3, 58, 29, 0, 402, 401, 1, 0, 0, 0, 402, 403, 1, 0, 0, 0, 403, 405, 1, 0, 0, 0, 404, 406, 3, 60, 30, 0, 405, 404, 1, 0, 0, 0, 405, 406, 1, 0, 0, 0, 406, 408, 1, 0, 0, 0, 407, 409, 3, 62, 31, 0, 408, 407, 1, 0, 0, 0, 408, 409, 1, 0, 0, 0, 409, 57, 1, 0, 0, 0, 410, 411, 5, 125, 0, 0, 411, 412, 5, 18, 0, 0, 412, 413, 3, 72, 36, 0, 413, 59, 1, 0, 0, 0, 414, 415, 5, 121, 0, 0, 415, 416, 5, 18, 0, 0, 416, 417, 3, 46, 23, 0, 417, 61, 1, 0, 0, 0, 418, 419, 7, 10, 0, 0, 419, 420, 3, 64, 32, 0, 420, 63, 1, 0, 0, 0, 421, 428, 3, 66, 33, 0, 422, 423, 5, 16, 0, 0, 423, 424, 3, 66, 33, 0, 424, 425, 5, 6, 0, 0, 425, 426, 3, 66, 33, 0, 426, 428, 1, 0, 0, 0, 427, 421, 1, 0, 0, 0, 427, 422, 1, 0, 0, 0, 428, 65, 1, 0, 0, 0, 429, 430, 5, 32, 0, 0, 430, 442, 5, 141, 0, 0, 431, 432, 5, 174, 0, 0, 432, 442, 5, 127, 0, 0, 433, 434, 5, 174, 0, 0, 434, 442, 5, 63, 0, 0, 435, 436, 3, 102, 51, 0, 436, 437, 5, 127, 0, 0, 437, 442, 1, 0, 0, 0, 438, 439, 3, 102, 51, 0, 439, 440, 5, 63, 0, 0, 440, 442, 1, 0, 0, 0, 441, 429, 1, 0, 0, 0, 441, 431, 1, 0, 0, 0, 441, 433, 1, 0, 0, 0, 441, 435, 1, 0, 0, 0, 441, 438, 1, 0, 0, 0, 442, 67, 1, 0, 0, 0, 443, 444, 3, 76, 38, 0, 444, 445, 5, 0, 0, 1, 445, 69, 1, 0, 0, 0, 446, 494, 3, 114, 57, 0, 447, 448, 3, 114, 57, 0, 448, 449, 5, 218, 0, 0, 449, 450, 3, 114, 57, 0, 450, 457, 3, 70, 35, 0, 451, 452, 5, 205, 0, 0, 452, 453, 3, 114, 57, 0, 453, 454, 3, 70, 35, 0, 454, 456, 1, 0, 0, 0, 455, 451, 1, 0, 0, 0, 456, 459, 1, 0, 0, 0, 457, 455, 1, 0, 0, 0, 457, 458, 1, 0, 0, 0, 458, 460, 1, 0, 0, 0, 459, 457, 1, 0, 0, 0, 460, 461, 5, 228, 0, 0, 461, 494, 1, 0, 0, 0, 462, 463, 3, 114, 57, 0, 463, 464, 5, 218, 0, 0, 464, 469, 3, 118, 59, 0, 465, 466, 5, 205, 0, 0, 466, 468, 3, 118, 59, 0, 467, 465, 1, 0, 0, 0, 468, 471, 1, 0, 0, 0, 469, 467, 1, 0, 0, 0, 469, 470, 1, 0, 0, 0, 470, 472, 1, 0, 0, 0, 471, 469, 1, 0, 0, 0, 472, 473, 5, 228, 0, 0, 473, 494, 1, 0, 0, 0, 474, 475, 3, 114, 57, 0, 475, 476, 5, 218, 0, 0, 476, 481, 3, 70, 35, 0, 477, 478, 5, 205, 0, 0, 478, 480, 3, 70, 35, 0, 479, 477, 1, 0, 0, 0, 480, 483, 1, 0, 0, 0, 481, 479, 1, 0, 0, 0, 481, 482, 1, 0, 0, 0, 482, 484, 1, 0, 0, 0, 483, 481, 1, 0, 0, 0, 484, 485, 5, 228, 0, 0, 485, 494, 1, 0, 0, 0, 486, 487, 3, 114, 57, 0, 487, 489, 5, 218, 0, 0, 488, 490, 3, 72, 36, 0, 489, 488, 1, 0, 0, 0, 489, 490, 1, 0, 0, 0, 490, 491, 1, 0, 0, 0, 491, 492, 5, 228, 0, 0, 492, 494, 1, 0, 0, 0, 493, 446, 1, 0, 0, 0, 493, 447, 1, 0, 0, 0, 493, 462, 1, 0, 0, 0, 493, 474, 1, 0, 0, 0, 493, 486, 1, 0, 0, 0, 494, 71, 1, 0, 0, 0, 495, 500, 3, 74, 37, 0, 496, 497, 5, 205, 0, 0, 497, 499, 3, 74, 37, 0, 498, 496, 1, 0, 0, 0, 499, 502, 1, 0, 0, 0, 500, 498, 1, 0, 0, 0, 500, 501, 1, 0, 0, 0, 501, 73, 1, 0, 0, 0, 502, 500, 1, 0, 0, 0, 503, 504, 3, 92, 46, 0, 504, 505, 5, 209, 0, 0, 505, 507, 1, 0, 0, 0, 506, 503, 1, 0, 0, 0, 506, 507, 1, 0, 0, 0, 507, 508, 1, 0, 0, 0, 508, 515, 5, 201, 0, 0, 509, 510, 5, 218, 0, 0, 510, 511, 3, 2, 1, 0, 511, 512, 5, 228, 0, 0, 512, 515, 1, 0, 0, 0, 513, 515, 3, 76, 38, 0, 514, 506, 1, 0, 0, 0, 514, 509, 1, 0, 0, 0, 514, 513, 1, 0, 0, 0, 515, 75, 1, 0, 0, 0, 516, 517, 6, 38, -1, 0, 517, 519, 5, 19, 0, 0, 518, 520, 3, 76, 38, 0, 519, 518, 1, 0, 0, 0, 519, 520, 1, 0, 0, 0, 520, 526, 1, 0, 0, 0, 521, 522, 5, 185, 0, 0, 522, 523, 3, 76, 38, 0, 523, 524, 5, 162, 0, 0, 524, 525, 3, 76, 38, 0, 525, 527, 1, 0, 0, 0, 526, 521, 1, 0, 0, 0, 527, 528, 1, 0, 0, 0, 528, 526, 1, 0, 0, 0, 528, 529, 1, 0, 0, 0, 529, 532, 1, 0, 0, 0, 530, 531, 5, 51, 0, 0, 531, 533, 3, 76, 38, 0, 532, 530, 1, 0, 0, 0, 532, 533, 1, 0, 0, 0, 533, 534, 1, 0, 0, 0, 534, 535, 5, 52, 0, 0, 535, 646, 1, 0, 0, 0, 536, 537, 5, 20, 0, 0, 537, 538, 5, 218, 0, 0, 538, 539, 3, 76, 38, 0, 539, 540, 5, 10, 0, 0, 540, 541, 3, 70, 35, 0, 541, 542, 5, 228, 0, 0, 542, 646, 1, 0, 0, 0, 543, 544, 5, 35, 0, 0, 544, 646, 5, 198, 0, 0, 545, 546, 5, 58, 0, 0, 546, 547, 5, 218, 0, 0, 547, 548, 3, 106, 53, 0, 548, 549, 5, 67, 0, 0, 549, 550, 3, 76, 38, 0, 550, 551, 5, 228, 0, 0, 551, 646, 1, 0, 0, 0, 552, 553, 5, 85, 0, 0, 553, 554, 3, 76, 38, 0, 554, 555, 3, 106, 53, 0, 555, 646, 1, 0, 0, 0, 556, 557, 5, 154, 0, 0, 557, 558, 5, 218, 0, 0, 558, 559, 3, 76, 38, 0, 559, 560, 5, 67, 0, 0, 560, 563, 3, 76, 38, 0, 561, 562, 5, 64, 0, 0, 562, 564, 3, 76, 38, 0, 563, 561, 1, 0, 0, 0, 563, 564, 1, 0, 0, 0, 564, 565, 1, 0, 0, 0, 565, 566, 5, 228, 0, 0, 566, 646, 1, 0, 0, 0, 567, 568, 5, 165, 0, 0, 568, 646, 5, 198, 0, 0, 569, 570, 5, 170, 0, 0, 570, 571, 5, 218, 0, 0, 571, 572, 7, 11, 0, 0, 572, 573, 5, 198, 0, 0, 573, 574, 5, 67, 0, 0, 574, 575, 3, 76, 38, 0, 575, 576, 5, 228, 0, 0, 576, 646, 1, 0, 0, 0, 577, 578, 3, 114, 57, 0, 578, 580, 5, 218, 0, 0, 579, 581, 3, 72, 36, 0, 580, 579, 1, 0, 0, 0, 580, 581, 1, 0, 0, 0, 581, 582, 1, 0, 0, 0, 582, 583, 5, 228, 0, 0, 583, 584, 1, 0, 0, 0, 584, 585, 5, 124, 0, 0, 585, 586, 5, 218, 0, 0, 586, 587, 3, 56, 28, 0, 587, 588, 5, 228, 0, 0, 588, 646, 1, 0, 0, 0, 589, 590, 3, 114, 57, 0, 590, 592, 5, 218, 0, 0, 591, 593, 3, 72, 36, 0, 592, 591, 1, 0, 0, 0, 592, 593, 1, 0, 0, 0, 593, 594, 1, 0, 0, 0, 594, 595, 5, 228, 0, 0, 595, 596, 1, 0, 0, 0, 596, 597, 5, 124, 0, 0, 597, 598, 3, 114, 57, 0, 598, 646, 1, 0, 0, 0, 599, 605, 3, 114, 57, 0, 600, 602, 5, 218, 0, 0, 601, 603, 3, 72, 36, 0, 602, 601, 1, 0, 0, 0, 602, 603, 1, 0, 0, 0, 603, 604, 1, 0, 0, 0, 604, 606, 5, 228, 0, 0, 605, 600, 1, 0, 0, 0, 605, 606, 1, 0, 0, 0, 606, 607, 1, 0, 0, 0, 607, 609, 5, 218, 0, 0, 608, 610, 5, 48, 0, 0, 609, 608, 1, 0, 0, 0, 609, 610, 1, 0, 0, 0, 610, 612, 1, 0, 0, 0, 611, 613, 3, 78, 39, 0, 612, 611, 1, 0, 0, 0, 612, 613, 1, 0, 0, 0, 613, 614, 1, 0, 0, 0, 614, 615, 5, 228, 0, 0, 615, 646, 1, 0, 0, 0, 616, 646, 3, 104, 52, 0, 617, 618, 5, 207, 0, 0, 618, 646, 3, 76, 38, 17, 619, 620, 5, 114, 0, 0, 620, 646, 3, 76, 38, 12, 621, 622, 3, 92, 46, 0, 622, 623, 5, 209, 0, 0, 623, 625, 1, 0, 0, 0, 624, 621, 1, 0, 0, 0, 624, 625, 1, 0, 0, 0, 625, 626, 1, 0, 0, 0, 626, 646, 5, 201, 0, 0, 627, 628, 5, 218, 0, 0, 628, 629, 3, 2, 1, 0, 629, 630, 5, 228, 0, 0, 630, 646, 1, 0, 0, 0, 631, 632, 5, 218, 0, 0, 632, 633, 3, 76, 38, 0, 633, 634, 5, 228, 0, 0, 634, 646, 1, 0, 0, 0, 635, 636, 5, 218, 0, 0, 636, 637, 3, 72, 36, 0, 637, 638, 5, 228, 0, 0, 638, 646, 1, 0, 0, 0, 639, 641, 5, 216, 0, 0, 640, 642, 3, 72, 36, 0, 641, 640, 1, 0, 0, 0, 641, 642, 1, 0, 0, 0, 642, 643, 1, 0, 0, 0, 643, 646, 5, 227, 0, 0, 644, 646, 3, 84, 42, 0, 645, 516, 1, 0, 0, 0, 645, 536, 1, 0, 0, 0, 645, 543, 1, 0, 0, 0, 645, 545, 1, 0, 0, 0, 645, 552, 1, 0, 0, 0, 645, 556, 1, 0, 0, 0, 645, 567, 1, 0, 0, 0, 645, 569, 1, 0, 0, 0, 645, 577, 1, 0, 0, 0, 645, 589, 1, 0, 0, 0, 645, 599, 1, 0, 0, 0, 645, 616, 1, 0, 0, 0, 645, 617, 1, 0, 0, 0, 645, 619, 1, 0, 0, 0, 645, 624, 1, 0, 0, 0, 645, 627, 1, 0, 0, 0, 645, 631, 1, 0, 0, 0, 645, 635, 1, 0, 0, 0, 645, 639, 1, 0, 0, 0, 645, 644, 1, 0, 0, 0, 646, 728, 1, 0, 0, 0, 647, 651, 10, 16, 0, 0, 648, 652, 5, 201, 0, 0, 649, 652, 5, 230, 0, 0, 650, 652, 5, 221, 0, 0, 651, 648, 1, 0, 0, 0, 651, 649, 1, 0, 0, 0, 651, 650, 1, 0, 0, 0, 652, 653, 1, 0, 0, 0, 653, 727, 3, 76, 38, 17, 654, 658, 10, 15, 0, 0, 655, 659, 5, 222, 0, 0, 656, 659, 5, 207, 0, 0, 657, 659, 5, 206, 0, 0, 658, 655, 1, 0, 0, 0, 658, 656, 1, 0, 0, 0, 658, 657, 1, 0, 0, 0, 659, 660, 1, 0, 0, 0, 660, 727, 3, 76, 38, 16, 661, 680, 10, 14, 0, 0, 662, 681, 5, 210, 0, 0, 663, 681, 5, 211, 0, 0, 664, 681, 5, 220, 0, 0, 665, 681, 5, 217, 0, 0, 666, 681, 5, 212, 0, 0, 667, 681, 5, 219, 0, 0, 668, 681, 5, 213, 0, 0, 669, 671, 5, 70, 0, 0, 670, 669, 1, 0, 0, 0, 670, 671, 1, 0, 0, 0, 671, 673, 1, 0, 0, 0, 672, 674, 5, 114, 0, 0, 673, 672, 1, 0, 0, 0, 673, 674, 1, 0, 0, 0, 674, 675, 1, 0, 0, 0, 675, 681, 5, 79, 0, 0, 676, 678, 5, 114, 0, 0, 677, 676, 1, 0, 0, 0, 677, 678, 1, 0, 0, 0, 678, 679, 1, 0, 0, 0, 679, 681, 7, 12, 0, 0, 680, 662, 1, 0, 0, 0, 680, 663, 1, 0, 0, 0, 680, 664, 1, 0, 0, 0, 680, 665, 1, 0, 0, 0, 680, 666, 1, 0, 0, 0, 680, 667, 1, 0, 0, 0, 680, 668, 1, 0, 0, 0, 680, 670, 1, 0, 0, 0, 680, 677, 1, 0, 0, 0, 681, 682, 1, 0, 0, 0, 682, 727, 3, 76, 38, 15, 683, 684, 10, 11, 0, 0, 684, 685, 5, 6, 0, 0, 685, 727, 3, 76, 38, 12, 686, 687, 10, 10, 0, 0, 687, 688, 5, 120, 0, 0, 688, 727, 3, 76, 38, 11, 689, 691, 10, 9, 0, 0, 690, 692, 5, 114, 0, 0, 691, 690, 1, 0, 0, 0, 691, 692, 1, 0, 0, 0, 692, 693, 1, 0, 0, 0, 693, 694, 5, 16, 0, 0, 694, 695, 3, 76, 38, 0, 695, 696, 5, 6, 0, 0, 696, 697, 3, 76, 38, 10, 697, 727, 1, 0, 0, 0, 698, 699, 10, 8, 0, 0, 699, 700, 5, 223, 0, 0, 700, 701, 3, 76, 38, 0, 701, 702, 5, 204, 0, 0, 702, 703, 3, 76, 38, 8, 703, 727, 1, 0, 0, 0, 704, 705, 10, 19, 0, 0, 705, 706, 5, 216, 0, 0, 706, 707, 3, 76, 38, 0, 707, 708, 5, 227, 0, 0, 708, 727, 1, 0, 0, 0, 709, 710, 10, 18, 0, 0, 710, 711, 5, 209, 0, 0, 711, 727, 5, 196, 0, 0, 712, 713, 10, 13, 0, 0, 713, 715, 5, 87, 0, 0, 714, 716, 5, 114, 0, 0, 715, 714, 1, 0, 0, 0, 715, 716, 1, 0, 0, 0, 716, 717, 1, 0, 0, 0, 717, 727, 5, 115, 0, 0, 718, 724, 10, 7, 0, 0, 719, 725, 3, 112, 56, 0, 720, 721, 5, 10, 0, 0, 721, 725, 3, 114, 57, 0, 722, 723, 5, 10, 0, 0, 723, 725, 5, 198, 0, 0, 724, 719, 1, 0, 0, 0, 724, 720, 1, 0, 0, 0, 724, 722, 1, 0, 0, 0, 725, 727, 1, 0, 0, 0, 726, 647, 1, 0, 0, 0, 726, 654, 1, 0, 0, 0, 726, 661, 1, 0, 0, 0, 726, 683, 1, 0, 0, 0, 726, 686, 1, 0, 0, 0, 726, 689, 1, 0, 0, 0, 726, 698, 1, 0, 0, 0, 726, 704, 1, 0, 0, 0, 726, 709, 1, 0, 0, 0, 726, 712, 1, 0, 0, 0, 726, 718, 1, 0, 0, 0, 727, 730, 1, 0, 0, 0, 728, 726, 1, 0, 0, 0, 728, 729, 1, 0, 0, 0, 729, 77, 1, 0, 0, 0, 730, 728, 1, 0, 0, 0, 731, 736, 3, 80, 40, 0, 732, 733, 5, 205, 0, 0, 733, 735, 3, 80, 40, 0, 734, 732, 1, 0, 0, 0, 735, 738, 1, 0, 0, 0, 736, 734, 1, 0, 0, 0, 736, 737, 1, 0, 0, 0, 737, 79, 1, 0, 0, 0, 738, 736, 1, 0, 0, 0, 739, 742, 3, 82, 41, 0, 740, 742, 3, 76, 38, 0, 741, 739, 1, 0, 0, 0, 741, 740, 1, 0, 0, 0, 742, 81, 1, 0, 0, 0, 743, 744, 5, 218, 0, 0, 744, 749, 3, 114, 57, 0, 745, 746, 5, 205, 0, 0, 746, 748, 3, 114, 57, 0, 747, 745, 1, 0, 0, 0, 748, 751, 1, 0, 0, 0, 749, 747, 1, 0, 0, 0, 749, 750, 1, 0, 0, 0, 750, 752, 1, 0, 0, 0, 751, 749, 1, 0, 0, 0, 752, 753, 5, 228, 0, 0, 753, 763, 1, 0, 0, 0, 754, 759, 3, 114, 57, 0, 755, 756, 5, 205, 0, 0, 756, 758, 3, 114, 57, 0, 757, 755, 1, 0, 0, 0, 758, 761, 1, 0, 0, 0, 759, 757, 1, 0, 0, 0, 759, 760, 1, 0, 0, 0, 760, 763, 1, 0, 0, 0, 761, 759, 1, 0, 0, 0, 762, 743, 1, 0, 0, 0, 762, 754, 1, 0, 0, 0, 763, 764, 1, 0, 0, 0, 764, 765, 5, 200, 0, 0, 765, 766, 3, 76, 38, 0, 766, 83, 1, 0, 0, 0, 767, 775, 5, 199, 0, 0, 768, 769, 3, 92, 46, 0, 769, 770, 5, 209, 0, 0, 770, 772, 1, 0, 0, 0, 771, 768, 1, 0, 0, 0, 771, 772, 1, 0, 0, 0, 772, 773, 1, 0, 0, 0, 773, 775, 3, 86, 43, 0, 774, 767, 1, 0, 0, 0, 774, 771, 1, 0, 0, 0, 775, 85, 1, 0, 0, 0, 776, 781, 3, 114, 57, 0, 777, 778, 5, 209, 0, 0, 778, 780, 3, 114, 57, 0, 779, 777, 1, 0, 0, 0, 780, 783, 1, 0, 0, 0, 781, 779, 1, 0, 0, 0, 781, 782, 1, 0, 0, 0, 782, 87, 1, 0, 0, 0, 783, 781, 1, 0, 0, 0, 784, 785, 6, 44, -1, 0, 785, 792, 3, 92, 46, 0, 786, 792, 3, 90, 45, 0, 787, 788, 5, 218, 0, 0, 788, 789, 3, 2, 1, 0, 789, 790, 5, 228, 0, 0, 790, 792, 1, 0, 0, 0, 791, 784, 1, 0, 0, 0, 791, 786, 1, 0, 0, 0, 791, 787, 1, 0, 0, 0, 792, 801, 1, 0, 0, 0, 793, 797, 10, 1, 0, 0, 794, 798, 3, 112, 56, 0, 795, 796, 5, 10, 0, 0, 796, 798, 3, 114, 57, 0, 797, 794, 1, 0, 0, 0, 797, 795, 1, 0, 0, 0, 798, 800, 1, 0, 0, 0, 799, 793, 1, 0, 0, 0, 800, 803, 1, 0, 0, 0, 801, 799, 1, 0, 0, 0, 801, 802, 1, 0, 0, 0, 802, 89, 1, 0, 0, 0, 803, 801, 1, 0, 0, 0, 804, 805, 3, 114, 57, 0, 805, 807, 5, 218, 0, 0, 806, 808, 3, 94, 47, 0, 807, 806, 1, 0, 0, 0, 807, 808, 1, 0, 0, 0, 808, 809, 1, 0, 0, 0, 809, 810, 5, 228, 0, 0, 810, 91, 1, 0, 0, 0, 811, 812, 3, 98, 49, 0, 812, 813, 5, 209, 0, 0, 813, 815, 1, 0, 0, 0, 814, 811, 1, 0, 0, 0, 814, 815, 1, 0, 0, 0, 815, 816, 1, 0, 0, 0, 816, 817, 3, 114, 57, 0, 817, 93, 1, 0, 0, 0, 818, 823, 3, 96, 48, 0, 819, 820, 5, 205, 0, 0, 820, 822, 3, 96, 48, 0, 821, 819, 1, 0, 0, 0, 822, 825, 1, 0, 0, 0, 823, 821, 1, 0, 0, 0, 823, 824, 1, 0, 0, 0, 824, 95, 1, 0, 0, 0, 825, 823, 1, 0, 0, 0, 826, 830, 3, 86, 43, 0, 827, 830, 3, 90, 45, 0, 828, 830, 3, 104, 52, 0, 829, 826, 1, 0, 0, 0, 829, 827, 1, 0, 0, 0, 829, 828, 1, 0, 0, 0, 830, 97, 1, 0, 0, 0, 831, 832, 3, 114, 57, 0, 832, 99, 1, 0, 0, 0, 833, 842, 5, 194, 0, 0, 834, 835, 5, 209, 0, 0, 835, 842, 7, 13, 0, 0, 836, 837, 5, 196, 0, 0, 837, 839, 5, 209, 0, 0, 838, 840, 7, 13, 0, 0, 839, 838, 1, 0, 0, 0, 839, 840, 1, 0, 0, 0, 840, 842, 1, 0, 0, 0, 841, 833, 1, 0, 0, 0, 841, 834, 1, 0, 0, 0, 841, 836, 1, 0, 0, 0, 842, 101, 1, 0, 0, 0, 843, 845, 7, 14, 0, 0, 844, 843, 1, 0, 0, 0, 844, 845, 1, 0, 0, 0, 845, 852, 1, 0, 0, 0, 846, 853, 3, 100, 50, 0, 847, 853, 5, 195, 0, 0, 848, 853, 5, 196, 0, 0, 849, 853, 5, 197, 0, 0, 850, 853, 5, 81, 0, 0, 851, 853, 5, 112, 0, 0, 852, 846, 1, 0, 0, 0, 852, 847, 1, 0, 0, 0, 852, 848, 1, 0, 0, 0, 852, 849, 1, 0, 0, 0, 852, 850, 1, 0, 0, 0, 852, 851, 1, 0, 0, 0, 853, 103, 1, 0, 0, 0, 854, 858, 3, 102, 51, 0, 855, 858, 5, 198, 0, 0, 856, 858, 5, 115, 0, 0, 857, 854, 1, 0, 0, 0, 857, 855, 1, 0, 0, 0, 857, 856, 1, 0, 0, 0, 858, 105, 1, 0, 0, 0, 859, 860, 7, 15, 0, 0, 860, 107, 1, 0, 0, 0, 861, 862, 7, 16, 0, 0, 862, 109, 1, 0, 0, 0, 863, 864, 7, 17, 0, 0, 864, 111, 1, 0, 0, 0, 865, 868, 5, 193, 0, 0, 866, 868, 3, 110, 55, 0, 867, 865, 1, 0, 0, 0, 867, 866, 1, 0, 0, 0, 868, 113, 1, 0, 0, 0, 869, 873, 5, 193, 0, 0, 870, 873, 3, 106, 53, 0, 871, 873, 3, 108, 54, 0, 872, 869, 1, 0, 0, 0, 872, 870, 1, 0, 0, 0, 872, 871, 1, 0, 0, 0, 873, 115, 1, 0, 0, 0, 874, 877, 3, 114, 57, 0, 875, 877, 5, 115, 0, 0, 876, 874, 1, 0, 0, 0, 876, 875, 1, 0, 0, 0, 877, 117, 1, 0, 0, 0, 878, 879, 5, 198, 0, 0, 879, 880, 5, 211, 0, 0, 880, 881, 3, 102, 51, 0, 881, 119, 1, 0, 0, 0, 114, 122, 132, 140, 143, 147, 150, 154, 157, 160, 163, 166, 169, 173, 177, 180, 183, 186, 189, 198, 204, 231, 250, 258, 261, 267, 275, 278, 284, 286, 290, 295, 298, 301, 305, 309, 312, 314, 317, 321, 325, 328, 330, 332, 335, 340, 351, 357, 362, 369, 374, 378, 382, 387, 394, 402, 405, 408, 427, 441, 457, 469, 481, 489, 493, 500, 506, 514, 519, 528, 532, 563, 580, 592, 602, 605, 609, 612, 624, 641, 645, 651, 658, 670, 673, 677, 680, 691, 715, 724, 726, 728, 736, 741, 749, 759, 762, 771, 774, 781, 791, 797, 801, 807, 814, 823, 829, 839, 841, 844, 852, 857, 867, 872, 876] \ No newline at end of file diff --git a/posthog/hogql/grammar/HogQLParser.py b/posthog/hogql/grammar/HogQLParser.py index 69da91c2a9518..eca17cbe4f6a4 100644 --- a/posthog/hogql/grammar/HogQLParser.py +++ b/posthog/hogql/grammar/HogQLParser.py @@ -10,7 +10,7 @@ def serializedATN(): return [ - 4,1,234,891,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6, + 4,1,234,883,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6, 7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7, 13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2, 20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7, @@ -19,348 +19,345 @@ def serializedATN(): 39,2,40,7,40,2,41,7,41,2,42,7,42,2,43,7,43,2,44,7,44,2,45,7,45,2, 46,7,46,2,47,7,47,2,48,7,48,2,49,7,49,2,50,7,50,2,51,7,51,2,52,7, 52,2,53,7,53,2,54,7,54,2,55,7,55,2,56,7,56,2,57,7,57,2,58,7,58,2, - 59,7,59,2,60,7,60,1,0,1,0,3,0,125,8,0,1,0,1,0,1,1,1,1,1,1,1,1,5, - 1,133,8,1,10,1,12,1,136,9,1,1,2,1,2,1,2,1,2,1,2,3,2,143,8,2,1,3, - 3,3,146,8,3,1,3,1,3,3,3,150,8,3,1,3,3,3,153,8,3,1,3,1,3,3,3,157, - 8,3,1,3,3,3,160,8,3,1,3,3,3,163,8,3,1,3,3,3,166,8,3,1,3,3,3,169, - 8,3,1,3,3,3,172,8,3,1,3,1,3,3,3,176,8,3,1,3,1,3,3,3,180,8,3,1,3, - 3,3,183,8,3,1,3,3,3,186,8,3,1,3,3,3,189,8,3,1,3,3,3,192,8,3,1,3, - 3,3,195,8,3,1,4,1,4,1,4,1,5,1,5,1,5,1,5,3,5,204,8,5,1,6,1,6,1,6, - 1,7,3,7,210,8,7,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,9, - 1,9,1,9,1,10,1,10,1,10,1,11,1,11,1,11,1,11,1,11,1,11,1,11,1,11,3, - 11,237,8,11,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,14,1,14,1,14,1, - 14,1,15,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,16,3,16,259,8,16,1, - 17,1,17,1,17,1,18,1,18,1,18,3,18,267,8,18,1,18,3,18,270,8,18,1,18, - 1,18,1,18,1,18,3,18,276,8,18,1,18,1,18,1,18,1,18,1,18,1,18,3,18, - 284,8,18,1,18,3,18,287,8,18,1,18,1,18,1,18,1,18,5,18,293,8,18,10, - 18,12,18,296,9,18,1,19,3,19,299,8,19,1,19,1,19,1,19,3,19,304,8,19, - 1,19,3,19,307,8,19,1,19,3,19,310,8,19,1,19,1,19,3,19,314,8,19,1, - 19,1,19,3,19,318,8,19,1,19,3,19,321,8,19,3,19,323,8,19,1,19,3,19, - 326,8,19,1,19,1,19,3,19,330,8,19,1,19,1,19,3,19,334,8,19,1,19,3, - 19,337,8,19,3,19,339,8,19,3,19,341,8,19,1,20,3,20,344,8,20,1,20, - 1,20,1,20,3,20,349,8,20,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,21, - 1,21,3,21,360,8,21,1,22,1,22,1,22,1,22,3,22,366,8,22,1,23,1,23,1, - 23,3,23,371,8,23,1,24,1,24,1,24,5,24,376,8,24,10,24,12,24,379,9, - 24,1,25,1,25,3,25,383,8,25,1,25,1,25,3,25,387,8,25,1,25,1,25,3,25, - 391,8,25,1,26,1,26,1,26,3,26,396,8,26,1,27,1,27,1,27,5,27,401,8, - 27,10,27,12,27,404,9,27,1,28,1,28,1,28,1,28,1,29,3,29,411,8,29,1, - 29,3,29,414,8,29,1,29,3,29,417,8,29,1,30,1,30,1,30,1,30,1,31,1,31, - 1,31,1,31,1,32,1,32,1,32,1,33,1,33,1,33,1,33,1,33,1,33,3,33,436, - 8,33,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34,1,34, - 3,34,450,8,34,1,35,1,35,1,35,1,36,1,36,1,36,1,36,1,36,1,36,1,36, - 1,36,1,36,5,36,464,8,36,10,36,12,36,467,9,36,1,36,1,36,1,36,1,36, - 1,36,1,36,1,36,5,36,476,8,36,10,36,12,36,479,9,36,1,36,1,36,1,36, - 1,36,1,36,1,36,1,36,5,36,488,8,36,10,36,12,36,491,9,36,1,36,1,36, - 1,36,1,36,1,36,3,36,498,8,36,1,36,1,36,3,36,502,8,36,1,37,1,37,1, - 37,5,37,507,8,37,10,37,12,37,510,9,37,1,38,1,38,1,38,3,38,515,8, - 38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,523,8,38,1,39,1,39,1,39,3, - 39,528,8,39,1,39,1,39,1,39,1,39,1,39,4,39,535,8,39,11,39,12,39,536, - 1,39,1,39,3,39,541,8,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39, - 1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39, - 1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,3,39,572,8,39,1,39,1,39, - 1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39, - 3,39,589,8,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39, - 3,39,601,8,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,3,39,611,8, - 39,1,39,3,39,614,8,39,1,39,1,39,3,39,618,8,39,1,39,3,39,621,8,39, - 1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,3,39,633,8,39, - 1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39, - 1,39,1,39,3,39,650,8,39,1,39,1,39,3,39,654,8,39,1,39,1,39,1,39,1, - 39,3,39,660,8,39,1,39,1,39,1,39,1,39,1,39,3,39,667,8,39,1,39,1,39, - 1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,3,39,679,8,39,1,39,3,39, - 682,8,39,1,39,1,39,3,39,686,8,39,1,39,3,39,689,8,39,1,39,1,39,1, - 39,1,39,1,39,1,39,1,39,1,39,1,39,3,39,700,8,39,1,39,1,39,1,39,1, - 39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1,39,1, - 39,1,39,1,39,1,39,1,39,1,39,3,39,724,8,39,1,39,1,39,1,39,1,39,1, - 39,1,39,1,39,3,39,733,8,39,5,39,735,8,39,10,39,12,39,738,9,39,1, - 40,1,40,1,40,5,40,743,8,40,10,40,12,40,746,9,40,1,41,1,41,3,41,750, - 8,41,1,42,1,42,1,42,1,42,5,42,756,8,42,10,42,12,42,759,9,42,1,42, - 1,42,1,42,1,42,1,42,5,42,766,8,42,10,42,12,42,769,9,42,3,42,771, - 8,42,1,42,1,42,1,42,1,43,1,43,1,43,1,43,3,43,780,8,43,1,43,3,43, - 783,8,43,1,44,1,44,1,44,5,44,788,8,44,10,44,12,44,791,9,44,1,45, - 1,45,1,45,1,45,1,45,1,45,1,45,3,45,800,8,45,1,45,1,45,1,45,1,45, - 3,45,806,8,45,5,45,808,8,45,10,45,12,45,811,9,45,1,46,1,46,1,46, - 3,46,816,8,46,1,46,1,46,1,47,1,47,1,47,3,47,823,8,47,1,47,1,47,1, - 48,1,48,1,48,5,48,830,8,48,10,48,12,48,833,9,48,1,49,1,49,1,49,3, - 49,838,8,49,1,50,1,50,1,51,1,51,1,51,1,51,1,51,1,51,3,51,848,8,51, - 3,51,850,8,51,1,52,3,52,853,8,52,1,52,1,52,1,52,1,52,1,52,1,52,3, - 52,861,8,52,1,53,1,53,1,53,3,53,866,8,53,1,54,1,54,1,55,1,55,1,56, - 1,56,1,57,1,57,3,57,876,8,57,1,58,1,58,1,58,3,58,881,8,58,1,59,1, - 59,3,59,885,8,59,1,60,1,60,1,60,1,60,1,60,0,3,36,78,90,61,0,2,4, - 6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40,42,44,46,48, - 50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84,86,88,90,92, - 94,96,98,100,102,104,106,108,110,112,114,116,118,120,0,18,2,0,31, - 31,140,140,2,0,83,83,95,95,2,0,70,70,100,100,3,0,4,4,8,8,12,12,4, - 0,4,4,7,8,12,12,146,146,2,0,95,95,139,139,2,0,4,4,8,8,2,0,117,117, - 205,205,2,0,11,11,41,42,2,0,61,61,92,92,2,0,132,132,142,142,3,0, - 17,17,94,94,169,169,2,0,78,78,97,97,1,0,195,196,2,0,207,207,222, - 222,8,0,36,36,75,75,107,107,109,109,131,131,144,144,184,184,189, - 189,12,0,2,35,37,74,76,80,82,106,108,108,110,111,113,114,116,129, - 132,143,145,183,185,188,190,191,4,0,35,35,61,61,76,76,90,90,1000, - 0,124,1,0,0,0,2,128,1,0,0,0,4,142,1,0,0,0,6,145,1,0,0,0,8,196,1, - 0,0,0,10,199,1,0,0,0,12,205,1,0,0,0,14,209,1,0,0,0,16,215,1,0,0, - 0,18,222,1,0,0,0,20,225,1,0,0,0,22,228,1,0,0,0,24,238,1,0,0,0,26, - 241,1,0,0,0,28,245,1,0,0,0,30,249,1,0,0,0,32,254,1,0,0,0,34,260, - 1,0,0,0,36,275,1,0,0,0,38,340,1,0,0,0,40,348,1,0,0,0,42,359,1,0, - 0,0,44,361,1,0,0,0,46,367,1,0,0,0,48,372,1,0,0,0,50,380,1,0,0,0, - 52,392,1,0,0,0,54,397,1,0,0,0,56,405,1,0,0,0,58,410,1,0,0,0,60,418, - 1,0,0,0,62,422,1,0,0,0,64,426,1,0,0,0,66,435,1,0,0,0,68,449,1,0, - 0,0,70,451,1,0,0,0,72,501,1,0,0,0,74,503,1,0,0,0,76,522,1,0,0,0, - 78,653,1,0,0,0,80,739,1,0,0,0,82,749,1,0,0,0,84,770,1,0,0,0,86,782, - 1,0,0,0,88,784,1,0,0,0,90,799,1,0,0,0,92,812,1,0,0,0,94,822,1,0, - 0,0,96,826,1,0,0,0,98,837,1,0,0,0,100,839,1,0,0,0,102,849,1,0,0, - 0,104,852,1,0,0,0,106,865,1,0,0,0,108,867,1,0,0,0,110,869,1,0,0, - 0,112,871,1,0,0,0,114,875,1,0,0,0,116,880,1,0,0,0,118,884,1,0,0, - 0,120,886,1,0,0,0,122,125,3,2,1,0,123,125,3,6,3,0,124,122,1,0,0, - 0,124,123,1,0,0,0,125,126,1,0,0,0,126,127,5,0,0,1,127,1,1,0,0,0, - 128,134,3,4,2,0,129,130,5,175,0,0,130,131,5,4,0,0,131,133,3,4,2, - 0,132,129,1,0,0,0,133,136,1,0,0,0,134,132,1,0,0,0,134,135,1,0,0, - 0,135,3,1,0,0,0,136,134,1,0,0,0,137,143,3,6,3,0,138,139,5,218,0, - 0,139,140,3,2,1,0,140,141,5,228,0,0,141,143,1,0,0,0,142,137,1,0, - 0,0,142,138,1,0,0,0,143,5,1,0,0,0,144,146,3,8,4,0,145,144,1,0,0, - 0,145,146,1,0,0,0,146,147,1,0,0,0,147,149,5,145,0,0,148,150,5,48, - 0,0,149,148,1,0,0,0,149,150,1,0,0,0,150,152,1,0,0,0,151,153,3,10, - 5,0,152,151,1,0,0,0,152,153,1,0,0,0,153,154,1,0,0,0,154,156,3,74, - 37,0,155,157,3,12,6,0,156,155,1,0,0,0,156,157,1,0,0,0,157,159,1, - 0,0,0,158,160,3,14,7,0,159,158,1,0,0,0,159,160,1,0,0,0,160,162,1, - 0,0,0,161,163,3,16,8,0,162,161,1,0,0,0,162,163,1,0,0,0,163,165,1, - 0,0,0,164,166,3,18,9,0,165,164,1,0,0,0,165,166,1,0,0,0,166,168,1, - 0,0,0,167,169,3,20,10,0,168,167,1,0,0,0,168,169,1,0,0,0,169,171, - 1,0,0,0,170,172,3,22,11,0,171,170,1,0,0,0,171,172,1,0,0,0,172,175, - 1,0,0,0,173,174,5,188,0,0,174,176,7,0,0,0,175,173,1,0,0,0,175,176, - 1,0,0,0,176,179,1,0,0,0,177,178,5,188,0,0,178,180,5,168,0,0,179, - 177,1,0,0,0,179,180,1,0,0,0,180,182,1,0,0,0,181,183,3,24,12,0,182, - 181,1,0,0,0,182,183,1,0,0,0,183,185,1,0,0,0,184,186,3,26,13,0,185, - 184,1,0,0,0,185,186,1,0,0,0,186,188,1,0,0,0,187,189,3,30,15,0,188, - 187,1,0,0,0,188,189,1,0,0,0,189,191,1,0,0,0,190,192,3,32,16,0,191, - 190,1,0,0,0,191,192,1,0,0,0,192,194,1,0,0,0,193,195,3,34,17,0,194, - 193,1,0,0,0,194,195,1,0,0,0,195,7,1,0,0,0,196,197,5,188,0,0,197, - 198,3,74,37,0,198,9,1,0,0,0,199,200,5,167,0,0,200,203,5,196,0,0, - 201,202,5,188,0,0,202,204,5,163,0,0,203,201,1,0,0,0,203,204,1,0, - 0,0,204,11,1,0,0,0,205,206,5,67,0,0,206,207,3,36,18,0,207,13,1,0, - 0,0,208,210,7,1,0,0,209,208,1,0,0,0,209,210,1,0,0,0,210,211,1,0, - 0,0,211,212,5,9,0,0,212,213,5,89,0,0,213,214,3,74,37,0,214,15,1, - 0,0,0,215,216,5,187,0,0,216,217,3,116,58,0,217,218,5,10,0,0,218, - 219,5,218,0,0,219,220,3,58,29,0,220,221,5,228,0,0,221,17,1,0,0,0, - 222,223,5,128,0,0,223,224,3,78,39,0,224,19,1,0,0,0,225,226,5,186, - 0,0,226,227,3,78,39,0,227,21,1,0,0,0,228,229,5,72,0,0,229,236,5, - 18,0,0,230,231,7,0,0,0,231,232,5,218,0,0,232,233,3,74,37,0,233,234, - 5,228,0,0,234,237,1,0,0,0,235,237,3,74,37,0,236,230,1,0,0,0,236, - 235,1,0,0,0,237,23,1,0,0,0,238,239,5,73,0,0,239,240,3,78,39,0,240, - 25,1,0,0,0,241,242,5,121,0,0,242,243,5,18,0,0,243,244,3,48,24,0, - 244,27,1,0,0,0,245,246,5,121,0,0,246,247,5,18,0,0,247,248,3,74,37, - 0,248,29,1,0,0,0,249,250,5,98,0,0,250,251,3,46,23,0,251,252,5,18, - 0,0,252,253,3,74,37,0,253,31,1,0,0,0,254,255,5,98,0,0,255,258,3, - 46,23,0,256,257,5,188,0,0,257,259,5,163,0,0,258,256,1,0,0,0,258, - 259,1,0,0,0,259,33,1,0,0,0,260,261,5,149,0,0,261,262,3,54,27,0,262, - 35,1,0,0,0,263,264,6,18,-1,0,264,266,3,90,45,0,265,267,5,60,0,0, - 266,265,1,0,0,0,266,267,1,0,0,0,267,269,1,0,0,0,268,270,3,44,22, - 0,269,268,1,0,0,0,269,270,1,0,0,0,270,276,1,0,0,0,271,272,5,218, - 0,0,272,273,3,36,18,0,273,274,5,228,0,0,274,276,1,0,0,0,275,263, - 1,0,0,0,275,271,1,0,0,0,276,294,1,0,0,0,277,278,10,3,0,0,278,279, - 3,40,20,0,279,280,3,36,18,4,280,293,1,0,0,0,281,283,10,4,0,0,282, - 284,7,2,0,0,283,282,1,0,0,0,283,284,1,0,0,0,284,286,1,0,0,0,285, - 287,3,38,19,0,286,285,1,0,0,0,286,287,1,0,0,0,287,288,1,0,0,0,288, - 289,5,89,0,0,289,290,3,36,18,0,290,291,3,42,21,0,291,293,1,0,0,0, - 292,277,1,0,0,0,292,281,1,0,0,0,293,296,1,0,0,0,294,292,1,0,0,0, - 294,295,1,0,0,0,295,37,1,0,0,0,296,294,1,0,0,0,297,299,7,3,0,0,298, - 297,1,0,0,0,298,299,1,0,0,0,299,300,1,0,0,0,300,307,5,83,0,0,301, - 303,5,83,0,0,302,304,7,3,0,0,303,302,1,0,0,0,303,304,1,0,0,0,304, - 307,1,0,0,0,305,307,7,3,0,0,306,298,1,0,0,0,306,301,1,0,0,0,306, - 305,1,0,0,0,307,341,1,0,0,0,308,310,7,4,0,0,309,308,1,0,0,0,309, - 310,1,0,0,0,310,311,1,0,0,0,311,313,7,5,0,0,312,314,5,122,0,0,313, - 312,1,0,0,0,313,314,1,0,0,0,314,323,1,0,0,0,315,317,7,5,0,0,316, - 318,5,122,0,0,317,316,1,0,0,0,317,318,1,0,0,0,318,320,1,0,0,0,319, - 321,7,4,0,0,320,319,1,0,0,0,320,321,1,0,0,0,321,323,1,0,0,0,322, - 309,1,0,0,0,322,315,1,0,0,0,323,341,1,0,0,0,324,326,7,6,0,0,325, - 324,1,0,0,0,325,326,1,0,0,0,326,327,1,0,0,0,327,329,5,68,0,0,328, - 330,5,122,0,0,329,328,1,0,0,0,329,330,1,0,0,0,330,339,1,0,0,0,331, - 333,5,68,0,0,332,334,5,122,0,0,333,332,1,0,0,0,333,334,1,0,0,0,334, - 336,1,0,0,0,335,337,7,6,0,0,336,335,1,0,0,0,336,337,1,0,0,0,337, - 339,1,0,0,0,338,325,1,0,0,0,338,331,1,0,0,0,339,341,1,0,0,0,340, - 306,1,0,0,0,340,322,1,0,0,0,340,338,1,0,0,0,341,39,1,0,0,0,342,344, - 7,2,0,0,343,342,1,0,0,0,343,344,1,0,0,0,344,345,1,0,0,0,345,346, - 5,30,0,0,346,349,5,89,0,0,347,349,5,205,0,0,348,343,1,0,0,0,348, - 347,1,0,0,0,349,41,1,0,0,0,350,351,5,118,0,0,351,360,3,74,37,0,352, - 353,5,178,0,0,353,354,5,218,0,0,354,355,3,74,37,0,355,356,5,228, - 0,0,356,360,1,0,0,0,357,358,5,178,0,0,358,360,3,74,37,0,359,350, - 1,0,0,0,359,352,1,0,0,0,359,357,1,0,0,0,360,43,1,0,0,0,361,362,5, - 143,0,0,362,365,3,52,26,0,363,364,5,117,0,0,364,366,3,52,26,0,365, - 363,1,0,0,0,365,366,1,0,0,0,366,45,1,0,0,0,367,370,3,78,39,0,368, - 369,7,7,0,0,369,371,3,78,39,0,370,368,1,0,0,0,370,371,1,0,0,0,371, - 47,1,0,0,0,372,377,3,50,25,0,373,374,5,205,0,0,374,376,3,50,25,0, - 375,373,1,0,0,0,376,379,1,0,0,0,377,375,1,0,0,0,377,378,1,0,0,0, - 378,49,1,0,0,0,379,377,1,0,0,0,380,382,3,78,39,0,381,383,7,8,0,0, - 382,381,1,0,0,0,382,383,1,0,0,0,383,386,1,0,0,0,384,385,5,116,0, - 0,385,387,7,9,0,0,386,384,1,0,0,0,386,387,1,0,0,0,387,390,1,0,0, - 0,388,389,5,25,0,0,389,391,5,198,0,0,390,388,1,0,0,0,390,391,1,0, - 0,0,391,51,1,0,0,0,392,395,3,104,52,0,393,394,5,230,0,0,394,396, - 3,104,52,0,395,393,1,0,0,0,395,396,1,0,0,0,396,53,1,0,0,0,397,402, - 3,56,28,0,398,399,5,205,0,0,399,401,3,56,28,0,400,398,1,0,0,0,401, - 404,1,0,0,0,402,400,1,0,0,0,402,403,1,0,0,0,403,55,1,0,0,0,404,402, - 1,0,0,0,405,406,3,116,58,0,406,407,5,211,0,0,407,408,3,106,53,0, - 408,57,1,0,0,0,409,411,3,60,30,0,410,409,1,0,0,0,410,411,1,0,0,0, - 411,413,1,0,0,0,412,414,3,62,31,0,413,412,1,0,0,0,413,414,1,0,0, - 0,414,416,1,0,0,0,415,417,3,64,32,0,416,415,1,0,0,0,416,417,1,0, - 0,0,417,59,1,0,0,0,418,419,5,125,0,0,419,420,5,18,0,0,420,421,3, - 74,37,0,421,61,1,0,0,0,422,423,5,121,0,0,423,424,5,18,0,0,424,425, - 3,48,24,0,425,63,1,0,0,0,426,427,7,10,0,0,427,428,3,66,33,0,428, - 65,1,0,0,0,429,436,3,68,34,0,430,431,5,16,0,0,431,432,3,68,34,0, - 432,433,5,6,0,0,433,434,3,68,34,0,434,436,1,0,0,0,435,429,1,0,0, - 0,435,430,1,0,0,0,436,67,1,0,0,0,437,438,5,32,0,0,438,450,5,141, - 0,0,439,440,5,174,0,0,440,450,5,127,0,0,441,442,5,174,0,0,442,450, - 5,63,0,0,443,444,3,104,52,0,444,445,5,127,0,0,445,450,1,0,0,0,446, - 447,3,104,52,0,447,448,5,63,0,0,448,450,1,0,0,0,449,437,1,0,0,0, - 449,439,1,0,0,0,449,441,1,0,0,0,449,443,1,0,0,0,449,446,1,0,0,0, - 450,69,1,0,0,0,451,452,3,78,39,0,452,453,5,0,0,1,453,71,1,0,0,0, - 454,502,3,116,58,0,455,456,3,116,58,0,456,457,5,218,0,0,457,458, - 3,116,58,0,458,465,3,72,36,0,459,460,5,205,0,0,460,461,3,116,58, - 0,461,462,3,72,36,0,462,464,1,0,0,0,463,459,1,0,0,0,464,467,1,0, - 0,0,465,463,1,0,0,0,465,466,1,0,0,0,466,468,1,0,0,0,467,465,1,0, - 0,0,468,469,5,228,0,0,469,502,1,0,0,0,470,471,3,116,58,0,471,472, - 5,218,0,0,472,477,3,120,60,0,473,474,5,205,0,0,474,476,3,120,60, - 0,475,473,1,0,0,0,476,479,1,0,0,0,477,475,1,0,0,0,477,478,1,0,0, - 0,478,480,1,0,0,0,479,477,1,0,0,0,480,481,5,228,0,0,481,502,1,0, - 0,0,482,483,3,116,58,0,483,484,5,218,0,0,484,489,3,72,36,0,485,486, - 5,205,0,0,486,488,3,72,36,0,487,485,1,0,0,0,488,491,1,0,0,0,489, - 487,1,0,0,0,489,490,1,0,0,0,490,492,1,0,0,0,491,489,1,0,0,0,492, - 493,5,228,0,0,493,502,1,0,0,0,494,495,3,116,58,0,495,497,5,218,0, - 0,496,498,3,74,37,0,497,496,1,0,0,0,497,498,1,0,0,0,498,499,1,0, - 0,0,499,500,5,228,0,0,500,502,1,0,0,0,501,454,1,0,0,0,501,455,1, - 0,0,0,501,470,1,0,0,0,501,482,1,0,0,0,501,494,1,0,0,0,502,73,1,0, - 0,0,503,508,3,76,38,0,504,505,5,205,0,0,505,507,3,76,38,0,506,504, - 1,0,0,0,507,510,1,0,0,0,508,506,1,0,0,0,508,509,1,0,0,0,509,75,1, - 0,0,0,510,508,1,0,0,0,511,512,3,94,47,0,512,513,5,209,0,0,513,515, - 1,0,0,0,514,511,1,0,0,0,514,515,1,0,0,0,515,516,1,0,0,0,516,523, - 5,201,0,0,517,518,5,218,0,0,518,519,3,2,1,0,519,520,5,228,0,0,520, - 523,1,0,0,0,521,523,3,78,39,0,522,514,1,0,0,0,522,517,1,0,0,0,522, - 521,1,0,0,0,523,77,1,0,0,0,524,525,6,39,-1,0,525,527,5,19,0,0,526, - 528,3,78,39,0,527,526,1,0,0,0,527,528,1,0,0,0,528,534,1,0,0,0,529, - 530,5,185,0,0,530,531,3,78,39,0,531,532,5,162,0,0,532,533,3,78,39, - 0,533,535,1,0,0,0,534,529,1,0,0,0,535,536,1,0,0,0,536,534,1,0,0, - 0,536,537,1,0,0,0,537,540,1,0,0,0,538,539,5,51,0,0,539,541,3,78, - 39,0,540,538,1,0,0,0,540,541,1,0,0,0,541,542,1,0,0,0,542,543,5,52, - 0,0,543,654,1,0,0,0,544,545,5,20,0,0,545,546,5,218,0,0,546,547,3, - 78,39,0,547,548,5,10,0,0,548,549,3,72,36,0,549,550,5,228,0,0,550, - 654,1,0,0,0,551,552,5,35,0,0,552,654,5,198,0,0,553,554,5,58,0,0, - 554,555,5,218,0,0,555,556,3,108,54,0,556,557,5,67,0,0,557,558,3, - 78,39,0,558,559,5,228,0,0,559,654,1,0,0,0,560,561,5,85,0,0,561,562, - 3,78,39,0,562,563,3,108,54,0,563,654,1,0,0,0,564,565,5,154,0,0,565, - 566,5,218,0,0,566,567,3,78,39,0,567,568,5,67,0,0,568,571,3,78,39, - 0,569,570,5,64,0,0,570,572,3,78,39,0,571,569,1,0,0,0,571,572,1,0, - 0,0,572,573,1,0,0,0,573,574,5,228,0,0,574,654,1,0,0,0,575,576,5, - 165,0,0,576,654,5,198,0,0,577,578,5,170,0,0,578,579,5,218,0,0,579, - 580,7,11,0,0,580,581,5,198,0,0,581,582,5,67,0,0,582,583,3,78,39, - 0,583,584,5,228,0,0,584,654,1,0,0,0,585,586,3,116,58,0,586,588,5, - 218,0,0,587,589,3,74,37,0,588,587,1,0,0,0,588,589,1,0,0,0,589,590, - 1,0,0,0,590,591,5,228,0,0,591,592,1,0,0,0,592,593,5,124,0,0,593, - 594,5,218,0,0,594,595,3,58,29,0,595,596,5,228,0,0,596,654,1,0,0, - 0,597,598,3,116,58,0,598,600,5,218,0,0,599,601,3,74,37,0,600,599, - 1,0,0,0,600,601,1,0,0,0,601,602,1,0,0,0,602,603,5,228,0,0,603,604, - 1,0,0,0,604,605,5,124,0,0,605,606,3,116,58,0,606,654,1,0,0,0,607, - 613,3,116,58,0,608,610,5,218,0,0,609,611,3,74,37,0,610,609,1,0,0, - 0,610,611,1,0,0,0,611,612,1,0,0,0,612,614,5,228,0,0,613,608,1,0, - 0,0,613,614,1,0,0,0,614,615,1,0,0,0,615,617,5,218,0,0,616,618,5, - 48,0,0,617,616,1,0,0,0,617,618,1,0,0,0,618,620,1,0,0,0,619,621,3, - 80,40,0,620,619,1,0,0,0,620,621,1,0,0,0,621,622,1,0,0,0,622,623, - 5,228,0,0,623,654,1,0,0,0,624,654,3,106,53,0,625,626,5,207,0,0,626, - 654,3,78,39,17,627,628,5,114,0,0,628,654,3,78,39,12,629,630,3,94, - 47,0,630,631,5,209,0,0,631,633,1,0,0,0,632,629,1,0,0,0,632,633,1, - 0,0,0,633,634,1,0,0,0,634,654,5,201,0,0,635,636,5,218,0,0,636,637, - 3,2,1,0,637,638,5,228,0,0,638,654,1,0,0,0,639,640,5,218,0,0,640, - 641,3,78,39,0,641,642,5,228,0,0,642,654,1,0,0,0,643,644,5,218,0, - 0,644,645,3,74,37,0,645,646,5,228,0,0,646,654,1,0,0,0,647,649,5, - 216,0,0,648,650,3,74,37,0,649,648,1,0,0,0,649,650,1,0,0,0,650,651, - 1,0,0,0,651,654,5,227,0,0,652,654,3,86,43,0,653,524,1,0,0,0,653, - 544,1,0,0,0,653,551,1,0,0,0,653,553,1,0,0,0,653,560,1,0,0,0,653, - 564,1,0,0,0,653,575,1,0,0,0,653,577,1,0,0,0,653,585,1,0,0,0,653, - 597,1,0,0,0,653,607,1,0,0,0,653,624,1,0,0,0,653,625,1,0,0,0,653, - 627,1,0,0,0,653,632,1,0,0,0,653,635,1,0,0,0,653,639,1,0,0,0,653, - 643,1,0,0,0,653,647,1,0,0,0,653,652,1,0,0,0,654,736,1,0,0,0,655, - 659,10,16,0,0,656,660,5,201,0,0,657,660,5,230,0,0,658,660,5,221, - 0,0,659,656,1,0,0,0,659,657,1,0,0,0,659,658,1,0,0,0,660,661,1,0, - 0,0,661,735,3,78,39,17,662,666,10,15,0,0,663,667,5,222,0,0,664,667, - 5,207,0,0,665,667,5,206,0,0,666,663,1,0,0,0,666,664,1,0,0,0,666, - 665,1,0,0,0,667,668,1,0,0,0,668,735,3,78,39,16,669,688,10,14,0,0, - 670,689,5,210,0,0,671,689,5,211,0,0,672,689,5,220,0,0,673,689,5, - 217,0,0,674,689,5,212,0,0,675,689,5,219,0,0,676,689,5,213,0,0,677, - 679,5,70,0,0,678,677,1,0,0,0,678,679,1,0,0,0,679,681,1,0,0,0,680, - 682,5,114,0,0,681,680,1,0,0,0,681,682,1,0,0,0,682,683,1,0,0,0,683, - 689,5,79,0,0,684,686,5,114,0,0,685,684,1,0,0,0,685,686,1,0,0,0,686, - 687,1,0,0,0,687,689,7,12,0,0,688,670,1,0,0,0,688,671,1,0,0,0,688, - 672,1,0,0,0,688,673,1,0,0,0,688,674,1,0,0,0,688,675,1,0,0,0,688, - 676,1,0,0,0,688,678,1,0,0,0,688,685,1,0,0,0,689,690,1,0,0,0,690, - 735,3,78,39,15,691,692,10,11,0,0,692,693,5,6,0,0,693,735,3,78,39, - 12,694,695,10,10,0,0,695,696,5,120,0,0,696,735,3,78,39,11,697,699, - 10,9,0,0,698,700,5,114,0,0,699,698,1,0,0,0,699,700,1,0,0,0,700,701, - 1,0,0,0,701,702,5,16,0,0,702,703,3,78,39,0,703,704,5,6,0,0,704,705, - 3,78,39,10,705,735,1,0,0,0,706,707,10,8,0,0,707,708,5,223,0,0,708, - 709,3,78,39,0,709,710,5,204,0,0,710,711,3,78,39,8,711,735,1,0,0, - 0,712,713,10,19,0,0,713,714,5,216,0,0,714,715,3,78,39,0,715,716, - 5,227,0,0,716,735,1,0,0,0,717,718,10,18,0,0,718,719,5,209,0,0,719, - 735,5,196,0,0,720,721,10,13,0,0,721,723,5,87,0,0,722,724,5,114,0, - 0,723,722,1,0,0,0,723,724,1,0,0,0,724,725,1,0,0,0,725,735,5,115, - 0,0,726,732,10,7,0,0,727,733,3,114,57,0,728,729,5,10,0,0,729,733, - 3,116,58,0,730,731,5,10,0,0,731,733,5,198,0,0,732,727,1,0,0,0,732, - 728,1,0,0,0,732,730,1,0,0,0,733,735,1,0,0,0,734,655,1,0,0,0,734, - 662,1,0,0,0,734,669,1,0,0,0,734,691,1,0,0,0,734,694,1,0,0,0,734, - 697,1,0,0,0,734,706,1,0,0,0,734,712,1,0,0,0,734,717,1,0,0,0,734, - 720,1,0,0,0,734,726,1,0,0,0,735,738,1,0,0,0,736,734,1,0,0,0,736, - 737,1,0,0,0,737,79,1,0,0,0,738,736,1,0,0,0,739,744,3,82,41,0,740, - 741,5,205,0,0,741,743,3,82,41,0,742,740,1,0,0,0,743,746,1,0,0,0, - 744,742,1,0,0,0,744,745,1,0,0,0,745,81,1,0,0,0,746,744,1,0,0,0,747, - 750,3,84,42,0,748,750,3,78,39,0,749,747,1,0,0,0,749,748,1,0,0,0, - 750,83,1,0,0,0,751,752,5,218,0,0,752,757,3,116,58,0,753,754,5,205, - 0,0,754,756,3,116,58,0,755,753,1,0,0,0,756,759,1,0,0,0,757,755,1, - 0,0,0,757,758,1,0,0,0,758,760,1,0,0,0,759,757,1,0,0,0,760,761,5, - 228,0,0,761,771,1,0,0,0,762,767,3,116,58,0,763,764,5,205,0,0,764, - 766,3,116,58,0,765,763,1,0,0,0,766,769,1,0,0,0,767,765,1,0,0,0,767, - 768,1,0,0,0,768,771,1,0,0,0,769,767,1,0,0,0,770,751,1,0,0,0,770, - 762,1,0,0,0,771,772,1,0,0,0,772,773,5,200,0,0,773,774,3,78,39,0, - 774,85,1,0,0,0,775,783,5,199,0,0,776,777,3,94,47,0,777,778,5,209, - 0,0,778,780,1,0,0,0,779,776,1,0,0,0,779,780,1,0,0,0,780,781,1,0, - 0,0,781,783,3,88,44,0,782,775,1,0,0,0,782,779,1,0,0,0,783,87,1,0, - 0,0,784,789,3,116,58,0,785,786,5,209,0,0,786,788,3,116,58,0,787, - 785,1,0,0,0,788,791,1,0,0,0,789,787,1,0,0,0,789,790,1,0,0,0,790, - 89,1,0,0,0,791,789,1,0,0,0,792,793,6,45,-1,0,793,800,3,94,47,0,794, - 800,3,92,46,0,795,796,5,218,0,0,796,797,3,2,1,0,797,798,5,228,0, - 0,798,800,1,0,0,0,799,792,1,0,0,0,799,794,1,0,0,0,799,795,1,0,0, - 0,800,809,1,0,0,0,801,805,10,1,0,0,802,806,3,114,57,0,803,804,5, - 10,0,0,804,806,3,116,58,0,805,802,1,0,0,0,805,803,1,0,0,0,806,808, - 1,0,0,0,807,801,1,0,0,0,808,811,1,0,0,0,809,807,1,0,0,0,809,810, - 1,0,0,0,810,91,1,0,0,0,811,809,1,0,0,0,812,813,3,116,58,0,813,815, - 5,218,0,0,814,816,3,96,48,0,815,814,1,0,0,0,815,816,1,0,0,0,816, - 817,1,0,0,0,817,818,5,228,0,0,818,93,1,0,0,0,819,820,3,100,50,0, - 820,821,5,209,0,0,821,823,1,0,0,0,822,819,1,0,0,0,822,823,1,0,0, - 0,823,824,1,0,0,0,824,825,3,116,58,0,825,95,1,0,0,0,826,831,3,98, - 49,0,827,828,5,205,0,0,828,830,3,98,49,0,829,827,1,0,0,0,830,833, - 1,0,0,0,831,829,1,0,0,0,831,832,1,0,0,0,832,97,1,0,0,0,833,831,1, - 0,0,0,834,838,3,88,44,0,835,838,3,92,46,0,836,838,3,106,53,0,837, - 834,1,0,0,0,837,835,1,0,0,0,837,836,1,0,0,0,838,99,1,0,0,0,839,840, - 3,116,58,0,840,101,1,0,0,0,841,850,5,194,0,0,842,843,5,209,0,0,843, - 850,7,13,0,0,844,845,5,196,0,0,845,847,5,209,0,0,846,848,7,13,0, - 0,847,846,1,0,0,0,847,848,1,0,0,0,848,850,1,0,0,0,849,841,1,0,0, - 0,849,842,1,0,0,0,849,844,1,0,0,0,850,103,1,0,0,0,851,853,7,14,0, - 0,852,851,1,0,0,0,852,853,1,0,0,0,853,860,1,0,0,0,854,861,3,102, - 51,0,855,861,5,195,0,0,856,861,5,196,0,0,857,861,5,197,0,0,858,861, - 5,81,0,0,859,861,5,112,0,0,860,854,1,0,0,0,860,855,1,0,0,0,860,856, - 1,0,0,0,860,857,1,0,0,0,860,858,1,0,0,0,860,859,1,0,0,0,861,105, - 1,0,0,0,862,866,3,104,52,0,863,866,5,198,0,0,864,866,5,115,0,0,865, - 862,1,0,0,0,865,863,1,0,0,0,865,864,1,0,0,0,866,107,1,0,0,0,867, - 868,7,15,0,0,868,109,1,0,0,0,869,870,7,16,0,0,870,111,1,0,0,0,871, - 872,7,17,0,0,872,113,1,0,0,0,873,876,5,193,0,0,874,876,3,112,56, - 0,875,873,1,0,0,0,875,874,1,0,0,0,876,115,1,0,0,0,877,881,5,193, - 0,0,878,881,3,108,54,0,879,881,3,110,55,0,880,877,1,0,0,0,880,878, - 1,0,0,0,880,879,1,0,0,0,881,117,1,0,0,0,882,885,3,116,58,0,883,885, - 5,115,0,0,884,882,1,0,0,0,884,883,1,0,0,0,885,119,1,0,0,0,886,887, - 5,198,0,0,887,888,5,211,0,0,888,889,3,104,52,0,889,121,1,0,0,0,115, - 124,134,142,145,149,152,156,159,162,165,168,171,175,179,182,185, - 188,191,194,203,209,236,258,266,269,275,283,286,292,294,298,303, - 306,309,313,317,320,322,325,329,333,336,338,340,343,348,359,365, - 370,377,382,386,390,395,402,410,413,416,435,449,465,477,489,497, - 501,508,514,522,527,536,540,571,588,600,610,613,617,620,632,649, - 653,659,666,678,681,685,688,699,723,732,734,736,744,749,757,767, - 770,779,782,789,799,805,809,815,822,831,837,847,849,852,860,865, - 875,880,884 + 59,7,59,1,0,1,0,3,0,123,8,0,1,0,1,0,1,1,1,1,1,1,1,1,5,1,131,8,1, + 10,1,12,1,134,9,1,1,2,1,2,1,2,1,2,1,2,3,2,141,8,2,1,3,3,3,144,8, + 3,1,3,1,3,3,3,148,8,3,1,3,3,3,151,8,3,1,3,1,3,3,3,155,8,3,1,3,3, + 3,158,8,3,1,3,3,3,161,8,3,1,3,3,3,164,8,3,1,3,3,3,167,8,3,1,3,3, + 3,170,8,3,1,3,1,3,3,3,174,8,3,1,3,1,3,3,3,178,8,3,1,3,3,3,181,8, + 3,1,3,3,3,184,8,3,1,3,3,3,187,8,3,1,3,3,3,190,8,3,1,4,1,4,1,4,1, + 5,1,5,1,5,1,5,3,5,199,8,5,1,6,1,6,1,6,1,7,3,7,205,8,7,1,7,1,7,1, + 7,1,7,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,9,1,9,1,9,1,10,1,10,1,10,1,11, + 1,11,1,11,1,11,1,11,1,11,1,11,1,11,3,11,232,8,11,1,12,1,12,1,12, + 1,13,1,13,1,13,1,13,1,14,1,14,1,14,1,14,1,15,1,15,1,15,1,15,1,15, + 1,15,3,15,251,8,15,1,16,1,16,1,16,1,17,1,17,1,17,3,17,259,8,17,1, + 17,3,17,262,8,17,1,17,1,17,1,17,1,17,3,17,268,8,17,1,17,1,17,1,17, + 1,17,1,17,1,17,3,17,276,8,17,1,17,3,17,279,8,17,1,17,1,17,1,17,1, + 17,5,17,285,8,17,10,17,12,17,288,9,17,1,18,3,18,291,8,18,1,18,1, + 18,1,18,3,18,296,8,18,1,18,3,18,299,8,18,1,18,3,18,302,8,18,1,18, + 1,18,3,18,306,8,18,1,18,1,18,3,18,310,8,18,1,18,3,18,313,8,18,3, + 18,315,8,18,1,18,3,18,318,8,18,1,18,1,18,3,18,322,8,18,1,18,1,18, + 3,18,326,8,18,1,18,3,18,329,8,18,3,18,331,8,18,3,18,333,8,18,1,19, + 3,19,336,8,19,1,19,1,19,1,19,3,19,341,8,19,1,20,1,20,1,20,1,20,1, + 20,1,20,1,20,1,20,1,20,3,20,352,8,20,1,21,1,21,1,21,1,21,3,21,358, + 8,21,1,22,1,22,1,22,3,22,363,8,22,1,23,1,23,1,23,5,23,368,8,23,10, + 23,12,23,371,9,23,1,24,1,24,3,24,375,8,24,1,24,1,24,3,24,379,8,24, + 1,24,1,24,3,24,383,8,24,1,25,1,25,1,25,3,25,388,8,25,1,26,1,26,1, + 26,5,26,393,8,26,10,26,12,26,396,9,26,1,27,1,27,1,27,1,27,1,28,3, + 28,403,8,28,1,28,3,28,406,8,28,1,28,3,28,409,8,28,1,29,1,29,1,29, + 1,29,1,30,1,30,1,30,1,30,1,31,1,31,1,31,1,32,1,32,1,32,1,32,1,32, + 1,32,3,32,428,8,32,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33,1,33, + 1,33,1,33,1,33,3,33,442,8,33,1,34,1,34,1,34,1,35,1,35,1,35,1,35, + 1,35,1,35,1,35,1,35,1,35,5,35,456,8,35,10,35,12,35,459,9,35,1,35, + 1,35,1,35,1,35,1,35,1,35,1,35,5,35,468,8,35,10,35,12,35,471,9,35, + 1,35,1,35,1,35,1,35,1,35,1,35,1,35,5,35,480,8,35,10,35,12,35,483, + 9,35,1,35,1,35,1,35,1,35,1,35,3,35,490,8,35,1,35,1,35,3,35,494,8, + 35,1,36,1,36,1,36,5,36,499,8,36,10,36,12,36,502,9,36,1,37,1,37,1, + 37,3,37,507,8,37,1,37,1,37,1,37,1,37,1,37,1,37,3,37,515,8,37,1,38, + 1,38,1,38,3,38,520,8,38,1,38,1,38,1,38,1,38,1,38,4,38,527,8,38,11, + 38,12,38,528,1,38,1,38,3,38,533,8,38,1,38,1,38,1,38,1,38,1,38,1, + 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, + 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,564,8, + 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, + 38,1,38,1,38,3,38,581,8,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, + 38,1,38,1,38,3,38,593,8,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, + 38,3,38,603,8,38,1,38,3,38,606,8,38,1,38,1,38,3,38,610,8,38,1,38, + 3,38,613,8,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38, + 3,38,625,8,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38, + 1,38,1,38,1,38,1,38,1,38,3,38,642,8,38,1,38,1,38,3,38,646,8,38,1, + 38,1,38,1,38,1,38,3,38,652,8,38,1,38,1,38,1,38,1,38,1,38,3,38,659, + 8,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,671, + 8,38,1,38,3,38,674,8,38,1,38,1,38,3,38,678,8,38,1,38,3,38,681,8, + 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,692,8,38,1, + 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1, + 38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,1,38,3,38,716,8,38,1,38,1, + 38,1,38,1,38,1,38,1,38,1,38,3,38,725,8,38,5,38,727,8,38,10,38,12, + 38,730,9,38,1,39,1,39,1,39,5,39,735,8,39,10,39,12,39,738,9,39,1, + 40,1,40,3,40,742,8,40,1,41,1,41,1,41,1,41,5,41,748,8,41,10,41,12, + 41,751,9,41,1,41,1,41,1,41,1,41,1,41,5,41,758,8,41,10,41,12,41,761, + 9,41,3,41,763,8,41,1,41,1,41,1,41,1,42,1,42,1,42,1,42,3,42,772,8, + 42,1,42,3,42,775,8,42,1,43,1,43,1,43,5,43,780,8,43,10,43,12,43,783, + 9,43,1,44,1,44,1,44,1,44,1,44,1,44,1,44,3,44,792,8,44,1,44,1,44, + 1,44,1,44,3,44,798,8,44,5,44,800,8,44,10,44,12,44,803,9,44,1,45, + 1,45,1,45,3,45,808,8,45,1,45,1,45,1,46,1,46,1,46,3,46,815,8,46,1, + 46,1,46,1,47,1,47,1,47,5,47,822,8,47,10,47,12,47,825,9,47,1,48,1, + 48,1,48,3,48,830,8,48,1,49,1,49,1,50,1,50,1,50,1,50,1,50,1,50,3, + 50,840,8,50,3,50,842,8,50,1,51,3,51,845,8,51,1,51,1,51,1,51,1,51, + 1,51,1,51,3,51,853,8,51,1,52,1,52,1,52,3,52,858,8,52,1,53,1,53,1, + 54,1,54,1,55,1,55,1,56,1,56,3,56,868,8,56,1,57,1,57,1,57,3,57,873, + 8,57,1,58,1,58,3,58,877,8,58,1,59,1,59,1,59,1,59,1,59,0,3,34,76, + 88,60,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,40, + 42,44,46,48,50,52,54,56,58,60,62,64,66,68,70,72,74,76,78,80,82,84, + 86,88,90,92,94,96,98,100,102,104,106,108,110,112,114,116,118,0,18, + 2,0,31,31,140,140,2,0,83,83,95,95,2,0,70,70,100,100,3,0,4,4,8,8, + 12,12,4,0,4,4,7,8,12,12,146,146,2,0,95,95,139,139,2,0,4,4,8,8,2, + 0,117,117,205,205,2,0,11,11,41,42,2,0,61,61,92,92,2,0,132,132,142, + 142,3,0,17,17,94,94,169,169,2,0,78,78,97,97,1,0,195,196,2,0,207, + 207,222,222,8,0,36,36,75,75,107,107,109,109,131,131,144,144,184, + 184,189,189,12,0,2,35,37,74,76,80,82,106,108,108,110,111,113,114, + 116,129,132,143,145,183,185,188,190,191,4,0,35,35,61,61,76,76,90, + 90,993,0,122,1,0,0,0,2,126,1,0,0,0,4,140,1,0,0,0,6,143,1,0,0,0,8, + 191,1,0,0,0,10,194,1,0,0,0,12,200,1,0,0,0,14,204,1,0,0,0,16,210, + 1,0,0,0,18,217,1,0,0,0,20,220,1,0,0,0,22,223,1,0,0,0,24,233,1,0, + 0,0,26,236,1,0,0,0,28,240,1,0,0,0,30,244,1,0,0,0,32,252,1,0,0,0, + 34,267,1,0,0,0,36,332,1,0,0,0,38,340,1,0,0,0,40,351,1,0,0,0,42,353, + 1,0,0,0,44,359,1,0,0,0,46,364,1,0,0,0,48,372,1,0,0,0,50,384,1,0, + 0,0,52,389,1,0,0,0,54,397,1,0,0,0,56,402,1,0,0,0,58,410,1,0,0,0, + 60,414,1,0,0,0,62,418,1,0,0,0,64,427,1,0,0,0,66,441,1,0,0,0,68,443, + 1,0,0,0,70,493,1,0,0,0,72,495,1,0,0,0,74,514,1,0,0,0,76,645,1,0, + 0,0,78,731,1,0,0,0,80,741,1,0,0,0,82,762,1,0,0,0,84,774,1,0,0,0, + 86,776,1,0,0,0,88,791,1,0,0,0,90,804,1,0,0,0,92,814,1,0,0,0,94,818, + 1,0,0,0,96,829,1,0,0,0,98,831,1,0,0,0,100,841,1,0,0,0,102,844,1, + 0,0,0,104,857,1,0,0,0,106,859,1,0,0,0,108,861,1,0,0,0,110,863,1, + 0,0,0,112,867,1,0,0,0,114,872,1,0,0,0,116,876,1,0,0,0,118,878,1, + 0,0,0,120,123,3,2,1,0,121,123,3,6,3,0,122,120,1,0,0,0,122,121,1, + 0,0,0,123,124,1,0,0,0,124,125,5,0,0,1,125,1,1,0,0,0,126,132,3,4, + 2,0,127,128,5,175,0,0,128,129,5,4,0,0,129,131,3,4,2,0,130,127,1, + 0,0,0,131,134,1,0,0,0,132,130,1,0,0,0,132,133,1,0,0,0,133,3,1,0, + 0,0,134,132,1,0,0,0,135,141,3,6,3,0,136,137,5,218,0,0,137,138,3, + 2,1,0,138,139,5,228,0,0,139,141,1,0,0,0,140,135,1,0,0,0,140,136, + 1,0,0,0,141,5,1,0,0,0,142,144,3,8,4,0,143,142,1,0,0,0,143,144,1, + 0,0,0,144,145,1,0,0,0,145,147,5,145,0,0,146,148,5,48,0,0,147,146, + 1,0,0,0,147,148,1,0,0,0,148,150,1,0,0,0,149,151,3,10,5,0,150,149, + 1,0,0,0,150,151,1,0,0,0,151,152,1,0,0,0,152,154,3,72,36,0,153,155, + 3,12,6,0,154,153,1,0,0,0,154,155,1,0,0,0,155,157,1,0,0,0,156,158, + 3,14,7,0,157,156,1,0,0,0,157,158,1,0,0,0,158,160,1,0,0,0,159,161, + 3,16,8,0,160,159,1,0,0,0,160,161,1,0,0,0,161,163,1,0,0,0,162,164, + 3,18,9,0,163,162,1,0,0,0,163,164,1,0,0,0,164,166,1,0,0,0,165,167, + 3,20,10,0,166,165,1,0,0,0,166,167,1,0,0,0,167,169,1,0,0,0,168,170, + 3,22,11,0,169,168,1,0,0,0,169,170,1,0,0,0,170,173,1,0,0,0,171,172, + 5,188,0,0,172,174,7,0,0,0,173,171,1,0,0,0,173,174,1,0,0,0,174,177, + 1,0,0,0,175,176,5,188,0,0,176,178,5,168,0,0,177,175,1,0,0,0,177, + 178,1,0,0,0,178,180,1,0,0,0,179,181,3,24,12,0,180,179,1,0,0,0,180, + 181,1,0,0,0,181,183,1,0,0,0,182,184,3,26,13,0,183,182,1,0,0,0,183, + 184,1,0,0,0,184,186,1,0,0,0,185,187,3,30,15,0,186,185,1,0,0,0,186, + 187,1,0,0,0,187,189,1,0,0,0,188,190,3,32,16,0,189,188,1,0,0,0,189, + 190,1,0,0,0,190,7,1,0,0,0,191,192,5,188,0,0,192,193,3,72,36,0,193, + 9,1,0,0,0,194,195,5,167,0,0,195,198,5,196,0,0,196,197,5,188,0,0, + 197,199,5,163,0,0,198,196,1,0,0,0,198,199,1,0,0,0,199,11,1,0,0,0, + 200,201,5,67,0,0,201,202,3,34,17,0,202,13,1,0,0,0,203,205,7,1,0, + 0,204,203,1,0,0,0,204,205,1,0,0,0,205,206,1,0,0,0,206,207,5,9,0, + 0,207,208,5,89,0,0,208,209,3,72,36,0,209,15,1,0,0,0,210,211,5,187, + 0,0,211,212,3,114,57,0,212,213,5,10,0,0,213,214,5,218,0,0,214,215, + 3,56,28,0,215,216,5,228,0,0,216,17,1,0,0,0,217,218,5,128,0,0,218, + 219,3,76,38,0,219,19,1,0,0,0,220,221,5,186,0,0,221,222,3,76,38,0, + 222,21,1,0,0,0,223,224,5,72,0,0,224,231,5,18,0,0,225,226,7,0,0,0, + 226,227,5,218,0,0,227,228,3,72,36,0,228,229,5,228,0,0,229,232,1, + 0,0,0,230,232,3,72,36,0,231,225,1,0,0,0,231,230,1,0,0,0,232,23,1, + 0,0,0,233,234,5,73,0,0,234,235,3,76,38,0,235,25,1,0,0,0,236,237, + 5,121,0,0,237,238,5,18,0,0,238,239,3,46,23,0,239,27,1,0,0,0,240, + 241,5,121,0,0,241,242,5,18,0,0,242,243,3,72,36,0,243,29,1,0,0,0, + 244,245,5,98,0,0,245,250,3,44,22,0,246,247,5,188,0,0,247,251,5,163, + 0,0,248,249,5,18,0,0,249,251,3,72,36,0,250,246,1,0,0,0,250,248,1, + 0,0,0,250,251,1,0,0,0,251,31,1,0,0,0,252,253,5,149,0,0,253,254,3, + 52,26,0,254,33,1,0,0,0,255,256,6,17,-1,0,256,258,3,88,44,0,257,259, + 5,60,0,0,258,257,1,0,0,0,258,259,1,0,0,0,259,261,1,0,0,0,260,262, + 3,42,21,0,261,260,1,0,0,0,261,262,1,0,0,0,262,268,1,0,0,0,263,264, + 5,218,0,0,264,265,3,34,17,0,265,266,5,228,0,0,266,268,1,0,0,0,267, + 255,1,0,0,0,267,263,1,0,0,0,268,286,1,0,0,0,269,270,10,3,0,0,270, + 271,3,38,19,0,271,272,3,34,17,4,272,285,1,0,0,0,273,275,10,4,0,0, + 274,276,7,2,0,0,275,274,1,0,0,0,275,276,1,0,0,0,276,278,1,0,0,0, + 277,279,3,36,18,0,278,277,1,0,0,0,278,279,1,0,0,0,279,280,1,0,0, + 0,280,281,5,89,0,0,281,282,3,34,17,0,282,283,3,40,20,0,283,285,1, + 0,0,0,284,269,1,0,0,0,284,273,1,0,0,0,285,288,1,0,0,0,286,284,1, + 0,0,0,286,287,1,0,0,0,287,35,1,0,0,0,288,286,1,0,0,0,289,291,7,3, + 0,0,290,289,1,0,0,0,290,291,1,0,0,0,291,292,1,0,0,0,292,299,5,83, + 0,0,293,295,5,83,0,0,294,296,7,3,0,0,295,294,1,0,0,0,295,296,1,0, + 0,0,296,299,1,0,0,0,297,299,7,3,0,0,298,290,1,0,0,0,298,293,1,0, + 0,0,298,297,1,0,0,0,299,333,1,0,0,0,300,302,7,4,0,0,301,300,1,0, + 0,0,301,302,1,0,0,0,302,303,1,0,0,0,303,305,7,5,0,0,304,306,5,122, + 0,0,305,304,1,0,0,0,305,306,1,0,0,0,306,315,1,0,0,0,307,309,7,5, + 0,0,308,310,5,122,0,0,309,308,1,0,0,0,309,310,1,0,0,0,310,312,1, + 0,0,0,311,313,7,4,0,0,312,311,1,0,0,0,312,313,1,0,0,0,313,315,1, + 0,0,0,314,301,1,0,0,0,314,307,1,0,0,0,315,333,1,0,0,0,316,318,7, + 6,0,0,317,316,1,0,0,0,317,318,1,0,0,0,318,319,1,0,0,0,319,321,5, + 68,0,0,320,322,5,122,0,0,321,320,1,0,0,0,321,322,1,0,0,0,322,331, + 1,0,0,0,323,325,5,68,0,0,324,326,5,122,0,0,325,324,1,0,0,0,325,326, + 1,0,0,0,326,328,1,0,0,0,327,329,7,6,0,0,328,327,1,0,0,0,328,329, + 1,0,0,0,329,331,1,0,0,0,330,317,1,0,0,0,330,323,1,0,0,0,331,333, + 1,0,0,0,332,298,1,0,0,0,332,314,1,0,0,0,332,330,1,0,0,0,333,37,1, + 0,0,0,334,336,7,2,0,0,335,334,1,0,0,0,335,336,1,0,0,0,336,337,1, + 0,0,0,337,338,5,30,0,0,338,341,5,89,0,0,339,341,5,205,0,0,340,335, + 1,0,0,0,340,339,1,0,0,0,341,39,1,0,0,0,342,343,5,118,0,0,343,352, + 3,72,36,0,344,345,5,178,0,0,345,346,5,218,0,0,346,347,3,72,36,0, + 347,348,5,228,0,0,348,352,1,0,0,0,349,350,5,178,0,0,350,352,3,72, + 36,0,351,342,1,0,0,0,351,344,1,0,0,0,351,349,1,0,0,0,352,41,1,0, + 0,0,353,354,5,143,0,0,354,357,3,50,25,0,355,356,5,117,0,0,356,358, + 3,50,25,0,357,355,1,0,0,0,357,358,1,0,0,0,358,43,1,0,0,0,359,362, + 3,76,38,0,360,361,7,7,0,0,361,363,3,76,38,0,362,360,1,0,0,0,362, + 363,1,0,0,0,363,45,1,0,0,0,364,369,3,48,24,0,365,366,5,205,0,0,366, + 368,3,48,24,0,367,365,1,0,0,0,368,371,1,0,0,0,369,367,1,0,0,0,369, + 370,1,0,0,0,370,47,1,0,0,0,371,369,1,0,0,0,372,374,3,76,38,0,373, + 375,7,8,0,0,374,373,1,0,0,0,374,375,1,0,0,0,375,378,1,0,0,0,376, + 377,5,116,0,0,377,379,7,9,0,0,378,376,1,0,0,0,378,379,1,0,0,0,379, + 382,1,0,0,0,380,381,5,25,0,0,381,383,5,198,0,0,382,380,1,0,0,0,382, + 383,1,0,0,0,383,49,1,0,0,0,384,387,3,102,51,0,385,386,5,230,0,0, + 386,388,3,102,51,0,387,385,1,0,0,0,387,388,1,0,0,0,388,51,1,0,0, + 0,389,394,3,54,27,0,390,391,5,205,0,0,391,393,3,54,27,0,392,390, + 1,0,0,0,393,396,1,0,0,0,394,392,1,0,0,0,394,395,1,0,0,0,395,53,1, + 0,0,0,396,394,1,0,0,0,397,398,3,114,57,0,398,399,5,211,0,0,399,400, + 3,104,52,0,400,55,1,0,0,0,401,403,3,58,29,0,402,401,1,0,0,0,402, + 403,1,0,0,0,403,405,1,0,0,0,404,406,3,60,30,0,405,404,1,0,0,0,405, + 406,1,0,0,0,406,408,1,0,0,0,407,409,3,62,31,0,408,407,1,0,0,0,408, + 409,1,0,0,0,409,57,1,0,0,0,410,411,5,125,0,0,411,412,5,18,0,0,412, + 413,3,72,36,0,413,59,1,0,0,0,414,415,5,121,0,0,415,416,5,18,0,0, + 416,417,3,46,23,0,417,61,1,0,0,0,418,419,7,10,0,0,419,420,3,64,32, + 0,420,63,1,0,0,0,421,428,3,66,33,0,422,423,5,16,0,0,423,424,3,66, + 33,0,424,425,5,6,0,0,425,426,3,66,33,0,426,428,1,0,0,0,427,421,1, + 0,0,0,427,422,1,0,0,0,428,65,1,0,0,0,429,430,5,32,0,0,430,442,5, + 141,0,0,431,432,5,174,0,0,432,442,5,127,0,0,433,434,5,174,0,0,434, + 442,5,63,0,0,435,436,3,102,51,0,436,437,5,127,0,0,437,442,1,0,0, + 0,438,439,3,102,51,0,439,440,5,63,0,0,440,442,1,0,0,0,441,429,1, + 0,0,0,441,431,1,0,0,0,441,433,1,0,0,0,441,435,1,0,0,0,441,438,1, + 0,0,0,442,67,1,0,0,0,443,444,3,76,38,0,444,445,5,0,0,1,445,69,1, + 0,0,0,446,494,3,114,57,0,447,448,3,114,57,0,448,449,5,218,0,0,449, + 450,3,114,57,0,450,457,3,70,35,0,451,452,5,205,0,0,452,453,3,114, + 57,0,453,454,3,70,35,0,454,456,1,0,0,0,455,451,1,0,0,0,456,459,1, + 0,0,0,457,455,1,0,0,0,457,458,1,0,0,0,458,460,1,0,0,0,459,457,1, + 0,0,0,460,461,5,228,0,0,461,494,1,0,0,0,462,463,3,114,57,0,463,464, + 5,218,0,0,464,469,3,118,59,0,465,466,5,205,0,0,466,468,3,118,59, + 0,467,465,1,0,0,0,468,471,1,0,0,0,469,467,1,0,0,0,469,470,1,0,0, + 0,470,472,1,0,0,0,471,469,1,0,0,0,472,473,5,228,0,0,473,494,1,0, + 0,0,474,475,3,114,57,0,475,476,5,218,0,0,476,481,3,70,35,0,477,478, + 5,205,0,0,478,480,3,70,35,0,479,477,1,0,0,0,480,483,1,0,0,0,481, + 479,1,0,0,0,481,482,1,0,0,0,482,484,1,0,0,0,483,481,1,0,0,0,484, + 485,5,228,0,0,485,494,1,0,0,0,486,487,3,114,57,0,487,489,5,218,0, + 0,488,490,3,72,36,0,489,488,1,0,0,0,489,490,1,0,0,0,490,491,1,0, + 0,0,491,492,5,228,0,0,492,494,1,0,0,0,493,446,1,0,0,0,493,447,1, + 0,0,0,493,462,1,0,0,0,493,474,1,0,0,0,493,486,1,0,0,0,494,71,1,0, + 0,0,495,500,3,74,37,0,496,497,5,205,0,0,497,499,3,74,37,0,498,496, + 1,0,0,0,499,502,1,0,0,0,500,498,1,0,0,0,500,501,1,0,0,0,501,73,1, + 0,0,0,502,500,1,0,0,0,503,504,3,92,46,0,504,505,5,209,0,0,505,507, + 1,0,0,0,506,503,1,0,0,0,506,507,1,0,0,0,507,508,1,0,0,0,508,515, + 5,201,0,0,509,510,5,218,0,0,510,511,3,2,1,0,511,512,5,228,0,0,512, + 515,1,0,0,0,513,515,3,76,38,0,514,506,1,0,0,0,514,509,1,0,0,0,514, + 513,1,0,0,0,515,75,1,0,0,0,516,517,6,38,-1,0,517,519,5,19,0,0,518, + 520,3,76,38,0,519,518,1,0,0,0,519,520,1,0,0,0,520,526,1,0,0,0,521, + 522,5,185,0,0,522,523,3,76,38,0,523,524,5,162,0,0,524,525,3,76,38, + 0,525,527,1,0,0,0,526,521,1,0,0,0,527,528,1,0,0,0,528,526,1,0,0, + 0,528,529,1,0,0,0,529,532,1,0,0,0,530,531,5,51,0,0,531,533,3,76, + 38,0,532,530,1,0,0,0,532,533,1,0,0,0,533,534,1,0,0,0,534,535,5,52, + 0,0,535,646,1,0,0,0,536,537,5,20,0,0,537,538,5,218,0,0,538,539,3, + 76,38,0,539,540,5,10,0,0,540,541,3,70,35,0,541,542,5,228,0,0,542, + 646,1,0,0,0,543,544,5,35,0,0,544,646,5,198,0,0,545,546,5,58,0,0, + 546,547,5,218,0,0,547,548,3,106,53,0,548,549,5,67,0,0,549,550,3, + 76,38,0,550,551,5,228,0,0,551,646,1,0,0,0,552,553,5,85,0,0,553,554, + 3,76,38,0,554,555,3,106,53,0,555,646,1,0,0,0,556,557,5,154,0,0,557, + 558,5,218,0,0,558,559,3,76,38,0,559,560,5,67,0,0,560,563,3,76,38, + 0,561,562,5,64,0,0,562,564,3,76,38,0,563,561,1,0,0,0,563,564,1,0, + 0,0,564,565,1,0,0,0,565,566,5,228,0,0,566,646,1,0,0,0,567,568,5, + 165,0,0,568,646,5,198,0,0,569,570,5,170,0,0,570,571,5,218,0,0,571, + 572,7,11,0,0,572,573,5,198,0,0,573,574,5,67,0,0,574,575,3,76,38, + 0,575,576,5,228,0,0,576,646,1,0,0,0,577,578,3,114,57,0,578,580,5, + 218,0,0,579,581,3,72,36,0,580,579,1,0,0,0,580,581,1,0,0,0,581,582, + 1,0,0,0,582,583,5,228,0,0,583,584,1,0,0,0,584,585,5,124,0,0,585, + 586,5,218,0,0,586,587,3,56,28,0,587,588,5,228,0,0,588,646,1,0,0, + 0,589,590,3,114,57,0,590,592,5,218,0,0,591,593,3,72,36,0,592,591, + 1,0,0,0,592,593,1,0,0,0,593,594,1,0,0,0,594,595,5,228,0,0,595,596, + 1,0,0,0,596,597,5,124,0,0,597,598,3,114,57,0,598,646,1,0,0,0,599, + 605,3,114,57,0,600,602,5,218,0,0,601,603,3,72,36,0,602,601,1,0,0, + 0,602,603,1,0,0,0,603,604,1,0,0,0,604,606,5,228,0,0,605,600,1,0, + 0,0,605,606,1,0,0,0,606,607,1,0,0,0,607,609,5,218,0,0,608,610,5, + 48,0,0,609,608,1,0,0,0,609,610,1,0,0,0,610,612,1,0,0,0,611,613,3, + 78,39,0,612,611,1,0,0,0,612,613,1,0,0,0,613,614,1,0,0,0,614,615, + 5,228,0,0,615,646,1,0,0,0,616,646,3,104,52,0,617,618,5,207,0,0,618, + 646,3,76,38,17,619,620,5,114,0,0,620,646,3,76,38,12,621,622,3,92, + 46,0,622,623,5,209,0,0,623,625,1,0,0,0,624,621,1,0,0,0,624,625,1, + 0,0,0,625,626,1,0,0,0,626,646,5,201,0,0,627,628,5,218,0,0,628,629, + 3,2,1,0,629,630,5,228,0,0,630,646,1,0,0,0,631,632,5,218,0,0,632, + 633,3,76,38,0,633,634,5,228,0,0,634,646,1,0,0,0,635,636,5,218,0, + 0,636,637,3,72,36,0,637,638,5,228,0,0,638,646,1,0,0,0,639,641,5, + 216,0,0,640,642,3,72,36,0,641,640,1,0,0,0,641,642,1,0,0,0,642,643, + 1,0,0,0,643,646,5,227,0,0,644,646,3,84,42,0,645,516,1,0,0,0,645, + 536,1,0,0,0,645,543,1,0,0,0,645,545,1,0,0,0,645,552,1,0,0,0,645, + 556,1,0,0,0,645,567,1,0,0,0,645,569,1,0,0,0,645,577,1,0,0,0,645, + 589,1,0,0,0,645,599,1,0,0,0,645,616,1,0,0,0,645,617,1,0,0,0,645, + 619,1,0,0,0,645,624,1,0,0,0,645,627,1,0,0,0,645,631,1,0,0,0,645, + 635,1,0,0,0,645,639,1,0,0,0,645,644,1,0,0,0,646,728,1,0,0,0,647, + 651,10,16,0,0,648,652,5,201,0,0,649,652,5,230,0,0,650,652,5,221, + 0,0,651,648,1,0,0,0,651,649,1,0,0,0,651,650,1,0,0,0,652,653,1,0, + 0,0,653,727,3,76,38,17,654,658,10,15,0,0,655,659,5,222,0,0,656,659, + 5,207,0,0,657,659,5,206,0,0,658,655,1,0,0,0,658,656,1,0,0,0,658, + 657,1,0,0,0,659,660,1,0,0,0,660,727,3,76,38,16,661,680,10,14,0,0, + 662,681,5,210,0,0,663,681,5,211,0,0,664,681,5,220,0,0,665,681,5, + 217,0,0,666,681,5,212,0,0,667,681,5,219,0,0,668,681,5,213,0,0,669, + 671,5,70,0,0,670,669,1,0,0,0,670,671,1,0,0,0,671,673,1,0,0,0,672, + 674,5,114,0,0,673,672,1,0,0,0,673,674,1,0,0,0,674,675,1,0,0,0,675, + 681,5,79,0,0,676,678,5,114,0,0,677,676,1,0,0,0,677,678,1,0,0,0,678, + 679,1,0,0,0,679,681,7,12,0,0,680,662,1,0,0,0,680,663,1,0,0,0,680, + 664,1,0,0,0,680,665,1,0,0,0,680,666,1,0,0,0,680,667,1,0,0,0,680, + 668,1,0,0,0,680,670,1,0,0,0,680,677,1,0,0,0,681,682,1,0,0,0,682, + 727,3,76,38,15,683,684,10,11,0,0,684,685,5,6,0,0,685,727,3,76,38, + 12,686,687,10,10,0,0,687,688,5,120,0,0,688,727,3,76,38,11,689,691, + 10,9,0,0,690,692,5,114,0,0,691,690,1,0,0,0,691,692,1,0,0,0,692,693, + 1,0,0,0,693,694,5,16,0,0,694,695,3,76,38,0,695,696,5,6,0,0,696,697, + 3,76,38,10,697,727,1,0,0,0,698,699,10,8,0,0,699,700,5,223,0,0,700, + 701,3,76,38,0,701,702,5,204,0,0,702,703,3,76,38,8,703,727,1,0,0, + 0,704,705,10,19,0,0,705,706,5,216,0,0,706,707,3,76,38,0,707,708, + 5,227,0,0,708,727,1,0,0,0,709,710,10,18,0,0,710,711,5,209,0,0,711, + 727,5,196,0,0,712,713,10,13,0,0,713,715,5,87,0,0,714,716,5,114,0, + 0,715,714,1,0,0,0,715,716,1,0,0,0,716,717,1,0,0,0,717,727,5,115, + 0,0,718,724,10,7,0,0,719,725,3,112,56,0,720,721,5,10,0,0,721,725, + 3,114,57,0,722,723,5,10,0,0,723,725,5,198,0,0,724,719,1,0,0,0,724, + 720,1,0,0,0,724,722,1,0,0,0,725,727,1,0,0,0,726,647,1,0,0,0,726, + 654,1,0,0,0,726,661,1,0,0,0,726,683,1,0,0,0,726,686,1,0,0,0,726, + 689,1,0,0,0,726,698,1,0,0,0,726,704,1,0,0,0,726,709,1,0,0,0,726, + 712,1,0,0,0,726,718,1,0,0,0,727,730,1,0,0,0,728,726,1,0,0,0,728, + 729,1,0,0,0,729,77,1,0,0,0,730,728,1,0,0,0,731,736,3,80,40,0,732, + 733,5,205,0,0,733,735,3,80,40,0,734,732,1,0,0,0,735,738,1,0,0,0, + 736,734,1,0,0,0,736,737,1,0,0,0,737,79,1,0,0,0,738,736,1,0,0,0,739, + 742,3,82,41,0,740,742,3,76,38,0,741,739,1,0,0,0,741,740,1,0,0,0, + 742,81,1,0,0,0,743,744,5,218,0,0,744,749,3,114,57,0,745,746,5,205, + 0,0,746,748,3,114,57,0,747,745,1,0,0,0,748,751,1,0,0,0,749,747,1, + 0,0,0,749,750,1,0,0,0,750,752,1,0,0,0,751,749,1,0,0,0,752,753,5, + 228,0,0,753,763,1,0,0,0,754,759,3,114,57,0,755,756,5,205,0,0,756, + 758,3,114,57,0,757,755,1,0,0,0,758,761,1,0,0,0,759,757,1,0,0,0,759, + 760,1,0,0,0,760,763,1,0,0,0,761,759,1,0,0,0,762,743,1,0,0,0,762, + 754,1,0,0,0,763,764,1,0,0,0,764,765,5,200,0,0,765,766,3,76,38,0, + 766,83,1,0,0,0,767,775,5,199,0,0,768,769,3,92,46,0,769,770,5,209, + 0,0,770,772,1,0,0,0,771,768,1,0,0,0,771,772,1,0,0,0,772,773,1,0, + 0,0,773,775,3,86,43,0,774,767,1,0,0,0,774,771,1,0,0,0,775,85,1,0, + 0,0,776,781,3,114,57,0,777,778,5,209,0,0,778,780,3,114,57,0,779, + 777,1,0,0,0,780,783,1,0,0,0,781,779,1,0,0,0,781,782,1,0,0,0,782, + 87,1,0,0,0,783,781,1,0,0,0,784,785,6,44,-1,0,785,792,3,92,46,0,786, + 792,3,90,45,0,787,788,5,218,0,0,788,789,3,2,1,0,789,790,5,228,0, + 0,790,792,1,0,0,0,791,784,1,0,0,0,791,786,1,0,0,0,791,787,1,0,0, + 0,792,801,1,0,0,0,793,797,10,1,0,0,794,798,3,112,56,0,795,796,5, + 10,0,0,796,798,3,114,57,0,797,794,1,0,0,0,797,795,1,0,0,0,798,800, + 1,0,0,0,799,793,1,0,0,0,800,803,1,0,0,0,801,799,1,0,0,0,801,802, + 1,0,0,0,802,89,1,0,0,0,803,801,1,0,0,0,804,805,3,114,57,0,805,807, + 5,218,0,0,806,808,3,94,47,0,807,806,1,0,0,0,807,808,1,0,0,0,808, + 809,1,0,0,0,809,810,5,228,0,0,810,91,1,0,0,0,811,812,3,98,49,0,812, + 813,5,209,0,0,813,815,1,0,0,0,814,811,1,0,0,0,814,815,1,0,0,0,815, + 816,1,0,0,0,816,817,3,114,57,0,817,93,1,0,0,0,818,823,3,96,48,0, + 819,820,5,205,0,0,820,822,3,96,48,0,821,819,1,0,0,0,822,825,1,0, + 0,0,823,821,1,0,0,0,823,824,1,0,0,0,824,95,1,0,0,0,825,823,1,0,0, + 0,826,830,3,86,43,0,827,830,3,90,45,0,828,830,3,104,52,0,829,826, + 1,0,0,0,829,827,1,0,0,0,829,828,1,0,0,0,830,97,1,0,0,0,831,832,3, + 114,57,0,832,99,1,0,0,0,833,842,5,194,0,0,834,835,5,209,0,0,835, + 842,7,13,0,0,836,837,5,196,0,0,837,839,5,209,0,0,838,840,7,13,0, + 0,839,838,1,0,0,0,839,840,1,0,0,0,840,842,1,0,0,0,841,833,1,0,0, + 0,841,834,1,0,0,0,841,836,1,0,0,0,842,101,1,0,0,0,843,845,7,14,0, + 0,844,843,1,0,0,0,844,845,1,0,0,0,845,852,1,0,0,0,846,853,3,100, + 50,0,847,853,5,195,0,0,848,853,5,196,0,0,849,853,5,197,0,0,850,853, + 5,81,0,0,851,853,5,112,0,0,852,846,1,0,0,0,852,847,1,0,0,0,852,848, + 1,0,0,0,852,849,1,0,0,0,852,850,1,0,0,0,852,851,1,0,0,0,853,103, + 1,0,0,0,854,858,3,102,51,0,855,858,5,198,0,0,856,858,5,115,0,0,857, + 854,1,0,0,0,857,855,1,0,0,0,857,856,1,0,0,0,858,105,1,0,0,0,859, + 860,7,15,0,0,860,107,1,0,0,0,861,862,7,16,0,0,862,109,1,0,0,0,863, + 864,7,17,0,0,864,111,1,0,0,0,865,868,5,193,0,0,866,868,3,110,55, + 0,867,865,1,0,0,0,867,866,1,0,0,0,868,113,1,0,0,0,869,873,5,193, + 0,0,870,873,3,106,53,0,871,873,3,108,54,0,872,869,1,0,0,0,872,870, + 1,0,0,0,872,871,1,0,0,0,873,115,1,0,0,0,874,877,3,114,57,0,875,877, + 5,115,0,0,876,874,1,0,0,0,876,875,1,0,0,0,877,117,1,0,0,0,878,879, + 5,198,0,0,879,880,5,211,0,0,880,881,3,102,51,0,881,119,1,0,0,0,114, + 122,132,140,143,147,150,154,157,160,163,166,169,173,177,180,183, + 186,189,198,204,231,250,258,261,267,275,278,284,286,290,295,298, + 301,305,309,312,314,317,321,325,328,330,332,335,340,351,357,362, + 369,374,378,382,387,394,402,405,408,427,441,457,469,481,489,493, + 500,506,514,519,528,532,563,580,592,602,605,609,612,624,641,645, + 651,658,670,673,677,680,691,715,724,726,728,736,741,749,759,762, + 771,774,781,791,797,801,807,814,823,829,839,841,844,852,857,867, + 872,876 ] class HogQLParser ( Parser ): @@ -488,68 +485,66 @@ class HogQLParser ( Parser ): RULE_havingClause = 12 RULE_orderByClause = 13 RULE_projectionOrderByClause = 14 - RULE_limitByClause = 15 - RULE_limitClause = 16 - RULE_settingsClause = 17 - RULE_joinExpr = 18 - RULE_joinOp = 19 - RULE_joinOpCross = 20 - RULE_joinConstraintClause = 21 - RULE_sampleClause = 22 - RULE_limitExpr = 23 - RULE_orderExprList = 24 - RULE_orderExpr = 25 - RULE_ratioExpr = 26 - RULE_settingExprList = 27 - RULE_settingExpr = 28 - RULE_windowExpr = 29 - RULE_winPartitionByClause = 30 - RULE_winOrderByClause = 31 - RULE_winFrameClause = 32 - RULE_winFrameExtend = 33 - RULE_winFrameBound = 34 - RULE_expr = 35 - RULE_columnTypeExpr = 36 - RULE_columnExprList = 37 - RULE_columnsExpr = 38 - RULE_columnExpr = 39 - RULE_columnArgList = 40 - RULE_columnArgExpr = 41 - RULE_columnLambdaExpr = 42 - RULE_columnIdentifier = 43 - RULE_nestedIdentifier = 44 - RULE_tableExpr = 45 - RULE_tableFunctionExpr = 46 - RULE_tableIdentifier = 47 - RULE_tableArgList = 48 - RULE_tableArgExpr = 49 - RULE_databaseIdentifier = 50 - RULE_floatingLiteral = 51 - RULE_numberLiteral = 52 - RULE_literal = 53 - RULE_interval = 54 - RULE_keyword = 55 - RULE_keywordForAlias = 56 - RULE_alias = 57 - RULE_identifier = 58 - RULE_identifierOrNull = 59 - RULE_enumValue = 60 + RULE_limitClause = 15 + RULE_settingsClause = 16 + RULE_joinExpr = 17 + RULE_joinOp = 18 + RULE_joinOpCross = 19 + RULE_joinConstraintClause = 20 + RULE_sampleClause = 21 + RULE_limitExpr = 22 + RULE_orderExprList = 23 + RULE_orderExpr = 24 + RULE_ratioExpr = 25 + RULE_settingExprList = 26 + RULE_settingExpr = 27 + RULE_windowExpr = 28 + RULE_winPartitionByClause = 29 + RULE_winOrderByClause = 30 + RULE_winFrameClause = 31 + RULE_winFrameExtend = 32 + RULE_winFrameBound = 33 + RULE_expr = 34 + RULE_columnTypeExpr = 35 + RULE_columnExprList = 36 + RULE_columnsExpr = 37 + RULE_columnExpr = 38 + RULE_columnArgList = 39 + RULE_columnArgExpr = 40 + RULE_columnLambdaExpr = 41 + RULE_columnIdentifier = 42 + RULE_nestedIdentifier = 43 + RULE_tableExpr = 44 + RULE_tableFunctionExpr = 45 + RULE_tableIdentifier = 46 + RULE_tableArgList = 47 + RULE_tableArgExpr = 48 + RULE_databaseIdentifier = 49 + RULE_floatingLiteral = 50 + RULE_numberLiteral = 51 + RULE_literal = 52 + RULE_interval = 53 + RULE_keyword = 54 + RULE_keywordForAlias = 55 + RULE_alias = 56 + RULE_identifier = 57 + RULE_identifierOrNull = 58 + RULE_enumValue = 59 ruleNames = [ "select", "selectUnionStmt", "selectStmtWithParens", "selectStmt", "withClause", "topClause", "fromClause", "arrayJoinClause", "windowClause", "prewhereClause", "whereClause", "groupByClause", "havingClause", "orderByClause", - "projectionOrderByClause", "limitByClause", "limitClause", - "settingsClause", "joinExpr", "joinOp", "joinOpCross", - "joinConstraintClause", "sampleClause", "limitExpr", - "orderExprList", "orderExpr", "ratioExpr", "settingExprList", - "settingExpr", "windowExpr", "winPartitionByClause", - "winOrderByClause", "winFrameClause", "winFrameExtend", - "winFrameBound", "expr", "columnTypeExpr", "columnExprList", - "columnsExpr", "columnExpr", "columnArgList", "columnArgExpr", - "columnLambdaExpr", "columnIdentifier", "nestedIdentifier", - "tableExpr", "tableFunctionExpr", "tableIdentifier", - "tableArgList", "tableArgExpr", "databaseIdentifier", + "projectionOrderByClause", "limitClause", "settingsClause", + "joinExpr", "joinOp", "joinOpCross", "joinConstraintClause", + "sampleClause", "limitExpr", "orderExprList", "orderExpr", + "ratioExpr", "settingExprList", "settingExpr", "windowExpr", + "winPartitionByClause", "winOrderByClause", "winFrameClause", + "winFrameExtend", "winFrameBound", "expr", "columnTypeExpr", + "columnExprList", "columnsExpr", "columnExpr", "columnArgList", + "columnArgExpr", "columnLambdaExpr", "columnIdentifier", + "nestedIdentifier", "tableExpr", "tableFunctionExpr", + "tableIdentifier", "tableArgList", "tableArgExpr", "databaseIdentifier", "floatingLiteral", "numberLiteral", "literal", "interval", "keyword", "keywordForAlias", "alias", "identifier", "identifierOrNull", "enumValue" ] @@ -835,21 +830,21 @@ def select(self): self.enterRule(localctx, 0, self.RULE_select) try: self.enterOuterAlt(localctx, 1) - self.state = 124 + self.state = 122 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input,0,self._ctx) if la_ == 1: - self.state = 122 + self.state = 120 self.selectUnionStmt() pass elif la_ == 2: - self.state = 123 + self.state = 121 self.selectStmt() pass - self.state = 126 + self.state = 124 self.match(HogQLParser.EOF) except RecognitionException as re: localctx.exception = re @@ -905,19 +900,19 @@ def selectUnionStmt(self): self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 128 + self.state = 126 self.selectStmtWithParens() - self.state = 134 + self.state = 132 self._errHandler.sync(self) _la = self._input.LA(1) while _la==175: - self.state = 129 + self.state = 127 self.match(HogQLParser.UNION) - self.state = 130 + self.state = 128 self.match(HogQLParser.ALL) - self.state = 131 + self.state = 129 self.selectStmtWithParens() - self.state = 136 + self.state = 134 self._errHandler.sync(self) _la = self._input.LA(1) @@ -968,21 +963,21 @@ def selectStmtWithParens(self): localctx = HogQLParser.SelectStmtWithParensContext(self, self._ctx, self.state) self.enterRule(localctx, 4, self.RULE_selectStmtWithParens) try: - self.state = 142 + self.state = 140 self._errHandler.sync(self) token = self._input.LA(1) if token in [145, 188]: self.enterOuterAlt(localctx, 1) - self.state = 137 + self.state = 135 self.selectStmt() pass elif token in [218]: self.enterOuterAlt(localctx, 2) - self.state = 138 + self.state = 136 self.match(HogQLParser.LPAREN) - self.state = 139 + self.state = 137 self.selectUnionStmt() - self.state = 140 + self.state = 138 self.match(HogQLParser.RPAREN) pass else: @@ -1055,10 +1050,6 @@ def orderByClause(self): return self.getTypedRuleContext(HogQLParser.OrderByClauseContext,0) - def limitByClause(self): - return self.getTypedRuleContext(HogQLParser.LimitByClauseContext,0) - - def limitClause(self): return self.getTypedRuleContext(HogQLParser.LimitClauseContext,0) @@ -1104,89 +1095,89 @@ def selectStmt(self): self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 145 + self.state = 143 self._errHandler.sync(self) _la = self._input.LA(1) if _la==188: - self.state = 144 + self.state = 142 localctx.with_ = self.withClause() - self.state = 147 + self.state = 145 self.match(HogQLParser.SELECT) - self.state = 149 + self.state = 147 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input,4,self._ctx) if la_ == 1: - self.state = 148 + self.state = 146 self.match(HogQLParser.DISTINCT) - self.state = 152 + self.state = 150 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input,5,self._ctx) if la_ == 1: - self.state = 151 + self.state = 149 self.topClause() - self.state = 154 + self.state = 152 localctx.columns = self.columnExprList() - self.state = 156 + self.state = 154 self._errHandler.sync(self) _la = self._input.LA(1) if _la==67: - self.state = 155 + self.state = 153 localctx.from_ = self.fromClause() - self.state = 159 + self.state = 157 self._errHandler.sync(self) _la = self._input.LA(1) if _la==9 or _la==83 or _la==95: - self.state = 158 + self.state = 156 self.arrayJoinClause() - self.state = 162 + self.state = 160 self._errHandler.sync(self) _la = self._input.LA(1) if _la==187: - self.state = 161 + self.state = 159 self.windowClause() - self.state = 165 + self.state = 163 self._errHandler.sync(self) _la = self._input.LA(1) if _la==128: - self.state = 164 + self.state = 162 self.prewhereClause() - self.state = 168 + self.state = 166 self._errHandler.sync(self) _la = self._input.LA(1) if _la==186: - self.state = 167 + self.state = 165 localctx.where = self.whereClause() - self.state = 171 + self.state = 169 self._errHandler.sync(self) _la = self._input.LA(1) if _la==72: - self.state = 170 + self.state = 168 self.groupByClause() - self.state = 175 + self.state = 173 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input,12,self._ctx) if la_ == 1: - self.state = 173 + self.state = 171 self.match(HogQLParser.WITH) - self.state = 174 + self.state = 172 _la = self._input.LA(1) if not(_la==31 or _la==140): self._errHandler.recoverInline(self) @@ -1195,53 +1186,45 @@ def selectStmt(self): self.consume() - self.state = 179 + self.state = 177 self._errHandler.sync(self) _la = self._input.LA(1) if _la==188: - self.state = 177 + self.state = 175 self.match(HogQLParser.WITH) - self.state = 178 + self.state = 176 self.match(HogQLParser.TOTALS) - self.state = 182 + self.state = 180 self._errHandler.sync(self) _la = self._input.LA(1) if _la==73: - self.state = 181 + self.state = 179 self.havingClause() - self.state = 185 + self.state = 183 self._errHandler.sync(self) _la = self._input.LA(1) if _la==121: - self.state = 184 + self.state = 182 self.orderByClause() - self.state = 188 - self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,16,self._ctx) - if la_ == 1: - self.state = 187 - self.limitByClause() - - - self.state = 191 + self.state = 186 self._errHandler.sync(self) _la = self._input.LA(1) if _la==98: - self.state = 190 + self.state = 185 self.limitClause() - self.state = 194 + self.state = 189 self._errHandler.sync(self) _la = self._input.LA(1) if _la==149: - self.state = 193 + self.state = 188 self.settingsClause() @@ -1286,9 +1269,9 @@ def withClause(self): self.enterRule(localctx, 8, self.RULE_withClause) try: self.enterOuterAlt(localctx, 1) - self.state = 196 + self.state = 191 self.match(HogQLParser.WITH) - self.state = 197 + self.state = 192 self.columnExprList() except RecognitionException as re: localctx.exception = re @@ -1336,17 +1319,17 @@ def topClause(self): self.enterRule(localctx, 10, self.RULE_topClause) try: self.enterOuterAlt(localctx, 1) - self.state = 199 + self.state = 194 self.match(HogQLParser.TOP) - self.state = 200 + self.state = 195 self.match(HogQLParser.DECIMAL_LITERAL) - self.state = 203 + self.state = 198 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,19,self._ctx) + la_ = self._interp.adaptivePredict(self._input,18,self._ctx) if la_ == 1: - self.state = 201 + self.state = 196 self.match(HogQLParser.WITH) - self.state = 202 + self.state = 197 self.match(HogQLParser.TIES) @@ -1391,9 +1374,9 @@ def fromClause(self): self.enterRule(localctx, 12, self.RULE_fromClause) try: self.enterOuterAlt(localctx, 1) - self.state = 205 + self.state = 200 self.match(HogQLParser.FROM) - self.state = 206 + self.state = 201 self.joinExpr(0) except RecognitionException as re: localctx.exception = re @@ -1446,11 +1429,11 @@ def arrayJoinClause(self): self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 209 + self.state = 204 self._errHandler.sync(self) _la = self._input.LA(1) if _la==83 or _la==95: - self.state = 208 + self.state = 203 _la = self._input.LA(1) if not(_la==83 or _la==95): self._errHandler.recoverInline(self) @@ -1459,11 +1442,11 @@ def arrayJoinClause(self): self.consume() - self.state = 211 + self.state = 206 self.match(HogQLParser.ARRAY) - self.state = 212 + self.state = 207 self.match(HogQLParser.JOIN) - self.state = 213 + self.state = 208 self.columnExprList() except RecognitionException as re: localctx.exception = re @@ -1519,17 +1502,17 @@ def windowClause(self): self.enterRule(localctx, 16, self.RULE_windowClause) try: self.enterOuterAlt(localctx, 1) - self.state = 215 + self.state = 210 self.match(HogQLParser.WINDOW) - self.state = 216 + self.state = 211 self.identifier() - self.state = 217 + self.state = 212 self.match(HogQLParser.AS) - self.state = 218 + self.state = 213 self.match(HogQLParser.LPAREN) - self.state = 219 + self.state = 214 self.windowExpr() - self.state = 220 + self.state = 215 self.match(HogQLParser.RPAREN) except RecognitionException as re: localctx.exception = re @@ -1572,9 +1555,9 @@ def prewhereClause(self): self.enterRule(localctx, 18, self.RULE_prewhereClause) try: self.enterOuterAlt(localctx, 1) - self.state = 222 + self.state = 217 self.match(HogQLParser.PREWHERE) - self.state = 223 + self.state = 218 self.columnExpr(0) except RecognitionException as re: localctx.exception = re @@ -1617,9 +1600,9 @@ def whereClause(self): self.enterRule(localctx, 20, self.RULE_whereClause) try: self.enterOuterAlt(localctx, 1) - self.state = 225 + self.state = 220 self.match(HogQLParser.WHERE) - self.state = 226 + self.state = 221 self.columnExpr(0) except RecognitionException as re: localctx.exception = re @@ -1678,31 +1661,31 @@ def groupByClause(self): self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 228 + self.state = 223 self.match(HogQLParser.GROUP) - self.state = 229 + self.state = 224 self.match(HogQLParser.BY) - self.state = 236 + self.state = 231 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,21,self._ctx) + la_ = self._interp.adaptivePredict(self._input,20,self._ctx) if la_ == 1: - self.state = 230 + self.state = 225 _la = self._input.LA(1) if not(_la==31 or _la==140): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() - self.state = 231 + self.state = 226 self.match(HogQLParser.LPAREN) - self.state = 232 + self.state = 227 self.columnExprList() - self.state = 233 + self.state = 228 self.match(HogQLParser.RPAREN) pass elif la_ == 2: - self.state = 235 + self.state = 230 self.columnExprList() pass @@ -1748,9 +1731,9 @@ def havingClause(self): self.enterRule(localctx, 24, self.RULE_havingClause) try: self.enterOuterAlt(localctx, 1) - self.state = 238 + self.state = 233 self.match(HogQLParser.HAVING) - self.state = 239 + self.state = 234 self.columnExpr(0) except RecognitionException as re: localctx.exception = re @@ -1796,11 +1779,11 @@ def orderByClause(self): self.enterRule(localctx, 26, self.RULE_orderByClause) try: self.enterOuterAlt(localctx, 1) - self.state = 241 + self.state = 236 self.match(HogQLParser.ORDER) - self.state = 242 + self.state = 237 self.match(HogQLParser.BY) - self.state = 243 + self.state = 238 self.orderExprList() except RecognitionException as re: localctx.exception = re @@ -1846,11 +1829,11 @@ def projectionOrderByClause(self): self.enterRule(localctx, 28, self.RULE_projectionOrderByClause) try: self.enterOuterAlt(localctx, 1) - self.state = 245 + self.state = 240 self.match(HogQLParser.ORDER) - self.state = 246 + self.state = 241 self.match(HogQLParser.BY) - self.state = 247 + self.state = 242 self.columnExprList() except RecognitionException as re: localctx.exception = re @@ -1861,7 +1844,7 @@ def projectionOrderByClause(self): return localctx - class LimitByClauseContext(ParserRuleContext): + class LimitClauseContext(ParserRuleContext): __slots__ = 'parser' def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): @@ -1882,55 +1865,6 @@ def columnExprList(self): return self.getTypedRuleContext(HogQLParser.ColumnExprListContext,0) - def getRuleIndex(self): - return HogQLParser.RULE_limitByClause - - def accept(self, visitor:ParseTreeVisitor): - if hasattr( visitor, "visitLimitByClause" ): - return visitor.visitLimitByClause(self) - else: - return visitor.visitChildren(self) - - - - - def limitByClause(self): - - localctx = HogQLParser.LimitByClauseContext(self, self._ctx, self.state) - self.enterRule(localctx, 30, self.RULE_limitByClause) - try: - self.enterOuterAlt(localctx, 1) - self.state = 249 - self.match(HogQLParser.LIMIT) - self.state = 250 - self.limitExpr() - self.state = 251 - self.match(HogQLParser.BY) - self.state = 252 - self.columnExprList() - except RecognitionException as re: - localctx.exception = re - self._errHandler.reportError(self, re) - self._errHandler.recover(self, re) - finally: - self.exitRule() - return localctx - - - class LimitClauseContext(ParserRuleContext): - __slots__ = 'parser' - - def __init__(self, parser, parent:ParserRuleContext=None, invokingState:int=-1): - super().__init__(parent, invokingState) - self.parser = parser - - def LIMIT(self): - return self.getToken(HogQLParser.LIMIT, 0) - - def limitExpr(self): - return self.getTypedRuleContext(HogQLParser.LimitExprContext,0) - - def WITH(self): return self.getToken(HogQLParser.WITH, 0) @@ -1952,24 +1886,32 @@ def accept(self, visitor:ParseTreeVisitor): def limitClause(self): localctx = HogQLParser.LimitClauseContext(self, self._ctx, self.state) - self.enterRule(localctx, 32, self.RULE_limitClause) - self._la = 0 # Token type + self.enterRule(localctx, 30, self.RULE_limitClause) try: self.enterOuterAlt(localctx, 1) - self.state = 254 + self.state = 244 self.match(HogQLParser.LIMIT) - self.state = 255 + self.state = 245 self.limitExpr() - self.state = 258 + self.state = 250 self._errHandler.sync(self) - _la = self._input.LA(1) - if _la==188: - self.state = 256 + token = self._input.LA(1) + if token in [188]: + self.state = 246 self.match(HogQLParser.WITH) - self.state = 257 + self.state = 247 self.match(HogQLParser.TIES) - - + pass + elif token in [18]: + self.state = 248 + self.match(HogQLParser.BY) + self.state = 249 + self.columnExprList() + pass + elif token in [-1, 149, 175, 228]: + pass + else: + pass except RecognitionException as re: localctx.exception = re self._errHandler.reportError(self, re) @@ -2008,12 +1950,12 @@ def accept(self, visitor:ParseTreeVisitor): def settingsClause(self): localctx = HogQLParser.SettingsClauseContext(self, self._ctx, self.state) - self.enterRule(localctx, 34, self.RULE_settingsClause) + self.enterRule(localctx, 32, self.RULE_settingsClause) try: self.enterOuterAlt(localctx, 1) - self.state = 260 + self.state = 252 self.match(HogQLParser.SETTINGS) - self.state = 261 + self.state = 253 self.settingExprList() except RecognitionException as re: localctx.exception = re @@ -2144,34 +2086,34 @@ def joinExpr(self, _p:int=0): _parentState = self.state localctx = HogQLParser.JoinExprContext(self, self._ctx, _parentState) _prevctx = localctx - _startState = 36 - self.enterRecursionRule(localctx, 36, self.RULE_joinExpr, _p) + _startState = 34 + self.enterRecursionRule(localctx, 34, self.RULE_joinExpr, _p) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 275 + self.state = 267 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,25,self._ctx) + la_ = self._interp.adaptivePredict(self._input,24,self._ctx) if la_ == 1: localctx = HogQLParser.JoinExprTableContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 264 + self.state = 256 self.tableExpr(0) - self.state = 266 + self.state = 258 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,23,self._ctx) + la_ = self._interp.adaptivePredict(self._input,22,self._ctx) if la_ == 1: - self.state = 265 + self.state = 257 self.match(HogQLParser.FINAL) - self.state = 269 + self.state = 261 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,24,self._ctx) + la_ = self._interp.adaptivePredict(self._input,23,self._ctx) if la_ == 1: - self.state = 268 + self.state = 260 self.sampleClause() @@ -2181,52 +2123,52 @@ def joinExpr(self, _p:int=0): localctx = HogQLParser.JoinExprParensContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 271 + self.state = 263 self.match(HogQLParser.LPAREN) - self.state = 272 + self.state = 264 self.joinExpr(0) - self.state = 273 + self.state = 265 self.match(HogQLParser.RPAREN) pass self._ctx.stop = self._input.LT(-1) - self.state = 294 + self.state = 286 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,29,self._ctx) + _alt = self._interp.adaptivePredict(self._input,28,self._ctx) while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: if _alt==1: if self._parseListeners is not None: self.triggerExitRuleEvent() _prevctx = localctx - self.state = 292 + self.state = 284 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,28,self._ctx) + la_ = self._interp.adaptivePredict(self._input,27,self._ctx) if la_ == 1: localctx = HogQLParser.JoinExprCrossOpContext(self, HogQLParser.JoinExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_joinExpr) - self.state = 277 + self.state = 269 if not self.precpred(self._ctx, 3): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 3)") - self.state = 278 + self.state = 270 self.joinOpCross() - self.state = 279 + self.state = 271 self.joinExpr(4) pass elif la_ == 2: localctx = HogQLParser.JoinExprOpContext(self, HogQLParser.JoinExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_joinExpr) - self.state = 281 + self.state = 273 if not self.precpred(self._ctx, 4): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 4)") - self.state = 283 + self.state = 275 self._errHandler.sync(self) _la = self._input.LA(1) if _la==70 or _la==100: - self.state = 282 + self.state = 274 _la = self._input.LA(1) if not(_la==70 or _la==100): self._errHandler.recoverInline(self) @@ -2235,26 +2177,26 @@ def joinExpr(self, _p:int=0): self.consume() - self.state = 286 + self.state = 278 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & 4496) != 0 or (((_la - 68)) & ~0x3f) == 0 and ((1 << (_la - 68)) & 134250497) != 0 or _la==139 or _la==146: - self.state = 285 + self.state = 277 self.joinOp() - self.state = 288 + self.state = 280 self.match(HogQLParser.JOIN) - self.state = 289 + self.state = 281 self.joinExpr(0) - self.state = 290 + self.state = 282 self.joinConstraintClause() pass - self.state = 296 + self.state = 288 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,29,self._ctx) + _alt = self._interp.adaptivePredict(self._input,28,self._ctx) except RecognitionException as re: localctx.exception = re @@ -2360,24 +2302,24 @@ def accept(self, visitor:ParseTreeVisitor): def joinOp(self): localctx = HogQLParser.JoinOpContext(self, self._ctx, self.state) - self.enterRule(localctx, 38, self.RULE_joinOp) + self.enterRule(localctx, 36, self.RULE_joinOp) self._la = 0 # Token type try: - self.state = 340 + self.state = 332 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,43,self._ctx) + la_ = self._interp.adaptivePredict(self._input,42,self._ctx) if la_ == 1: localctx = HogQLParser.JoinOpInnerContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 306 + self.state = 298 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,32,self._ctx) + la_ = self._interp.adaptivePredict(self._input,31,self._ctx) if la_ == 1: - self.state = 298 + self.state = 290 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & 4368) != 0: - self.state = 297 + self.state = 289 _la = self._input.LA(1) if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 4368) != 0): self._errHandler.recoverInline(self) @@ -2386,18 +2328,18 @@ def joinOp(self): self.consume() - self.state = 300 + self.state = 292 self.match(HogQLParser.INNER) pass elif la_ == 2: - self.state = 301 + self.state = 293 self.match(HogQLParser.INNER) - self.state = 303 + self.state = 295 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & 4368) != 0: - self.state = 302 + self.state = 294 _la = self._input.LA(1) if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 4368) != 0): self._errHandler.recoverInline(self) @@ -2409,7 +2351,7 @@ def joinOp(self): pass elif la_ == 3: - self.state = 305 + self.state = 297 _la = self._input.LA(1) if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 4368) != 0): self._errHandler.recoverInline(self) @@ -2424,15 +2366,15 @@ def joinOp(self): elif la_ == 2: localctx = HogQLParser.JoinOpLeftRightContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 322 + self.state = 314 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,37,self._ctx) + la_ = self._interp.adaptivePredict(self._input,36,self._ctx) if la_ == 1: - self.state = 309 + self.state = 301 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & 4496) != 0 or _la==146: - self.state = 308 + self.state = 300 _la = self._input.LA(1) if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 4496) != 0 or _la==146): self._errHandler.recoverInline(self) @@ -2441,44 +2383,44 @@ def joinOp(self): self.consume() - self.state = 311 + self.state = 303 _la = self._input.LA(1) if not(_la==95 or _la==139): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() - self.state = 313 + self.state = 305 self._errHandler.sync(self) _la = self._input.LA(1) if _la==122: - self.state = 312 + self.state = 304 self.match(HogQLParser.OUTER) pass elif la_ == 2: - self.state = 315 + self.state = 307 _la = self._input.LA(1) if not(_la==95 or _la==139): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() - self.state = 317 + self.state = 309 self._errHandler.sync(self) _la = self._input.LA(1) if _la==122: - self.state = 316 + self.state = 308 self.match(HogQLParser.OUTER) - self.state = 320 + self.state = 312 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & 4496) != 0 or _la==146: - self.state = 319 + self.state = 311 _la = self._input.LA(1) if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 4496) != 0 or _la==146): self._errHandler.recoverInline(self) @@ -2495,15 +2437,15 @@ def joinOp(self): elif la_ == 3: localctx = HogQLParser.JoinOpFullContext(self, localctx) self.enterOuterAlt(localctx, 3) - self.state = 338 + self.state = 330 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,42,self._ctx) + la_ = self._interp.adaptivePredict(self._input,41,self._ctx) if la_ == 1: - self.state = 325 + self.state = 317 self._errHandler.sync(self) _la = self._input.LA(1) if _la==4 or _la==8: - self.state = 324 + self.state = 316 _la = self._input.LA(1) if not(_la==4 or _la==8): self._errHandler.recoverInline(self) @@ -2512,34 +2454,34 @@ def joinOp(self): self.consume() - self.state = 327 + self.state = 319 self.match(HogQLParser.FULL) - self.state = 329 + self.state = 321 self._errHandler.sync(self) _la = self._input.LA(1) if _la==122: - self.state = 328 + self.state = 320 self.match(HogQLParser.OUTER) pass elif la_ == 2: - self.state = 331 + self.state = 323 self.match(HogQLParser.FULL) - self.state = 333 + self.state = 325 self._errHandler.sync(self) _la = self._input.LA(1) if _la==122: - self.state = 332 + self.state = 324 self.match(HogQLParser.OUTER) - self.state = 336 + self.state = 328 self._errHandler.sync(self) _la = self._input.LA(1) if _la==4 or _la==8: - self.state = 335 + self.state = 327 _la = self._input.LA(1) if not(_la==4 or _la==8): self._errHandler.recoverInline(self) @@ -2600,19 +2542,19 @@ def accept(self, visitor:ParseTreeVisitor): def joinOpCross(self): localctx = HogQLParser.JoinOpCrossContext(self, self._ctx, self.state) - self.enterRule(localctx, 40, self.RULE_joinOpCross) + self.enterRule(localctx, 38, self.RULE_joinOpCross) self._la = 0 # Token type try: - self.state = 348 + self.state = 340 self._errHandler.sync(self) token = self._input.LA(1) if token in [30, 70, 100]: self.enterOuterAlt(localctx, 1) - self.state = 343 + self.state = 335 self._errHandler.sync(self) _la = self._input.LA(1) if _la==70 or _la==100: - self.state = 342 + self.state = 334 _la = self._input.LA(1) if not(_la==70 or _la==100): self._errHandler.recoverInline(self) @@ -2621,14 +2563,14 @@ def joinOpCross(self): self.consume() - self.state = 345 + self.state = 337 self.match(HogQLParser.CROSS) - self.state = 346 + self.state = 338 self.match(HogQLParser.JOIN) pass elif token in [205]: self.enterOuterAlt(localctx, 2) - self.state = 347 + self.state = 339 self.match(HogQLParser.COMMA) pass else: @@ -2681,36 +2623,36 @@ def accept(self, visitor:ParseTreeVisitor): def joinConstraintClause(self): localctx = HogQLParser.JoinConstraintClauseContext(self, self._ctx, self.state) - self.enterRule(localctx, 42, self.RULE_joinConstraintClause) + self.enterRule(localctx, 40, self.RULE_joinConstraintClause) try: - self.state = 359 + self.state = 351 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,46,self._ctx) + la_ = self._interp.adaptivePredict(self._input,45,self._ctx) if la_ == 1: self.enterOuterAlt(localctx, 1) - self.state = 350 + self.state = 342 self.match(HogQLParser.ON) - self.state = 351 + self.state = 343 self.columnExprList() pass elif la_ == 2: self.enterOuterAlt(localctx, 2) - self.state = 352 + self.state = 344 self.match(HogQLParser.USING) - self.state = 353 + self.state = 345 self.match(HogQLParser.LPAREN) - self.state = 354 + self.state = 346 self.columnExprList() - self.state = 355 + self.state = 347 self.match(HogQLParser.RPAREN) pass elif la_ == 3: self.enterOuterAlt(localctx, 3) - self.state = 357 + self.state = 349 self.match(HogQLParser.USING) - self.state = 358 + self.state = 350 self.columnExprList() pass @@ -2759,20 +2701,20 @@ def accept(self, visitor:ParseTreeVisitor): def sampleClause(self): localctx = HogQLParser.SampleClauseContext(self, self._ctx, self.state) - self.enterRule(localctx, 44, self.RULE_sampleClause) + self.enterRule(localctx, 42, self.RULE_sampleClause) try: self.enterOuterAlt(localctx, 1) - self.state = 361 + self.state = 353 self.match(HogQLParser.SAMPLE) - self.state = 362 + self.state = 354 self.ratioExpr() - self.state = 365 + self.state = 357 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,47,self._ctx) + la_ = self._interp.adaptivePredict(self._input,46,self._ctx) if la_ == 1: - self.state = 363 + self.state = 355 self.match(HogQLParser.OFFSET) - self.state = 364 + self.state = 356 self.ratioExpr() @@ -2820,24 +2762,24 @@ def accept(self, visitor:ParseTreeVisitor): def limitExpr(self): localctx = HogQLParser.LimitExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 46, self.RULE_limitExpr) + self.enterRule(localctx, 44, self.RULE_limitExpr) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 367 + self.state = 359 self.columnExpr(0) - self.state = 370 + self.state = 362 self._errHandler.sync(self) _la = self._input.LA(1) if _la==117 or _la==205: - self.state = 368 + self.state = 360 _la = self._input.LA(1) if not(_la==117 or _la==205): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() - self.state = 369 + self.state = 361 self.columnExpr(0) @@ -2885,21 +2827,21 @@ def accept(self, visitor:ParseTreeVisitor): def orderExprList(self): localctx = HogQLParser.OrderExprListContext(self, self._ctx, self.state) - self.enterRule(localctx, 48, self.RULE_orderExprList) + self.enterRule(localctx, 46, self.RULE_orderExprList) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 372 + self.state = 364 self.orderExpr() - self.state = 377 + self.state = 369 self._errHandler.sync(self) _la = self._input.LA(1) while _la==205: - self.state = 373 + self.state = 365 self.match(HogQLParser.COMMA) - self.state = 374 + self.state = 366 self.orderExpr() - self.state = 379 + self.state = 371 self._errHandler.sync(self) _la = self._input.LA(1) @@ -2962,17 +2904,17 @@ def accept(self, visitor:ParseTreeVisitor): def orderExpr(self): localctx = HogQLParser.OrderExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 50, self.RULE_orderExpr) + self.enterRule(localctx, 48, self.RULE_orderExpr) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 380 + self.state = 372 self.columnExpr(0) - self.state = 382 + self.state = 374 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & 6597069768704) != 0: - self.state = 381 + self.state = 373 _la = self._input.LA(1) if not(((_la) & ~0x3f) == 0 and ((1 << _la) & 6597069768704) != 0): self._errHandler.recoverInline(self) @@ -2981,13 +2923,13 @@ def orderExpr(self): self.consume() - self.state = 386 + self.state = 378 self._errHandler.sync(self) _la = self._input.LA(1) if _la==116: - self.state = 384 + self.state = 376 self.match(HogQLParser.NULLS) - self.state = 385 + self.state = 377 _la = self._input.LA(1) if not(_la==61 or _la==92): self._errHandler.recoverInline(self) @@ -2996,13 +2938,13 @@ def orderExpr(self): self.consume() - self.state = 390 + self.state = 382 self._errHandler.sync(self) _la = self._input.LA(1) if _la==25: - self.state = 388 + self.state = 380 self.match(HogQLParser.COLLATE) - self.state = 389 + self.state = 381 self.match(HogQLParser.STRING_LITERAL) @@ -3047,18 +2989,18 @@ def accept(self, visitor:ParseTreeVisitor): def ratioExpr(self): localctx = HogQLParser.RatioExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 52, self.RULE_ratioExpr) + self.enterRule(localctx, 50, self.RULE_ratioExpr) try: self.enterOuterAlt(localctx, 1) - self.state = 392 + self.state = 384 self.numberLiteral() - self.state = 395 + self.state = 387 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,53,self._ctx) + la_ = self._interp.adaptivePredict(self._input,52,self._ctx) if la_ == 1: - self.state = 393 + self.state = 385 self.match(HogQLParser.SLASH) - self.state = 394 + self.state = 386 self.numberLiteral() @@ -3106,21 +3048,21 @@ def accept(self, visitor:ParseTreeVisitor): def settingExprList(self): localctx = HogQLParser.SettingExprListContext(self, self._ctx, self.state) - self.enterRule(localctx, 54, self.RULE_settingExprList) + self.enterRule(localctx, 52, self.RULE_settingExprList) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 397 + self.state = 389 self.settingExpr() - self.state = 402 + self.state = 394 self._errHandler.sync(self) _la = self._input.LA(1) while _la==205: - self.state = 398 + self.state = 390 self.match(HogQLParser.COMMA) - self.state = 399 + self.state = 391 self.settingExpr() - self.state = 404 + self.state = 396 self._errHandler.sync(self) _la = self._input.LA(1) @@ -3166,14 +3108,14 @@ def accept(self, visitor:ParseTreeVisitor): def settingExpr(self): localctx = HogQLParser.SettingExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 56, self.RULE_settingExpr) + self.enterRule(localctx, 54, self.RULE_settingExpr) try: self.enterOuterAlt(localctx, 1) - self.state = 405 + self.state = 397 self.identifier() - self.state = 406 + self.state = 398 self.match(HogQLParser.EQ_SINGLE) - self.state = 407 + self.state = 399 self.literal() except RecognitionException as re: localctx.exception = re @@ -3218,31 +3160,31 @@ def accept(self, visitor:ParseTreeVisitor): def windowExpr(self): localctx = HogQLParser.WindowExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 58, self.RULE_windowExpr) + self.enterRule(localctx, 56, self.RULE_windowExpr) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 410 + self.state = 402 self._errHandler.sync(self) _la = self._input.LA(1) if _la==125: - self.state = 409 + self.state = 401 self.winPartitionByClause() - self.state = 413 + self.state = 405 self._errHandler.sync(self) _la = self._input.LA(1) if _la==121: - self.state = 412 + self.state = 404 self.winOrderByClause() - self.state = 416 + self.state = 408 self._errHandler.sync(self) _la = self._input.LA(1) if _la==132 or _la==142: - self.state = 415 + self.state = 407 self.winFrameClause() @@ -3287,14 +3229,14 @@ def accept(self, visitor:ParseTreeVisitor): def winPartitionByClause(self): localctx = HogQLParser.WinPartitionByClauseContext(self, self._ctx, self.state) - self.enterRule(localctx, 60, self.RULE_winPartitionByClause) + self.enterRule(localctx, 58, self.RULE_winPartitionByClause) try: self.enterOuterAlt(localctx, 1) - self.state = 418 + self.state = 410 self.match(HogQLParser.PARTITION) - self.state = 419 + self.state = 411 self.match(HogQLParser.BY) - self.state = 420 + self.state = 412 self.columnExprList() except RecognitionException as re: localctx.exception = re @@ -3337,14 +3279,14 @@ def accept(self, visitor:ParseTreeVisitor): def winOrderByClause(self): localctx = HogQLParser.WinOrderByClauseContext(self, self._ctx, self.state) - self.enterRule(localctx, 62, self.RULE_winOrderByClause) + self.enterRule(localctx, 60, self.RULE_winOrderByClause) try: self.enterOuterAlt(localctx, 1) - self.state = 422 + self.state = 414 self.match(HogQLParser.ORDER) - self.state = 423 + self.state = 415 self.match(HogQLParser.BY) - self.state = 424 + self.state = 416 self.orderExprList() except RecognitionException as re: localctx.exception = re @@ -3387,18 +3329,18 @@ def accept(self, visitor:ParseTreeVisitor): def winFrameClause(self): localctx = HogQLParser.WinFrameClauseContext(self, self._ctx, self.state) - self.enterRule(localctx, 64, self.RULE_winFrameClause) + self.enterRule(localctx, 62, self.RULE_winFrameClause) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 426 + self.state = 418 _la = self._input.LA(1) if not(_la==132 or _la==142): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() - self.state = 427 + self.state = 419 self.winFrameExtend() except RecognitionException as re: localctx.exception = re @@ -3471,27 +3413,27 @@ def accept(self, visitor:ParseTreeVisitor): def winFrameExtend(self): localctx = HogQLParser.WinFrameExtendContext(self, self._ctx, self.state) - self.enterRule(localctx, 66, self.RULE_winFrameExtend) + self.enterRule(localctx, 64, self.RULE_winFrameExtend) try: - self.state = 435 + self.state = 427 self._errHandler.sync(self) token = self._input.LA(1) if token in [32, 81, 112, 174, 194, 195, 196, 197, 207, 209, 222]: localctx = HogQLParser.FrameStartContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 429 + self.state = 421 self.winFrameBound() pass elif token in [16]: localctx = HogQLParser.FrameBetweenContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 430 + self.state = 422 self.match(HogQLParser.BETWEEN) - self.state = 431 + self.state = 423 self.winFrameBound() - self.state = 432 + self.state = 424 self.match(HogQLParser.AND) - self.state = 433 + self.state = 425 self.winFrameBound() pass else: @@ -3547,44 +3489,44 @@ def accept(self, visitor:ParseTreeVisitor): def winFrameBound(self): localctx = HogQLParser.WinFrameBoundContext(self, self._ctx, self.state) - self.enterRule(localctx, 68, self.RULE_winFrameBound) + self.enterRule(localctx, 66, self.RULE_winFrameBound) try: self.enterOuterAlt(localctx, 1) - self.state = 449 + self.state = 441 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,59,self._ctx) + la_ = self._interp.adaptivePredict(self._input,58,self._ctx) if la_ == 1: - self.state = 437 + self.state = 429 self.match(HogQLParser.CURRENT) - self.state = 438 + self.state = 430 self.match(HogQLParser.ROW) pass elif la_ == 2: - self.state = 439 + self.state = 431 self.match(HogQLParser.UNBOUNDED) - self.state = 440 + self.state = 432 self.match(HogQLParser.PRECEDING) pass elif la_ == 3: - self.state = 441 + self.state = 433 self.match(HogQLParser.UNBOUNDED) - self.state = 442 + self.state = 434 self.match(HogQLParser.FOLLOWING) pass elif la_ == 4: - self.state = 443 + self.state = 435 self.numberLiteral() - self.state = 444 + self.state = 436 self.match(HogQLParser.PRECEDING) pass elif la_ == 5: - self.state = 446 + self.state = 438 self.numberLiteral() - self.state = 447 + self.state = 439 self.match(HogQLParser.FOLLOWING) pass @@ -3627,12 +3569,12 @@ def accept(self, visitor:ParseTreeVisitor): def expr(self): localctx = HogQLParser.ExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 70, self.RULE_expr) + self.enterRule(localctx, 68, self.RULE_expr) try: self.enterOuterAlt(localctx, 1) - self.state = 451 + self.state = 443 self.columnExpr(0) - self.state = 452 + self.state = 444 self.match(HogQLParser.EOF) except RecognitionException as re: localctx.exception = re @@ -3804,114 +3746,114 @@ def accept(self, visitor:ParseTreeVisitor): def columnTypeExpr(self): localctx = HogQLParser.ColumnTypeExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 72, self.RULE_columnTypeExpr) + self.enterRule(localctx, 70, self.RULE_columnTypeExpr) self._la = 0 # Token type try: - self.state = 501 + self.state = 493 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,64,self._ctx) + la_ = self._interp.adaptivePredict(self._input,63,self._ctx) if la_ == 1: localctx = HogQLParser.ColumnTypeExprSimpleContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 454 + self.state = 446 self.identifier() pass elif la_ == 2: localctx = HogQLParser.ColumnTypeExprNestedContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 455 + self.state = 447 self.identifier() - self.state = 456 + self.state = 448 self.match(HogQLParser.LPAREN) - self.state = 457 + self.state = 449 self.identifier() - self.state = 458 + self.state = 450 self.columnTypeExpr() - self.state = 465 + self.state = 457 self._errHandler.sync(self) _la = self._input.LA(1) while _la==205: - self.state = 459 + self.state = 451 self.match(HogQLParser.COMMA) - self.state = 460 + self.state = 452 self.identifier() - self.state = 461 + self.state = 453 self.columnTypeExpr() - self.state = 467 + self.state = 459 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 468 + self.state = 460 self.match(HogQLParser.RPAREN) pass elif la_ == 3: localctx = HogQLParser.ColumnTypeExprEnumContext(self, localctx) self.enterOuterAlt(localctx, 3) - self.state = 470 + self.state = 462 self.identifier() - self.state = 471 + self.state = 463 self.match(HogQLParser.LPAREN) - self.state = 472 + self.state = 464 self.enumValue() - self.state = 477 + self.state = 469 self._errHandler.sync(self) _la = self._input.LA(1) while _la==205: - self.state = 473 + self.state = 465 self.match(HogQLParser.COMMA) - self.state = 474 + self.state = 466 self.enumValue() - self.state = 479 + self.state = 471 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 480 + self.state = 472 self.match(HogQLParser.RPAREN) pass elif la_ == 4: localctx = HogQLParser.ColumnTypeExprComplexContext(self, localctx) self.enterOuterAlt(localctx, 4) - self.state = 482 + self.state = 474 self.identifier() - self.state = 483 + self.state = 475 self.match(HogQLParser.LPAREN) - self.state = 484 + self.state = 476 self.columnTypeExpr() - self.state = 489 + self.state = 481 self._errHandler.sync(self) _la = self._input.LA(1) while _la==205: - self.state = 485 + self.state = 477 self.match(HogQLParser.COMMA) - self.state = 486 + self.state = 478 self.columnTypeExpr() - self.state = 491 + self.state = 483 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 492 + self.state = 484 self.match(HogQLParser.RPAREN) pass elif la_ == 5: localctx = HogQLParser.ColumnTypeExprParamContext(self, localctx) self.enterOuterAlt(localctx, 5) - self.state = 494 + self.state = 486 self.identifier() - self.state = 495 + self.state = 487 self.match(HogQLParser.LPAREN) - self.state = 497 + self.state = 489 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & -4) != 0 or (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -1) != 0 or (((_la - 128)) & ~0x3f) == 0 and ((1 << (_la - 128)) & -5) != 0 or (((_la - 193)) & ~0x3f) == 0 and ((1 << (_la - 193)) & 578896255) != 0: - self.state = 496 + self.state = 488 self.columnExprList() - self.state = 499 + self.state = 491 self.match(HogQLParser.RPAREN) pass @@ -3960,23 +3902,23 @@ def accept(self, visitor:ParseTreeVisitor): def columnExprList(self): localctx = HogQLParser.ColumnExprListContext(self, self._ctx, self.state) - self.enterRule(localctx, 74, self.RULE_columnExprList) + self.enterRule(localctx, 72, self.RULE_columnExprList) try: self.enterOuterAlt(localctx, 1) - self.state = 503 + self.state = 495 self.columnsExpr() - self.state = 508 + self.state = 500 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,65,self._ctx) + _alt = self._interp.adaptivePredict(self._input,64,self._ctx) while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: if _alt==1: - self.state = 504 + self.state = 496 self.match(HogQLParser.COMMA) - self.state = 505 + self.state = 497 self.columnsExpr() - self.state = 510 + self.state = 502 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,65,self._ctx) + _alt = self._interp.adaptivePredict(self._input,64,self._ctx) except RecognitionException as re: localctx.exception = re @@ -4067,44 +4009,44 @@ def accept(self, visitor:ParseTreeVisitor): def columnsExpr(self): localctx = HogQLParser.ColumnsExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 76, self.RULE_columnsExpr) + self.enterRule(localctx, 74, self.RULE_columnsExpr) self._la = 0 # Token type try: - self.state = 522 + self.state = 514 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,67,self._ctx) + la_ = self._interp.adaptivePredict(self._input,66,self._ctx) if la_ == 1: localctx = HogQLParser.ColumnsExprAsteriskContext(self, localctx) self.enterOuterAlt(localctx, 1) - self.state = 514 + self.state = 506 self._errHandler.sync(self) _la = self._input.LA(1) if (((_la - 2)) & ~0x3f) == 0 and ((1 << (_la - 2)) & -1) != 0 or (((_la - 66)) & ~0x3f) == 0 and ((1 << (_la - 66)) & -633318697631745) != 0 or (((_la - 131)) & ~0x3f) == 0 and ((1 << (_la - 131)) & 6917529027641081855) != 0: - self.state = 511 + self.state = 503 self.tableIdentifier() - self.state = 512 + self.state = 504 self.match(HogQLParser.DOT) - self.state = 516 + self.state = 508 self.match(HogQLParser.ASTERISK) pass elif la_ == 2: localctx = HogQLParser.ColumnsExprSubqueryContext(self, localctx) self.enterOuterAlt(localctx, 2) - self.state = 517 + self.state = 509 self.match(HogQLParser.LPAREN) - self.state = 518 + self.state = 510 self.selectUnionStmt() - self.state = 519 + self.state = 511 self.match(HogQLParser.RPAREN) pass elif la_ == 3: localctx = HogQLParser.ColumnsExprColumnContext(self, localctx) self.enterOuterAlt(localctx, 3) - self.state = 521 + self.state = 513 self.columnExpr(0) pass @@ -4927,58 +4869,58 @@ def columnExpr(self, _p:int=0): _parentState = self.state localctx = HogQLParser.ColumnExprContext(self, self._ctx, _parentState) _prevctx = localctx - _startState = 78 - self.enterRecursionRule(localctx, 78, self.RULE_columnExpr, _p) + _startState = 76 + self.enterRecursionRule(localctx, 76, self.RULE_columnExpr, _p) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 653 + self.state = 645 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,80,self._ctx) + la_ = self._interp.adaptivePredict(self._input,79,self._ctx) if la_ == 1: localctx = HogQLParser.ColumnExprCaseContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 525 + self.state = 517 self.match(HogQLParser.CASE) - self.state = 527 + self.state = 519 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,68,self._ctx) + la_ = self._interp.adaptivePredict(self._input,67,self._ctx) if la_ == 1: - self.state = 526 + self.state = 518 localctx.caseExpr = self.columnExpr(0) - self.state = 534 + self.state = 526 self._errHandler.sync(self) _la = self._input.LA(1) while True: - self.state = 529 + self.state = 521 self.match(HogQLParser.WHEN) - self.state = 530 + self.state = 522 localctx.whenExpr = self.columnExpr(0) - self.state = 531 + self.state = 523 self.match(HogQLParser.THEN) - self.state = 532 + self.state = 524 localctx.thenExpr = self.columnExpr(0) - self.state = 536 + self.state = 528 self._errHandler.sync(self) _la = self._input.LA(1) if not (_la==185): break - self.state = 540 + self.state = 532 self._errHandler.sync(self) _la = self._input.LA(1) if _la==51: - self.state = 538 + self.state = 530 self.match(HogQLParser.ELSE) - self.state = 539 + self.state = 531 localctx.elseExpr = self.columnExpr(0) - self.state = 542 + self.state = 534 self.match(HogQLParser.END) pass @@ -4986,17 +4928,17 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprCastContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 544 + self.state = 536 self.match(HogQLParser.CAST) - self.state = 545 + self.state = 537 self.match(HogQLParser.LPAREN) - self.state = 546 + self.state = 538 self.columnExpr(0) - self.state = 547 + self.state = 539 self.match(HogQLParser.AS) - self.state = 548 + self.state = 540 self.columnTypeExpr() - self.state = 549 + self.state = 541 self.match(HogQLParser.RPAREN) pass @@ -5004,9 +4946,9 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprDateContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 551 + self.state = 543 self.match(HogQLParser.DATE) - self.state = 552 + self.state = 544 self.match(HogQLParser.STRING_LITERAL) pass @@ -5014,17 +4956,17 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprExtractContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 553 + self.state = 545 self.match(HogQLParser.EXTRACT) - self.state = 554 + self.state = 546 self.match(HogQLParser.LPAREN) - self.state = 555 + self.state = 547 self.interval() - self.state = 556 + self.state = 548 self.match(HogQLParser.FROM) - self.state = 557 + self.state = 549 self.columnExpr(0) - self.state = 558 + self.state = 550 self.match(HogQLParser.RPAREN) pass @@ -5032,11 +4974,11 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprIntervalContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 560 + self.state = 552 self.match(HogQLParser.INTERVAL) - self.state = 561 + self.state = 553 self.columnExpr(0) - self.state = 562 + self.state = 554 self.interval() pass @@ -5044,27 +4986,27 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprSubstringContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 564 + self.state = 556 self.match(HogQLParser.SUBSTRING) - self.state = 565 + self.state = 557 self.match(HogQLParser.LPAREN) - self.state = 566 + self.state = 558 self.columnExpr(0) - self.state = 567 + self.state = 559 self.match(HogQLParser.FROM) - self.state = 568 + self.state = 560 self.columnExpr(0) - self.state = 571 + self.state = 563 self._errHandler.sync(self) _la = self._input.LA(1) if _la==64: - self.state = 569 + self.state = 561 self.match(HogQLParser.FOR) - self.state = 570 + self.state = 562 self.columnExpr(0) - self.state = 573 + self.state = 565 self.match(HogQLParser.RPAREN) pass @@ -5072,9 +5014,9 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprTimestampContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 575 + self.state = 567 self.match(HogQLParser.TIMESTAMP) - self.state = 576 + self.state = 568 self.match(HogQLParser.STRING_LITERAL) pass @@ -5082,24 +5024,24 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprTrimContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 577 + self.state = 569 self.match(HogQLParser.TRIM) - self.state = 578 + self.state = 570 self.match(HogQLParser.LPAREN) - self.state = 579 + self.state = 571 _la = self._input.LA(1) if not(_la==17 or _la==94 or _la==169): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() - self.state = 580 + self.state = 572 self.match(HogQLParser.STRING_LITERAL) - self.state = 581 + self.state = 573 self.match(HogQLParser.FROM) - self.state = 582 + self.state = 574 self.columnExpr(0) - self.state = 583 + self.state = 575 self.match(HogQLParser.RPAREN) pass @@ -5107,28 +5049,28 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprWinFunctionContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 585 + self.state = 577 self.identifier() - self.state = 586 + self.state = 578 self.match(HogQLParser.LPAREN) - self.state = 588 + self.state = 580 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & -4) != 0 or (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -1) != 0 or (((_la - 128)) & ~0x3f) == 0 and ((1 << (_la - 128)) & -5) != 0 or (((_la - 193)) & ~0x3f) == 0 and ((1 << (_la - 193)) & 578896255) != 0: - self.state = 587 + self.state = 579 self.columnExprList() - self.state = 590 + self.state = 582 self.match(HogQLParser.RPAREN) - self.state = 592 + self.state = 584 self.match(HogQLParser.OVER) - self.state = 593 + self.state = 585 self.match(HogQLParser.LPAREN) - self.state = 594 + self.state = 586 self.windowExpr() - self.state = 595 + self.state = 587 self.match(HogQLParser.RPAREN) pass @@ -5136,24 +5078,24 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprWinFunctionTargetContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 597 + self.state = 589 self.identifier() - self.state = 598 + self.state = 590 self.match(HogQLParser.LPAREN) - self.state = 600 + self.state = 592 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & -4) != 0 or (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -1) != 0 or (((_la - 128)) & ~0x3f) == 0 and ((1 << (_la - 128)) & -5) != 0 or (((_la - 193)) & ~0x3f) == 0 and ((1 << (_la - 193)) & 578896255) != 0: - self.state = 599 + self.state = 591 self.columnExprList() - self.state = 602 + self.state = 594 self.match(HogQLParser.RPAREN) - self.state = 604 + self.state = 596 self.match(HogQLParser.OVER) - self.state = 605 + self.state = 597 self.identifier() pass @@ -5161,45 +5103,45 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprFunctionContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 607 + self.state = 599 self.identifier() - self.state = 613 + self.state = 605 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,75,self._ctx) + la_ = self._interp.adaptivePredict(self._input,74,self._ctx) if la_ == 1: - self.state = 608 + self.state = 600 self.match(HogQLParser.LPAREN) - self.state = 610 + self.state = 602 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & -4) != 0 or (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -1) != 0 or (((_la - 128)) & ~0x3f) == 0 and ((1 << (_la - 128)) & -5) != 0 or (((_la - 193)) & ~0x3f) == 0 and ((1 << (_la - 193)) & 578896255) != 0: - self.state = 609 + self.state = 601 self.columnExprList() - self.state = 612 + self.state = 604 self.match(HogQLParser.RPAREN) - self.state = 615 + self.state = 607 self.match(HogQLParser.LPAREN) - self.state = 617 + self.state = 609 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,76,self._ctx) + la_ = self._interp.adaptivePredict(self._input,75,self._ctx) if la_ == 1: - self.state = 616 + self.state = 608 self.match(HogQLParser.DISTINCT) - self.state = 620 + self.state = 612 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & -4) != 0 or (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -1) != 0 or (((_la - 128)) & ~0x3f) == 0 and ((1 << (_la - 128)) & -5) != 0 or (((_la - 193)) & ~0x3f) == 0 and ((1 << (_la - 193)) & 578896255) != 0: - self.state = 619 + self.state = 611 self.columnArgList() - self.state = 622 + self.state = 614 self.match(HogQLParser.RPAREN) pass @@ -5207,7 +5149,7 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprLiteralContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 624 + self.state = 616 self.literal() pass @@ -5215,9 +5157,9 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprNegateContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 625 + self.state = 617 self.match(HogQLParser.DASH) - self.state = 626 + self.state = 618 self.columnExpr(17) pass @@ -5225,9 +5167,9 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprNotContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 627 + self.state = 619 self.match(HogQLParser.NOT) - self.state = 628 + self.state = 620 self.columnExpr(12) pass @@ -5235,17 +5177,17 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprAsteriskContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 632 + self.state = 624 self._errHandler.sync(self) _la = self._input.LA(1) if (((_la - 2)) & ~0x3f) == 0 and ((1 << (_la - 2)) & -1) != 0 or (((_la - 66)) & ~0x3f) == 0 and ((1 << (_la - 66)) & -633318697631745) != 0 or (((_la - 131)) & ~0x3f) == 0 and ((1 << (_la - 131)) & 6917529027641081855) != 0: - self.state = 629 + self.state = 621 self.tableIdentifier() - self.state = 630 + self.state = 622 self.match(HogQLParser.DOT) - self.state = 634 + self.state = 626 self.match(HogQLParser.ASTERISK) pass @@ -5253,11 +5195,11 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprSubqueryContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 635 + self.state = 627 self.match(HogQLParser.LPAREN) - self.state = 636 + self.state = 628 self.selectUnionStmt() - self.state = 637 + self.state = 629 self.match(HogQLParser.RPAREN) pass @@ -5265,11 +5207,11 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprParensContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 639 + self.state = 631 self.match(HogQLParser.LPAREN) - self.state = 640 + self.state = 632 self.columnExpr(0) - self.state = 641 + self.state = 633 self.match(HogQLParser.RPAREN) pass @@ -5277,11 +5219,11 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprTupleContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 643 + self.state = 635 self.match(HogQLParser.LPAREN) - self.state = 644 + self.state = 636 self.columnExprList() - self.state = 645 + self.state = 637 self.match(HogQLParser.RPAREN) pass @@ -5289,17 +5231,17 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprArrayContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 647 + self.state = 639 self.match(HogQLParser.LBRACKET) - self.state = 649 + self.state = 641 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & -4) != 0 or (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -1) != 0 or (((_la - 128)) & ~0x3f) == 0 and ((1 << (_la - 128)) & -5) != 0 or (((_la - 193)) & ~0x3f) == 0 and ((1 << (_la - 193)) & 578896255) != 0: - self.state = 648 + self.state = 640 self.columnExprList() - self.state = 651 + self.state = 643 self.match(HogQLParser.RBRACKET) pass @@ -5307,50 +5249,50 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprIdentifierContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 652 + self.state = 644 self.columnIdentifier() pass self._ctx.stop = self._input.LT(-1) - self.state = 736 + self.state = 728 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,91,self._ctx) + _alt = self._interp.adaptivePredict(self._input,90,self._ctx) while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: if _alt==1: if self._parseListeners is not None: self.triggerExitRuleEvent() _prevctx = localctx - self.state = 734 + self.state = 726 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,90,self._ctx) + la_ = self._interp.adaptivePredict(self._input,89,self._ctx) if la_ == 1: localctx = HogQLParser.ColumnExprPrecedence1Context(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) localctx.left = _prevctx self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 655 + self.state = 647 if not self.precpred(self._ctx, 16): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 16)") - self.state = 659 + self.state = 651 self._errHandler.sync(self) token = self._input.LA(1) if token in [201]: - self.state = 656 + self.state = 648 localctx.operator = self.match(HogQLParser.ASTERISK) pass elif token in [230]: - self.state = 657 + self.state = 649 localctx.operator = self.match(HogQLParser.SLASH) pass elif token in [221]: - self.state = 658 + self.state = 650 localctx.operator = self.match(HogQLParser.PERCENT) pass else: raise NoViableAltException(self) - self.state = 661 + self.state = 653 localctx.right = self.columnExpr(17) pass @@ -5358,29 +5300,29 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprPrecedence2Context(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) localctx.left = _prevctx self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 662 + self.state = 654 if not self.precpred(self._ctx, 15): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 15)") - self.state = 666 + self.state = 658 self._errHandler.sync(self) token = self._input.LA(1) if token in [222]: - self.state = 663 + self.state = 655 localctx.operator = self.match(HogQLParser.PLUS) pass elif token in [207]: - self.state = 664 + self.state = 656 localctx.operator = self.match(HogQLParser.DASH) pass elif token in [206]: - self.state = 665 + self.state = 657 localctx.operator = self.match(HogQLParser.CONCAT) pass else: raise NoViableAltException(self) - self.state = 668 + self.state = 660 localctx.right = self.columnExpr(16) pass @@ -5388,79 +5330,79 @@ def columnExpr(self, _p:int=0): localctx = HogQLParser.ColumnExprPrecedence3Context(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) localctx.left = _prevctx self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 669 + self.state = 661 if not self.precpred(self._ctx, 14): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 14)") - self.state = 688 + self.state = 680 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,86,self._ctx) + la_ = self._interp.adaptivePredict(self._input,85,self._ctx) if la_ == 1: - self.state = 670 + self.state = 662 localctx.operator = self.match(HogQLParser.EQ_DOUBLE) pass elif la_ == 2: - self.state = 671 + self.state = 663 localctx.operator = self.match(HogQLParser.EQ_SINGLE) pass elif la_ == 3: - self.state = 672 + self.state = 664 localctx.operator = self.match(HogQLParser.NOT_EQ) pass elif la_ == 4: - self.state = 673 + self.state = 665 localctx.operator = self.match(HogQLParser.LE) pass elif la_ == 5: - self.state = 674 + self.state = 666 localctx.operator = self.match(HogQLParser.GE) pass elif la_ == 6: - self.state = 675 + self.state = 667 localctx.operator = self.match(HogQLParser.LT) pass elif la_ == 7: - self.state = 676 + self.state = 668 localctx.operator = self.match(HogQLParser.GT) pass elif la_ == 8: - self.state = 678 + self.state = 670 self._errHandler.sync(self) _la = self._input.LA(1) if _la==70: - self.state = 677 + self.state = 669 localctx.operator = self.match(HogQLParser.GLOBAL) - self.state = 681 + self.state = 673 self._errHandler.sync(self) _la = self._input.LA(1) if _la==114: - self.state = 680 + self.state = 672 self.match(HogQLParser.NOT) - self.state = 683 + self.state = 675 self.match(HogQLParser.IN) pass elif la_ == 9: - self.state = 685 + self.state = 677 self._errHandler.sync(self) _la = self._input.LA(1) if _la==114: - self.state = 684 + self.state = 676 localctx.operator = self.match(HogQLParser.NOT) - self.state = 687 + self.state = 679 _la = self._input.LA(1) if not(_la==78 or _la==97): self._errHandler.recoverInline(self) @@ -5470,153 +5412,153 @@ def columnExpr(self, _p:int=0): pass - self.state = 690 + self.state = 682 localctx.right = self.columnExpr(15) pass elif la_ == 4: localctx = HogQLParser.ColumnExprAndContext(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 691 + self.state = 683 if not self.precpred(self._ctx, 11): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 11)") - self.state = 692 + self.state = 684 self.match(HogQLParser.AND) - self.state = 693 + self.state = 685 self.columnExpr(12) pass elif la_ == 5: localctx = HogQLParser.ColumnExprOrContext(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 694 + self.state = 686 if not self.precpred(self._ctx, 10): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 10)") - self.state = 695 + self.state = 687 self.match(HogQLParser.OR) - self.state = 696 + self.state = 688 self.columnExpr(11) pass elif la_ == 6: localctx = HogQLParser.ColumnExprBetweenContext(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 697 + self.state = 689 if not self.precpred(self._ctx, 9): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 9)") - self.state = 699 + self.state = 691 self._errHandler.sync(self) _la = self._input.LA(1) if _la==114: - self.state = 698 + self.state = 690 self.match(HogQLParser.NOT) - self.state = 701 + self.state = 693 self.match(HogQLParser.BETWEEN) - self.state = 702 + self.state = 694 self.columnExpr(0) - self.state = 703 + self.state = 695 self.match(HogQLParser.AND) - self.state = 704 + self.state = 696 self.columnExpr(10) pass elif la_ == 7: localctx = HogQLParser.ColumnExprTernaryOpContext(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 706 + self.state = 698 if not self.precpred(self._ctx, 8): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 8)") - self.state = 707 + self.state = 699 self.match(HogQLParser.QUERY) - self.state = 708 + self.state = 700 self.columnExpr(0) - self.state = 709 + self.state = 701 self.match(HogQLParser.COLON) - self.state = 710 + self.state = 702 self.columnExpr(8) pass elif la_ == 8: localctx = HogQLParser.ColumnExprArrayAccessContext(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 712 + self.state = 704 if not self.precpred(self._ctx, 19): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 19)") - self.state = 713 + self.state = 705 self.match(HogQLParser.LBRACKET) - self.state = 714 + self.state = 706 self.columnExpr(0) - self.state = 715 + self.state = 707 self.match(HogQLParser.RBRACKET) pass elif la_ == 9: localctx = HogQLParser.ColumnExprTupleAccessContext(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 717 + self.state = 709 if not self.precpred(self._ctx, 18): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 18)") - self.state = 718 + self.state = 710 self.match(HogQLParser.DOT) - self.state = 719 + self.state = 711 self.match(HogQLParser.DECIMAL_LITERAL) pass elif la_ == 10: localctx = HogQLParser.ColumnExprIsNullContext(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 720 + self.state = 712 if not self.precpred(self._ctx, 13): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 13)") - self.state = 721 + self.state = 713 self.match(HogQLParser.IS) - self.state = 723 + self.state = 715 self._errHandler.sync(self) _la = self._input.LA(1) if _la==114: - self.state = 722 + self.state = 714 self.match(HogQLParser.NOT) - self.state = 725 + self.state = 717 self.match(HogQLParser.NULL_SQL) pass elif la_ == 11: localctx = HogQLParser.ColumnExprAliasContext(self, HogQLParser.ColumnExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_columnExpr) - self.state = 726 + self.state = 718 if not self.precpred(self._ctx, 7): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 7)") - self.state = 732 + self.state = 724 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,89,self._ctx) + la_ = self._interp.adaptivePredict(self._input,88,self._ctx) if la_ == 1: - self.state = 727 + self.state = 719 self.alias() pass elif la_ == 2: - self.state = 728 + self.state = 720 self.match(HogQLParser.AS) - self.state = 729 + self.state = 721 self.identifier() pass elif la_ == 3: - self.state = 730 + self.state = 722 self.match(HogQLParser.AS) - self.state = 731 + self.state = 723 self.match(HogQLParser.STRING_LITERAL) pass @@ -5624,9 +5566,9 @@ def columnExpr(self, _p:int=0): pass - self.state = 738 + self.state = 730 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,91,self._ctx) + _alt = self._interp.adaptivePredict(self._input,90,self._ctx) except RecognitionException as re: localctx.exception = re @@ -5672,21 +5614,21 @@ def accept(self, visitor:ParseTreeVisitor): def columnArgList(self): localctx = HogQLParser.ColumnArgListContext(self, self._ctx, self.state) - self.enterRule(localctx, 80, self.RULE_columnArgList) + self.enterRule(localctx, 78, self.RULE_columnArgList) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 739 + self.state = 731 self.columnArgExpr() - self.state = 744 + self.state = 736 self._errHandler.sync(self) _la = self._input.LA(1) while _la==205: - self.state = 740 + self.state = 732 self.match(HogQLParser.COMMA) - self.state = 741 + self.state = 733 self.columnArgExpr() - self.state = 746 + self.state = 738 self._errHandler.sync(self) _la = self._input.LA(1) @@ -5729,20 +5671,20 @@ def accept(self, visitor:ParseTreeVisitor): def columnArgExpr(self): localctx = HogQLParser.ColumnArgExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 82, self.RULE_columnArgExpr) + self.enterRule(localctx, 80, self.RULE_columnArgExpr) try: - self.state = 749 + self.state = 741 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,93,self._ctx) + la_ = self._interp.adaptivePredict(self._input,92,self._ctx) if la_ == 1: self.enterOuterAlt(localctx, 1) - self.state = 747 + self.state = 739 self.columnLambdaExpr() pass elif la_ == 2: self.enterOuterAlt(localctx, 2) - self.state = 748 + self.state = 740 self.columnExpr(0) pass @@ -5804,45 +5746,45 @@ def accept(self, visitor:ParseTreeVisitor): def columnLambdaExpr(self): localctx = HogQLParser.ColumnLambdaExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 84, self.RULE_columnLambdaExpr) + self.enterRule(localctx, 82, self.RULE_columnLambdaExpr) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 770 + self.state = 762 self._errHandler.sync(self) token = self._input.LA(1) if token in [218]: - self.state = 751 + self.state = 743 self.match(HogQLParser.LPAREN) - self.state = 752 + self.state = 744 self.identifier() - self.state = 757 + self.state = 749 self._errHandler.sync(self) _la = self._input.LA(1) while _la==205: - self.state = 753 + self.state = 745 self.match(HogQLParser.COMMA) - self.state = 754 + self.state = 746 self.identifier() - self.state = 759 + self.state = 751 self._errHandler.sync(self) _la = self._input.LA(1) - self.state = 760 + self.state = 752 self.match(HogQLParser.RPAREN) pass elif token in [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 113, 114, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 193]: - self.state = 762 + self.state = 754 self.identifier() - self.state = 767 + self.state = 759 self._errHandler.sync(self) _la = self._input.LA(1) while _la==205: - self.state = 763 + self.state = 755 self.match(HogQLParser.COMMA) - self.state = 764 + self.state = 756 self.identifier() - self.state = 769 + self.state = 761 self._errHandler.sync(self) _la = self._input.LA(1) @@ -5850,9 +5792,9 @@ def columnLambdaExpr(self): else: raise NoViableAltException(self) - self.state = 772 + self.state = 764 self.match(HogQLParser.ARROW) - self.state = 773 + self.state = 765 self.columnExpr(0) except RecognitionException as re: localctx.exception = re @@ -5899,29 +5841,29 @@ def accept(self, visitor:ParseTreeVisitor): def columnIdentifier(self): localctx = HogQLParser.ColumnIdentifierContext(self, self._ctx, self.state) - self.enterRule(localctx, 86, self.RULE_columnIdentifier) + self.enterRule(localctx, 84, self.RULE_columnIdentifier) try: - self.state = 782 + self.state = 774 self._errHandler.sync(self) token = self._input.LA(1) if token in [199]: self.enterOuterAlt(localctx, 1) - self.state = 775 + self.state = 767 self.match(HogQLParser.PLACEHOLDER) pass elif token in [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 113, 114, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 193]: self.enterOuterAlt(localctx, 2) - self.state = 779 + self.state = 771 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,97,self._ctx) + la_ = self._interp.adaptivePredict(self._input,96,self._ctx) if la_ == 1: - self.state = 776 + self.state = 768 self.tableIdentifier() - self.state = 777 + self.state = 769 self.match(HogQLParser.DOT) - self.state = 781 + self.state = 773 self.nestedIdentifier() pass else: @@ -5971,23 +5913,23 @@ def accept(self, visitor:ParseTreeVisitor): def nestedIdentifier(self): localctx = HogQLParser.NestedIdentifierContext(self, self._ctx, self.state) - self.enterRule(localctx, 88, self.RULE_nestedIdentifier) + self.enterRule(localctx, 86, self.RULE_nestedIdentifier) try: self.enterOuterAlt(localctx, 1) - self.state = 784 + self.state = 776 self.identifier() - self.state = 789 + self.state = 781 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,99,self._ctx) + _alt = self._interp.adaptivePredict(self._input,98,self._ctx) while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: if _alt==1: - self.state = 785 + self.state = 777 self.match(HogQLParser.DOT) - self.state = 786 + self.state = 778 self.identifier() - self.state = 791 + self.state = 783 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,99,self._ctx) + _alt = self._interp.adaptivePredict(self._input,98,self._ctx) except RecognitionException as re: localctx.exception = re @@ -6100,19 +6042,19 @@ def tableExpr(self, _p:int=0): _parentState = self.state localctx = HogQLParser.TableExprContext(self, self._ctx, _parentState) _prevctx = localctx - _startState = 90 - self.enterRecursionRule(localctx, 90, self.RULE_tableExpr, _p) + _startState = 88 + self.enterRecursionRule(localctx, 88, self.RULE_tableExpr, _p) try: self.enterOuterAlt(localctx, 1) - self.state = 799 + self.state = 791 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,100,self._ctx) + la_ = self._interp.adaptivePredict(self._input,99,self._ctx) if la_ == 1: localctx = HogQLParser.TableExprIdentifierContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 793 + self.state = 785 self.tableIdentifier() pass @@ -6120,7 +6062,7 @@ def tableExpr(self, _p:int=0): localctx = HogQLParser.TableExprFunctionContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 794 + self.state = 786 self.tableFunctionExpr() pass @@ -6128,19 +6070,19 @@ def tableExpr(self, _p:int=0): localctx = HogQLParser.TableExprSubqueryContext(self, localctx) self._ctx = localctx _prevctx = localctx - self.state = 795 + self.state = 787 self.match(HogQLParser.LPAREN) - self.state = 796 + self.state = 788 self.selectUnionStmt() - self.state = 797 + self.state = 789 self.match(HogQLParser.RPAREN) pass self._ctx.stop = self._input.LT(-1) - self.state = 809 + self.state = 801 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,102,self._ctx) + _alt = self._interp.adaptivePredict(self._input,101,self._ctx) while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: if _alt==1: if self._parseListeners is not None: @@ -6148,29 +6090,29 @@ def tableExpr(self, _p:int=0): _prevctx = localctx localctx = HogQLParser.TableExprAliasContext(self, HogQLParser.TableExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_tableExpr) - self.state = 801 + self.state = 793 if not self.precpred(self._ctx, 1): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 1)") - self.state = 805 + self.state = 797 self._errHandler.sync(self) token = self._input.LA(1) if token in [35, 61, 76, 90, 193]: - self.state = 802 + self.state = 794 self.alias() pass elif token in [10]: - self.state = 803 + self.state = 795 self.match(HogQLParser.AS) - self.state = 804 + self.state = 796 self.identifier() pass else: raise NoViableAltException(self) - self.state = 811 + self.state = 803 self._errHandler.sync(self) - _alt = self._interp.adaptivePredict(self._input,102,self._ctx) + _alt = self._interp.adaptivePredict(self._input,101,self._ctx) except RecognitionException as re: localctx.exception = re @@ -6217,23 +6159,23 @@ def accept(self, visitor:ParseTreeVisitor): def tableFunctionExpr(self): localctx = HogQLParser.TableFunctionExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 92, self.RULE_tableFunctionExpr) + self.enterRule(localctx, 90, self.RULE_tableFunctionExpr) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 812 + self.state = 804 self.identifier() - self.state = 813 + self.state = 805 self.match(HogQLParser.LPAREN) - self.state = 815 + self.state = 807 self._errHandler.sync(self) _la = self._input.LA(1) if ((_la) & ~0x3f) == 0 and ((1 << _la) & -4) != 0 or (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -1) != 0 or (((_la - 128)) & ~0x3f) == 0 and ((1 << (_la - 128)) & -5) != 0 or (((_la - 193)) & ~0x3f) == 0 and ((1 << (_la - 193)) & 536952895) != 0: - self.state = 814 + self.state = 806 self.tableArgList() - self.state = 817 + self.state = 809 self.match(HogQLParser.RPAREN) except RecognitionException as re: localctx.exception = re @@ -6277,20 +6219,20 @@ def accept(self, visitor:ParseTreeVisitor): def tableIdentifier(self): localctx = HogQLParser.TableIdentifierContext(self, self._ctx, self.state) - self.enterRule(localctx, 94, self.RULE_tableIdentifier) + self.enterRule(localctx, 92, self.RULE_tableIdentifier) try: self.enterOuterAlt(localctx, 1) - self.state = 822 + self.state = 814 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,104,self._ctx) + la_ = self._interp.adaptivePredict(self._input,103,self._ctx) if la_ == 1: - self.state = 819 + self.state = 811 self.databaseIdentifier() - self.state = 820 + self.state = 812 self.match(HogQLParser.DOT) - self.state = 824 + self.state = 816 self.identifier() except RecognitionException as re: localctx.exception = re @@ -6336,21 +6278,21 @@ def accept(self, visitor:ParseTreeVisitor): def tableArgList(self): localctx = HogQLParser.TableArgListContext(self, self._ctx, self.state) - self.enterRule(localctx, 96, self.RULE_tableArgList) + self.enterRule(localctx, 94, self.RULE_tableArgList) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 826 + self.state = 818 self.tableArgExpr() - self.state = 831 + self.state = 823 self._errHandler.sync(self) _la = self._input.LA(1) while _la==205: - self.state = 827 + self.state = 819 self.match(HogQLParser.COMMA) - self.state = 828 + self.state = 820 self.tableArgExpr() - self.state = 833 + self.state = 825 self._errHandler.sync(self) _la = self._input.LA(1) @@ -6397,26 +6339,26 @@ def accept(self, visitor:ParseTreeVisitor): def tableArgExpr(self): localctx = HogQLParser.TableArgExprContext(self, self._ctx, self.state) - self.enterRule(localctx, 98, self.RULE_tableArgExpr) + self.enterRule(localctx, 96, self.RULE_tableArgExpr) try: - self.state = 837 + self.state = 829 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,106,self._ctx) + la_ = self._interp.adaptivePredict(self._input,105,self._ctx) if la_ == 1: self.enterOuterAlt(localctx, 1) - self.state = 834 + self.state = 826 self.nestedIdentifier() pass elif la_ == 2: self.enterOuterAlt(localctx, 2) - self.state = 835 + self.state = 827 self.tableFunctionExpr() pass elif la_ == 3: self.enterOuterAlt(localctx, 3) - self.state = 836 + self.state = 828 self.literal() pass @@ -6456,10 +6398,10 @@ def accept(self, visitor:ParseTreeVisitor): def databaseIdentifier(self): localctx = HogQLParser.DatabaseIdentifierContext(self, self._ctx, self.state) - self.enterRule(localctx, 100, self.RULE_databaseIdentifier) + self.enterRule(localctx, 98, self.RULE_databaseIdentifier) try: self.enterOuterAlt(localctx, 1) - self.state = 839 + self.state = 831 self.identifier() except RecognitionException as re: localctx.exception = re @@ -6507,22 +6449,22 @@ def accept(self, visitor:ParseTreeVisitor): def floatingLiteral(self): localctx = HogQLParser.FloatingLiteralContext(self, self._ctx, self.state) - self.enterRule(localctx, 102, self.RULE_floatingLiteral) + self.enterRule(localctx, 100, self.RULE_floatingLiteral) self._la = 0 # Token type try: - self.state = 849 + self.state = 841 self._errHandler.sync(self) token = self._input.LA(1) if token in [194]: self.enterOuterAlt(localctx, 1) - self.state = 841 + self.state = 833 self.match(HogQLParser.FLOATING_LITERAL) pass elif token in [209]: self.enterOuterAlt(localctx, 2) - self.state = 842 + self.state = 834 self.match(HogQLParser.DOT) - self.state = 843 + self.state = 835 _la = self._input.LA(1) if not(_la==195 or _la==196): self._errHandler.recoverInline(self) @@ -6532,15 +6474,15 @@ def floatingLiteral(self): pass elif token in [196]: self.enterOuterAlt(localctx, 3) - self.state = 844 + self.state = 836 self.match(HogQLParser.DECIMAL_LITERAL) - self.state = 845 + self.state = 837 self.match(HogQLParser.DOT) - self.state = 847 + self.state = 839 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,107,self._ctx) + la_ = self._interp.adaptivePredict(self._input,106,self._ctx) if la_ == 1: - self.state = 846 + self.state = 838 _la = self._input.LA(1) if not(_la==195 or _la==196): self._errHandler.recoverInline(self) @@ -6609,15 +6551,15 @@ def accept(self, visitor:ParseTreeVisitor): def numberLiteral(self): localctx = HogQLParser.NumberLiteralContext(self, self._ctx, self.state) - self.enterRule(localctx, 104, self.RULE_numberLiteral) + self.enterRule(localctx, 102, self.RULE_numberLiteral) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 852 + self.state = 844 self._errHandler.sync(self) _la = self._input.LA(1) if _la==207 or _la==222: - self.state = 851 + self.state = 843 _la = self._input.LA(1) if not(_la==207 or _la==222): self._errHandler.recoverInline(self) @@ -6626,36 +6568,36 @@ def numberLiteral(self): self.consume() - self.state = 860 + self.state = 852 self._errHandler.sync(self) - la_ = self._interp.adaptivePredict(self._input,110,self._ctx) + la_ = self._interp.adaptivePredict(self._input,109,self._ctx) if la_ == 1: - self.state = 854 + self.state = 846 self.floatingLiteral() pass elif la_ == 2: - self.state = 855 + self.state = 847 self.match(HogQLParser.OCTAL_LITERAL) pass elif la_ == 3: - self.state = 856 + self.state = 848 self.match(HogQLParser.DECIMAL_LITERAL) pass elif la_ == 4: - self.state = 857 + self.state = 849 self.match(HogQLParser.HEXADECIMAL_LITERAL) pass elif la_ == 5: - self.state = 858 + self.state = 850 self.match(HogQLParser.INF) pass elif la_ == 6: - self.state = 859 + self.state = 851 self.match(HogQLParser.NAN_SQL) pass @@ -6701,24 +6643,24 @@ def accept(self, visitor:ParseTreeVisitor): def literal(self): localctx = HogQLParser.LiteralContext(self, self._ctx, self.state) - self.enterRule(localctx, 106, self.RULE_literal) + self.enterRule(localctx, 104, self.RULE_literal) try: - self.state = 865 + self.state = 857 self._errHandler.sync(self) token = self._input.LA(1) if token in [81, 112, 194, 195, 196, 197, 207, 209, 222]: self.enterOuterAlt(localctx, 1) - self.state = 862 + self.state = 854 self.numberLiteral() pass elif token in [198]: self.enterOuterAlt(localctx, 2) - self.state = 863 + self.state = 855 self.match(HogQLParser.STRING_LITERAL) pass elif token in [115]: self.enterOuterAlt(localctx, 3) - self.state = 864 + self.state = 856 self.match(HogQLParser.NULL_SQL) pass else: @@ -6779,11 +6721,11 @@ def accept(self, visitor:ParseTreeVisitor): def interval(self): localctx = HogQLParser.IntervalContext(self, self._ctx, self.state) - self.enterRule(localctx, 108, self.RULE_interval) + self.enterRule(localctx, 106, self.RULE_interval) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 867 + self.state = 859 _la = self._input.LA(1) if not(_la==36 or (((_la - 75)) & ~0x3f) == 0 and ((1 << (_la - 75)) & 72057615512764417) != 0 or (((_la - 144)) & ~0x3f) == 0 and ((1 << (_la - 144)) & 36283883716609) != 0): self._errHandler.recoverInline(self) @@ -7355,11 +7297,11 @@ def accept(self, visitor:ParseTreeVisitor): def keyword(self): localctx = HogQLParser.KeywordContext(self, self._ctx, self.state) - self.enterRule(localctx, 110, self.RULE_keyword) + self.enterRule(localctx, 108, self.RULE_keyword) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 869 + self.state = 861 _la = self._input.LA(1) if not(((_la) & ~0x3f) == 0 and ((1 << _la) & -68719476740) != 0 or (((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & -2577255255640065) != 0 or (((_la - 128)) & ~0x3f) == 0 and ((1 << (_la - 128)) & -2377900603251687437) != 0): self._errHandler.recoverInline(self) @@ -7409,11 +7351,11 @@ def accept(self, visitor:ParseTreeVisitor): def keywordForAlias(self): localctx = HogQLParser.KeywordForAliasContext(self, self._ctx, self.state) - self.enterRule(localctx, 112, self.RULE_keywordForAlias) + self.enterRule(localctx, 110, self.RULE_keywordForAlias) self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 871 + self.state = 863 _la = self._input.LA(1) if not((((_la - 35)) & ~0x3f) == 0 and ((1 << (_la - 35)) & 36030996109328385) != 0): self._errHandler.recoverInline(self) @@ -7458,19 +7400,19 @@ def accept(self, visitor:ParseTreeVisitor): def alias(self): localctx = HogQLParser.AliasContext(self, self._ctx, self.state) - self.enterRule(localctx, 114, self.RULE_alias) + self.enterRule(localctx, 112, self.RULE_alias) try: - self.state = 875 + self.state = 867 self._errHandler.sync(self) token = self._input.LA(1) if token in [193]: self.enterOuterAlt(localctx, 1) - self.state = 873 + self.state = 865 self.match(HogQLParser.IDENTIFIER) pass elif token in [35, 61, 76, 90]: self.enterOuterAlt(localctx, 2) - self.state = 874 + self.state = 866 self.keywordForAlias() pass else: @@ -7518,24 +7460,24 @@ def accept(self, visitor:ParseTreeVisitor): def identifier(self): localctx = HogQLParser.IdentifierContext(self, self._ctx, self.state) - self.enterRule(localctx, 116, self.RULE_identifier) + self.enterRule(localctx, 114, self.RULE_identifier) try: - self.state = 880 + self.state = 872 self._errHandler.sync(self) token = self._input.LA(1) if token in [193]: self.enterOuterAlt(localctx, 1) - self.state = 877 + self.state = 869 self.match(HogQLParser.IDENTIFIER) pass elif token in [36, 75, 107, 109, 131, 144, 184, 189]: self.enterOuterAlt(localctx, 2) - self.state = 878 + self.state = 870 self.interval() pass elif token in [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 108, 110, 111, 113, 114, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 185, 186, 187, 188, 190, 191]: self.enterOuterAlt(localctx, 3) - self.state = 879 + self.state = 871 self.keyword() pass else: @@ -7579,19 +7521,19 @@ def accept(self, visitor:ParseTreeVisitor): def identifierOrNull(self): localctx = HogQLParser.IdentifierOrNullContext(self, self._ctx, self.state) - self.enterRule(localctx, 118, self.RULE_identifierOrNull) + self.enterRule(localctx, 116, self.RULE_identifierOrNull) try: - self.state = 884 + self.state = 876 self._errHandler.sync(self) token = self._input.LA(1) if token in [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 113, 114, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 193]: self.enterOuterAlt(localctx, 1) - self.state = 882 + self.state = 874 self.identifier() pass elif token in [115]: self.enterOuterAlt(localctx, 2) - self.state = 883 + self.state = 875 self.match(HogQLParser.NULL_SQL) pass else: @@ -7638,14 +7580,14 @@ def accept(self, visitor:ParseTreeVisitor): def enumValue(self): localctx = HogQLParser.EnumValueContext(self, self._ctx, self.state) - self.enterRule(localctx, 120, self.RULE_enumValue) + self.enterRule(localctx, 118, self.RULE_enumValue) try: self.enterOuterAlt(localctx, 1) - self.state = 886 + self.state = 878 self.match(HogQLParser.STRING_LITERAL) - self.state = 887 + self.state = 879 self.match(HogQLParser.EQ_SINGLE) - self.state = 888 + self.state = 880 self.numberLiteral() except RecognitionException as re: localctx.exception = re @@ -7660,9 +7602,9 @@ def enumValue(self): def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int): if self._predicates == None: self._predicates = dict() - self._predicates[18] = self.joinExpr_sempred - self._predicates[39] = self.columnExpr_sempred - self._predicates[45] = self.tableExpr_sempred + self._predicates[17] = self.joinExpr_sempred + self._predicates[38] = self.columnExpr_sempred + self._predicates[44] = self.tableExpr_sempred pred = self._predicates.get(ruleIndex, None) if pred is None: raise Exception("No predicate with index:" + str(ruleIndex)) diff --git a/posthog/hogql/grammar/HogQLParserVisitor.py b/posthog/hogql/grammar/HogQLParserVisitor.py index dbaf69ef6fda9..b5bc53c977fc1 100644 --- a/posthog/hogql/grammar/HogQLParserVisitor.py +++ b/posthog/hogql/grammar/HogQLParserVisitor.py @@ -84,11 +84,6 @@ def visitProjectionOrderByClause(self, ctx:HogQLParser.ProjectionOrderByClauseCo return self.visitChildren(ctx) - # Visit a parse tree produced by HogQLParser#limitByClause. - def visitLimitByClause(self, ctx:HogQLParser.LimitByClauseContext): - return self.visitChildren(ctx) - - # Visit a parse tree produced by HogQLParser#limitClause. def visitLimitClause(self, ctx:HogQLParser.LimitClauseContext): return self.visitChildren(ctx) diff --git a/posthog/hogql/parser.py b/posthog/hogql/parser.py index f393769960196..a8347a36a0035 100644 --- a/posthog/hogql/parser.py +++ b/posthog/hogql/parser.py @@ -66,17 +66,17 @@ def visitSelectStmt(self, ctx: HogQLParser.SelectStmtContext): order_by=self.visit(ctx.orderByClause()) if ctx.orderByClause() else None, ) - any_limit_clause = ctx.limitClause() or ctx.limitByClause() - if any_limit_clause and any_limit_clause.limitExpr(): - limit_expr = any_limit_clause.limitExpr() + if ctx.limitClause(): + limit_clause = ctx.limitClause() + limit_expr = limit_clause.limitExpr() if limit_expr.columnExpr(0): select_query.limit = self.visit(limit_expr.columnExpr(0)) if limit_expr.columnExpr(1): select_query.offset = self.visit(limit_expr.columnExpr(1)) - if ctx.limitClause() and ctx.limitClause().WITH() and ctx.limitClause().TIES(): - select_query.limit_with_ties = True - if ctx.limitByClause() and ctx.limitByClause().columnExprList(): - select_query.limit_by = self.visit(ctx.limitByClause().columnExprList()) + if limit_clause.columnExprList(): + select_query.limit_by = self.visit(limit_clause.columnExprList()) + if limit_clause.WITH() and limit_clause.TIES(): + select_query.limit_with_ties = True if ctx.withClause(): raise NotImplementedError(f"Unsupported: SelectStmt.withClause()") @@ -124,9 +124,6 @@ def visitOrderByClause(self, ctx: HogQLParser.OrderByClauseContext): def visitProjectionOrderByClause(self, ctx: HogQLParser.ProjectionOrderByClauseContext): raise NotImplementedError(f"Unsupported node: ProjectionOrderByClause") - def visitLimitByClause(self, ctx: HogQLParser.LimitByClauseContext): - raise Exception(f"Parsed as part of SelectStmt, can't parse directly.") - def visitLimitClause(self, ctx: HogQLParser.LimitClauseContext): raise Exception(f"Parsed as part of SelectStmt, can't parse directly.") diff --git a/posthog/hogql/printer.py b/posthog/hogql/printer.py index e2ebe83dc4d23..65eb95b928eba 100644 --- a/posthog/hogql/printer.py +++ b/posthog/hogql/printer.py @@ -88,7 +88,7 @@ def print_ast( f"ORDER BY {', '.join(order_by)}" if order_by and len(order_by) > 0 else None, ] if limit is not None: - clauses.append(f"LIMIT {print_ast(limit, stack, context, dialect)}"), + clauses.append(f"LIMIT {print_ast(limit, stack, context, dialect)}") if node.offset is not None: clauses.append(f"OFFSET {print_ast(node.offset, stack, context, dialect)}") if node.limit_by is not None: From 9cd96bccedc8ae501140385b8233ea5fabd6ac51 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 8 Feb 2023 15:27:10 +0000 Subject: [PATCH 7/7] Update snapshots --- .../queries/trends/test/__snapshots__/test_formula.ambr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/posthog/queries/trends/test/__snapshots__/test_formula.ambr b/posthog/queries/trends/test/__snapshots__/test_formula.ambr index 3ce2fa339fefa..6828f1b8f59cd 100644 --- a/posthog/queries/trends/test/__snapshots__/test_formula.ambr +++ b/posthog/queries/trends/test/__snapshots__/test_formula.ambr @@ -153,7 +153,7 @@ CROSS JOIN (SELECT breakdown_value FROM - (SELECT [36, 0] as breakdown_value) ARRAY + (SELECT [37, 0] as breakdown_value) ARRAY JOIN breakdown_value) as sec ORDER BY breakdown_value, day_start @@ -163,7 +163,7 @@ FROM events e INNER JOIN (SELECT distinct_id, - 36 as value + 37 as value FROM (SELECT distinct_id, argMax(person_id, version) as person_id @@ -222,7 +222,7 @@ CROSS JOIN (SELECT breakdown_value FROM - (SELECT [36, 0] as breakdown_value) ARRAY + (SELECT [37, 0] as breakdown_value) ARRAY JOIN breakdown_value) as sec ORDER BY breakdown_value, day_start @@ -232,7 +232,7 @@ FROM events e INNER JOIN (SELECT distinct_id, - 36 as value + 37 as value FROM (SELECT distinct_id, argMax(person_id, version) as person_id