UNPKG

flink-sql-language-server

Version:

A LSP-based language server for Apache Flink SQL

1,192 lines 1.34 MB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.PivotContext = exports.OptionNameContext = exports.OptionValueContext = exports.HintKVOptionContext = exports.HintOptionsContext = exports.HintContext = exports.HintsContext = exports.TableQueryContext = exports.TableLateralContext = exports.TableSourceContext = exports.TablePrimaryContext = exports.TableDimContext = exports.TableReferenceContext = exports.CommaTableContext = exports.JoinConditionContext = exports.MapTableContext = exports.TableExprContext = exports.TableExpressionContext = exports.SetQuantifierContext = exports.ProjectItemContext = exports.WindowSelectContext = exports.HavingContext = exports.GroupItemsContext = exports.GroupByContext = exports.WhereContext = exports.FromTableContext = exports.ProjectItemsContext = exports.SelectContext = exports.SelectClauseContext = exports.OrderItemContext = exports.WithItemContext = exports.QueryFetchContext = exports.QueryOffsetContext = exports.QueryLimitContext = exports.QueryOrderByContext = exports.MapQueryContext = exports.CtesContext = exports.QueryPrimaryContext = exports.QueryTermContext = exports.QueryContext = exports.AnalyzeContext = exports.AutoOptimizeDatabaseContext = exports.AutoOptimizeTableContext = exports.AutoOptimizeContext = exports.EndContext = exports.StatementEndContext = exports.StatementContext = exports.StatementsContext = exports.ProgramContext = exports.FlinkSQLParser = void 0; exports.ShowModelsContext = exports.ShowContext = exports.UseContext = exports.BeginStatementSetContext = exports.ExecuteStatementSetContext = exports.InsertMultipleContext = exports.PartitionContext = exports.InsertContext = exports.DescribeModelContext = exports.DescribeTableContext = exports.DescribeDatabaseContext = exports.DescribeCatalogContext = exports.DescribeContext = exports.ExplainDetailContext = exports.ExplainDetailsContext = exports.ExplainContext = exports.SetValuesContext = exports.RenameToContext = exports.AlterModelContext = exports.AlterMaterializedTableContext = exports.AlterFunctionContext = exports.AlterDatabaseContext = exports.AlterViewContext = exports.AlterTableContext = exports.AlterContext = exports.ResetStatementContext = exports.SetStatementContext = exports.RangeOrRowsContext = exports.WindowSpecContext = exports.WindowContext = exports.ParenthesisGroupItemsContext = exports.GroupingSetsContext = exports.GroupItemContext = exports.ValueRowContext = exports.ValuesRowsParenthesisContext = exports.ValuesRowsContext = exports.ValuesContext = exports.UnpivotValueContext = exports.UnpivotAxisListContext = exports.UnpivotMeasureListContext = exports.UnpivotContext = exports.PivotExprContext = exports.PivotExprsContext = exports.InPivotExprsContext = exports.ExprOrListContext = exports.ColumnOrListContext = exports.PivotListContext = exports.PivotAggContext = exports.ForPivotListContext = exports.PivotAggsContext = void 0; exports.CharContext = exports.CollectionsTypeNameContext = exports.SqlTypeNameContext = exports.TypeNameContext = exports.TypeContext = exports.ShowModulesContext = exports.UseModulesContext = exports.UnloadModuleContext = exports.LoadModuleContext = exports.ModuleStatementContext = exports.AddJarContext = exports.DropModelContext = exports.DropMaterializedTableContext = exports.DropFunctionContext = exports.DropViewContext = exports.DropDatabaseContext = exports.DropTableContext = exports.DropContext = exports.CreateFunctionContext = exports.CreateViewContext = exports.ExcludingTableContext = exports.IncludingTableContext = exports.AsDatabaseContext = exports.CreateDatabaseContext = exports.CreateCatalogContext = exports.LikeOptionContext = exports.LikeOptionsContext = exports.LikeConfigContext = exports.WatermarkDefinitionContext = exports.TableConstraintContext = exports.ColumnConstraintContext = exports.ColumnDefinitionContext = exports.TableElementContext = exports.RefreshModeContext = exports.FreshnessContext = exports.AsTableContext = exports.LikeTableContext = exports.WithValuesContext = exports.IntoBucketsContext = exports.DistributedByContext = exports.PartitionedByContext = exports.DefineValuesContext = exports.ModelOutputsContext = exports.ModelInputsContext = exports.CreateModelContext = exports.CreateMaterializedTableContext = exports.CreateTableContext = exports.CreateContext = exports.DdlStatementContext = exports.ShowCreateModelContext = void 0; exports.ValueAssignmentContext = exports.ValueAssignmentsContext = exports.ColumnAssignmentContext = exports.ColumnAssignmentsContext = exports.ParenthesisQueryContext = exports.ParenthesisExpressionsContext = exports.ExpressionsContext = exports.OverWindowContext = exports.AggregateNullsContext = exports.AggregateFilterContext = exports.AggregateWithinContext = exports.TimePointUnitContext = exports.TimeIntervalUnitContext = exports.SecondUnitContext = exports.MinuteUnitContext = exports.HourUnitContext = exports.DayUnitContext = exports.MonthUnitContext = exports.YearUnitContext = exports.DayTimeIntervalContext = exports.YearMonthIntervalContext = exports.TemporalTimestampContext = exports.TemporalTimeContext = exports.TemporalDateContext = exports.TemporalOverlapsContext = exports.TemporalFunctionContext = exports.NullBehaviorContext = exports.JsonValContext = exports.JsonKeyValContext = exports.JsonArrayAggFunctionContext = exports.JsonArrayFunctionContext = exports.JsonObjectAggFunctionContext = exports.JsonObjectFunctionContext = exports.PathContext = exports.JsonValueContext = exports.JsonQueryFunctionContext = exports.JsonValueFunctionContext = exports.JsonStringFunctionContext = exports.JsonExistsFunctionContext = exports.JsonFunctionContext = exports.MlPredictFunctionNamedArgumentContext = exports.MlPredictFunctionArgsContext = exports.MlPredictFunctionContext = exports.MlFunctionContext = exports.SystemFunctionContext = exports.MapContext = exports.RowTypeContext = exports.VarbinaryContext = exports.DecimalContext = exports.VarcharContext = void 0; exports.ValueExprContext = exports.LogicalBinaryContext = exports.PredicatedContext = exports.ExistsContext = exports.LogicalNotContext = exports.BooleanExprContext = exports.ExprContext = exports.PredicateContext = exports.LogicalBindContext = exports.NamedArgumentAssignContext = exports.CompareContext = exports.ArrayConstructContext = exports.CaseEndContext = exports.ElseExprContext = exports.ThenExprContext = exports.WhenExprContext = exports.LiteralValueContext = exports.CharsetLiteralContext = exports.CharsetIntroducerContext = exports.ArrowWindowFunctionContext = exports.AnyNonStringNameContext = exports.AnyNameContext = exports.KeywordContext = exports.AliasesContext = exports.AliasContext = exports.PatternQuantifierContext = exports.PatternPrimaryContext = exports.PatternFactorContext = exports.PatternTermContext = exports.PatternContext = exports.MeasureColumnContext = exports.DefineItemContext = exports.DefineItemsContext = exports.DefineMatchContext = exports.SubsetItemContext = exports.SubsetItemsContext = exports.SubsetMatchContext = exports.WithinMatchContext = exports.PatternMatchContext = exports.AfterMatchContext = exports.PerMatchContext = exports.MeasureColumnsContext = exports.MeasuresContext = exports.MatchRecognizeContext = exports.PartitionByContext = exports.OrderItemsContext = exports.OrderByContext = exports.CommentContext = exports.ColumnsWithoutParenthesisContext = exports.ColumnsContext = void 0; exports.CommonKeywordsContext = exports.NonReservedKeywordsContext = exports.ReservedKeywordsContext = exports.CatalogContext = exports.DatabaseContext = exports.ModelContext = exports.TableContext = exports.ViewContext = exports.DereferenceContext = exports.StarContext = exports.ColumnReferenceContext = exports.ColumnContext = exports.FunctionNameContext = exports.ViewNameContext = exports.CatalogNameContext = exports.DatabaseNameContext = exports.ModelNameContext = exports.TableNameContext = exports.ColumnNameContext = exports.NameContext = exports.StringContext = exports.PrimaryExprContext = exports.FunctionCallContext = exports.SubQueryContext = exports.ComparisonContext = exports.ArithmeticBinaryContext = exports.ArithmeticUnaryContext = exports.ValueExpressionDefaultContext = void 0; const ATN_1 = require("antlr4ts/atn/ATN"); const ATNDeserializer_1 = require("antlr4ts/atn/ATNDeserializer"); const FailedPredicateException_1 = require("antlr4ts/FailedPredicateException"); const NoViableAltException_1 = require("antlr4ts/NoViableAltException"); const Parser_1 = require("antlr4ts/Parser"); const ParserRuleContext_1 = require("antlr4ts/ParserRuleContext"); const ParserATNSimulator_1 = require("antlr4ts/atn/ParserATNSimulator"); const RecognitionException_1 = require("antlr4ts/RecognitionException"); const Token_1 = require("antlr4ts/Token"); const VocabularyImpl_1 = require("antlr4ts/VocabularyImpl"); const Utils = __importStar(require("antlr4ts/misc/Utils")); class FlinkSQLParser extends Parser_1.Parser { constructor(input) { super(input); this._interp = new ParserATNSimulator_1.ParserATNSimulator(FlinkSQLParser._ATN, this); } get vocabulary() { return FlinkSQLParser.VOCABULARY; } get grammarFileName() { return "FlinkSQLParser.g4"; } get ruleNames() { return FlinkSQLParser.ruleNames; } get serializedATN() { return FlinkSQLParser._serializedATN; } createFailedPredicateException(predicate, message) { return new FailedPredicateException_1.FailedPredicateException(this, predicate, message); } program() { let _localctx = new ProgramContext(this._ctx, this.state); this.enterRule(_localctx, 0, FlinkSQLParser.RULE_program); try { this.state = 536; this._errHandler.sync(this); switch (this._input.LA(1)) { case FlinkSQLParser.L_PARENTHESIS: case FlinkSQLParser.ALTER: case FlinkSQLParser.AUTO: case FlinkSQLParser.BEGIN: case FlinkSQLParser.CREATE: case FlinkSQLParser.DESCRIBE: case FlinkSQLParser.DROP: case FlinkSQLParser.END: case FlinkSQLParser.EXECUTE: case FlinkSQLParser.EXPLAIN: case FlinkSQLParser.INSERT: case FlinkSQLParser.RESET: case FlinkSQLParser.SELECT: case FlinkSQLParser.SET: case FlinkSQLParser.SHOW: case FlinkSQLParser.TABLE: case FlinkSQLParser.UPSERT: case FlinkSQLParser.VALUES: case FlinkSQLParser.WITH: case FlinkSQLParser.ADD: case FlinkSQLParser.DESC: case FlinkSQLParser.ANALYZE: case FlinkSQLParser.LOAD: case FlinkSQLParser.UNLOAD: case FlinkSQLParser.USE: this.enterOuterAlt(_localctx, 1); { this.state = 532; this.statements(); this.state = 533; this.match(FlinkSQLParser.EOF); } break; case FlinkSQLParser.EOF: this.enterOuterAlt(_localctx, 2); { this.state = 535; this.match(FlinkSQLParser.EOF); } break; default: throw new NoViableAltException_1.NoViableAltException(this); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } statements() { let _localctx = new StatementsContext(this._ctx, this.state); this.enterRule(_localctx, 2, FlinkSQLParser.RULE_statements); let _la; try { let _alt; this.enterOuterAlt(_localctx, 1); { this.state = 538; this.statement(); this.state = 548; this._errHandler.sync(this); _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); while (_alt !== 2 && _alt !== ATN_1.ATN.INVALID_ALT_NUMBER) { if (_alt === 1) { { { this.state = 540; this._errHandler.sync(this); _la = this._input.LA(1); do { { { this.state = 539; this.statementEnd(); } } this.state = 542; this._errHandler.sync(this); _la = this._input.LA(1); } while (_la === FlinkSQLParser.SEMICOLON); this.state = 544; this.statement(); } } } this.state = 550; this._errHandler.sync(this); _alt = this.interpreter.adaptivePredict(this._input, 2, this._ctx); } this.state = 554; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === FlinkSQLParser.SEMICOLON) { { { this.state = 551; this.statementEnd(); } } this.state = 556; this._errHandler.sync(this); _la = this._input.LA(1); } } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } statement() { let _localctx = new StatementContext(this._ctx, this.state); this.enterRule(_localctx, 4, FlinkSQLParser.RULE_statement); try { this.state = 573; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 4, this._ctx)) { case 1: this.enterOuterAlt(_localctx, 1); { this.state = 557; this.ddlStatement(); } break; case 2: this.enterOuterAlt(_localctx, 2); { this.state = 558; this.insert(); } break; case 3: this.enterOuterAlt(_localctx, 3); { this.state = 559; this.insertMultiple(); } break; case 4: this.enterOuterAlt(_localctx, 4); { this.state = 560; this.query(); } break; case 5: this.enterOuterAlt(_localctx, 5); { this.state = 561; this.alter(); } break; case 6: this.enterOuterAlt(_localctx, 6); { this.state = 562; this.explain(); } break; case 7: this.enterOuterAlt(_localctx, 7); { this.state = 563; this.autoOptimize(); } break; case 8: this.enterOuterAlt(_localctx, 8); { this.state = 564; this.setStatement(); } break; case 9: this.enterOuterAlt(_localctx, 9); { this.state = 565; this.resetStatement(); } break; case 10: this.enterOuterAlt(_localctx, 10); { this.state = 566; this.analyze(); } break; case 11: this.enterOuterAlt(_localctx, 11); { this.state = 567; this.describe(); } break; case 12: this.enterOuterAlt(_localctx, 12); { this.state = 568; this.use(); } break; case 13: this.enterOuterAlt(_localctx, 13); { this.state = 569; this.show(); } break; case 14: this.enterOuterAlt(_localctx, 14); { this.state = 570; this.addJar(); } break; case 15: this.enterOuterAlt(_localctx, 15); { this.state = 571; this.moduleStatement(); } break; case 16: this.enterOuterAlt(_localctx, 16); { this.state = 572; this.end(); } break; } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } statementEnd() { let _localctx = new StatementEndContext(this._ctx, this.state); this.enterRule(_localctx, 6, FlinkSQLParser.RULE_statementEnd); try { this.enterOuterAlt(_localctx, 1); { this.state = 575; this.match(FlinkSQLParser.SEMICOLON); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } end() { let _localctx = new EndContext(this._ctx, this.state); this.enterRule(_localctx, 8, FlinkSQLParser.RULE_end); try { this.enterOuterAlt(_localctx, 1); { this.state = 577; this.match(FlinkSQLParser.END); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } autoOptimize() { let _localctx = new AutoOptimizeContext(this._ctx, this.state); this.enterRule(_localctx, 10, FlinkSQLParser.RULE_autoOptimize); try { this.state = 581; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 5, this._ctx)) { case 1: this.enterOuterAlt(_localctx, 1); { this.state = 579; this.autoOptimizeTable(); } break; case 2: this.enterOuterAlt(_localctx, 2); { this.state = 580; this.autoOptimizeDatabase(); } break; } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } autoOptimizeTable() { let _localctx = new AutoOptimizeTableContext(this._ctx, this.state); this.enterRule(_localctx, 12, FlinkSQLParser.RULE_autoOptimizeTable); try { this.enterOuterAlt(_localctx, 1); { this.state = 583; this.match(FlinkSQLParser.AUTO); this.state = 584; this.match(FlinkSQLParser.OPTIMIZE); this.state = 585; this.match(FlinkSQLParser.TABLE); this.state = 586; this.table(); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } autoOptimizeDatabase() { let _localctx = new AutoOptimizeDatabaseContext(this._ctx, this.state); this.enterRule(_localctx, 14, FlinkSQLParser.RULE_autoOptimizeDatabase); try { this.enterOuterAlt(_localctx, 1); { this.state = 588; this.match(FlinkSQLParser.AUTO); this.state = 589; this.match(FlinkSQLParser.OPTIMIZE); this.state = 590; this.match(FlinkSQLParser.DATABASE); this.state = 591; this.database(); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } analyze() { let _localctx = new AnalyzeContext(this._ctx, this.state); this.enterRule(_localctx, 16, FlinkSQLParser.RULE_analyze); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 593; this.match(FlinkSQLParser.ANALYZE); this.state = 594; this.match(FlinkSQLParser.TABLE); this.state = 595; this.table(); this.state = 597; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.PARTITION) { { this.state = 596; this.partition(); } } this.state = 599; this.match(FlinkSQLParser.COMPUTE); this.state = 600; this.match(FlinkSQLParser.STATISTICS); this.state = 607; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 7, this._ctx)) { case 1: { this.state = 601; this.match(FlinkSQLParser.FOR); this.state = 602; this.match(FlinkSQLParser.COLUMNS); this.state = 603; this.columnsWithoutParenthesis(); } break; case 2: { this.state = 604; this.match(FlinkSQLParser.FOR); this.state = 605; this.match(FlinkSQLParser.ALL); this.state = 606; this.match(FlinkSQLParser.COLUMNS); } break; } } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } query() { let _localctx = new QueryContext(this._ctx, this.state); this.enterRule(_localctx, 18, FlinkSQLParser.RULE_query); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 610; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.WITH) { { this.state = 609; this.ctes(); } } this.state = 612; this.queryTerm(); this.state = 614; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.ORDER) { { this.state = 613; this.queryOrderBy(); } } this.state = 617; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.LIMIT) { { this.state = 616; this.queryLimit(); } } this.state = 620; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.OFFSET) { { this.state = 619; this.queryOffset(); } } this.state = 623; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.FETCH) { { this.state = 622; this.queryFetch(); } } } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } queryTerm() { let _localctx = new QueryTermContext(this._ctx, this.state); this.enterRule(_localctx, 20, FlinkSQLParser.RULE_queryTerm); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 625; this.queryPrimary(); this.state = 627; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.EXCEPT || _la === FlinkSQLParser.INTERSECT || _la === FlinkSQLParser.MINUS || _la === FlinkSQLParser.UNION) { { this.state = 626; this.mapQuery(); } } } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } queryPrimary() { let _localctx = new QueryPrimaryContext(this._ctx, this.state); this.enterRule(_localctx, 22, FlinkSQLParser.RULE_queryPrimary); try { this.state = 634; this._errHandler.sync(this); switch (this._input.LA(1)) { case FlinkSQLParser.SELECT: this.enterOuterAlt(_localctx, 1); { this.state = 629; this.select(); } break; case FlinkSQLParser.TABLE: this.enterOuterAlt(_localctx, 2); { this.state = 630; this.match(FlinkSQLParser.TABLE); this.state = 631; this.table(); } break; case FlinkSQLParser.VALUES: this.enterOuterAlt(_localctx, 3); { this.state = 632; this.values(); } break; case FlinkSQLParser.L_PARENTHESIS: this.enterOuterAlt(_localctx, 4); { this.state = 633; this.parenthesisQuery(); } break; default: throw new NoViableAltException_1.NoViableAltException(this); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } ctes() { let _localctx = new CtesContext(this._ctx, this.state); this.enterRule(_localctx, 24, FlinkSQLParser.RULE_ctes); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 636; this.match(FlinkSQLParser.WITH); this.state = 637; this.withItem(); this.state = 642; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === FlinkSQLParser.COMMA) { { { this.state = 638; this.match(FlinkSQLParser.COMMA); this.state = 639; this.withItem(); } } this.state = 644; this._errHandler.sync(this); _la = this._input.LA(1); } } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } mapQuery() { let _localctx = new MapQueryContext(this._ctx, this.state); this.enterRule(_localctx, 26, FlinkSQLParser.RULE_mapQuery); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 645; _la = this._input.LA(1); if (!(_la === FlinkSQLParser.EXCEPT || _la === FlinkSQLParser.INTERSECT || _la === FlinkSQLParser.MINUS || _la === FlinkSQLParser.UNION)) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token_1.Token.EOF) { this.matchedEOF = true; } this._errHandler.reportMatch(this); this.consume(); } this.state = 647; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.ALL || _la === FlinkSQLParser.DISTINCT) { { this.state = 646; this.setQuantifier(); } } this.state = 649; this.queryTerm(); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } queryOrderBy() { let _localctx = new QueryOrderByContext(this._ctx, this.state); this.enterRule(_localctx, 28, FlinkSQLParser.RULE_queryOrderBy); try { this.enterOuterAlt(_localctx, 1); { this.state = 651; this.match(FlinkSQLParser.ORDER); this.state = 652; this.match(FlinkSQLParser.BY); this.state = 653; this.orderItems(); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } queryLimit() { let _localctx = new QueryLimitContext(this._ctx, this.state); this.enterRule(_localctx, 30, FlinkSQLParser.RULE_queryLimit); try { this.enterOuterAlt(_localctx, 1); { this.state = 655; this.match(FlinkSQLParser.LIMIT); this.state = 659; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 17, this._ctx)) { case 1: { this.state = 656; this.expr(); this.state = 657; this.match(FlinkSQLParser.COMMA); } break; } this.state = 663; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 18, this._ctx)) { case 1: { this.state = 661; this.expr(); } break; case 2: { this.state = 662; this.match(FlinkSQLParser.ALL); } break; } } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } queryOffset() { let _localctx = new QueryOffsetContext(this._ctx, this.state); this.enterRule(_localctx, 32, FlinkSQLParser.RULE_queryOffset); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 665; this.match(FlinkSQLParser.OFFSET); this.state = 666; this.expr(); this.state = 667; _la = this._input.LA(1); if (!(_la === FlinkSQLParser.ROW || _la === FlinkSQLParser.ROWS)) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token_1.Token.EOF) { this.matchedEOF = true; } this._errHandler.reportMatch(this); this.consume(); } } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } queryFetch() { let _localctx = new QueryFetchContext(this._ctx, this.state); this.enterRule(_localctx, 34, FlinkSQLParser.RULE_queryFetch); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 669; this.match(FlinkSQLParser.FETCH); this.state = 670; _la = this._input.LA(1); if (!(_la === FlinkSQLParser.NEXT || _la === FlinkSQLParser.FIRST)) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token_1.Token.EOF) { this.matchedEOF = true; } this._errHandler.reportMatch(this); this.consume(); } this.state = 672; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 19, this._ctx)) { case 1: { this.state = 671; this.expr(); } break; } this.state = 674; _la = this._input.LA(1); if (!(_la === FlinkSQLParser.ROW || _la === FlinkSQLParser.ROWS)) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token_1.Token.EOF) { this.matchedEOF = true; } this._errHandler.reportMatch(this); this.consume(); } this.state = 675; this.match(FlinkSQLParser.ONLY); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } withItem() { let _localctx = new WithItemContext(this._ctx, this.state); this.enterRule(_localctx, 36, FlinkSQLParser.RULE_withItem); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 677; this.tableName(); this.state = 679; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 20, this._ctx)) { case 1: { this.state = 678; this.columns(); } break; } this.state = 682; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.AS) { { this.state = 681; this.match(FlinkSQLParser.AS); } } this.state = 684; this.parenthesisQuery(); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } orderItem() { let _localctx = new OrderItemContext(this._ctx, this.state); this.enterRule(_localctx, 38, FlinkSQLParser.RULE_orderItem); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 686; this.expr(); this.state = 688; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.ASC || _la === FlinkSQLParser.DESC) { { this.state = 687; _la = this._input.LA(1); if (!(_la === FlinkSQLParser.ASC || _la === FlinkSQLParser.DESC)) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token_1.Token.EOF) { this.matchedEOF = true; } this._errHandler.reportMatch(this); this.consume(); } } } this.state = 694; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 23, this._ctx)) { case 1: { this.state = 690; this.match(FlinkSQLParser.NULLS); this.state = 691; this.match(FlinkSQLParser.FIRST); } break; case 2: { this.state = 692; this.match(FlinkSQLParser.NULLS); this.state = 693; this.match(FlinkSQLParser.LAST); } break; } } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } selectClause() { let _localctx = new SelectClauseContext(this._ctx, this.state); this.enterRule(_localctx, 40, FlinkSQLParser.RULE_selectClause); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 696; this.match(FlinkSQLParser.SELECT); this.state = 698; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.L_HINT) { { this.state = 697; this.hints(); } } this.state = 701; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 25, this._ctx)) { case 1: { this.state = 700; this.match(FlinkSQLParser.STREAM); } break; } this.state = 704; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 26, this._ctx)) { case 1: { this.state = 703; this.setQuantifier(); } break; } this.state = 706; this.projectItems(); } } catch (re) { if (re instanceof RecognitionException_1.RecognitionException) { _localctx.exception = re; this._errHandler.reportError(this, re); this._errHandler.recover(this, re); } else { throw re; } } finally { this.exitRule(); } return _localctx; } select() { let _localctx = new SelectContext(this._ctx, this.state); this.enterRule(_localctx, 42, FlinkSQLParser.RULE_select); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 708; this.selectClause(); this.state = 710; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.FROM) { { this.state = 709; this.fromTable(); } } this.state = 713; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.WHERE) { { this.state = 712; this.where(); } } this.state = 716; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.GROUP) { { this.state = 715; this.groupBy(); } } this.state = 719; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === FlinkSQLParser.H