UNPKG

rhombic

Version:

SQL parsing, lineage extraction and manipulation

910 lines (909 loc) 1.17 MB
"use strict"; // Generated from src/antlr/SqlBase.g4 by ANTLR 4.9.0-SNAPSHOT var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (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.ShowViewsContext = exports.ShowColumnsContext = exports.ShowTblPropertiesContext = exports.ShowTableExtendedContext = exports.ShowTablesContext = exports.ExplainContext = exports.DropFunctionContext = exports.CreateFunctionContext = exports.AlterViewQueryContext = exports.CreateTempViewUsingContext = exports.CreateViewContext = exports.DropViewContext = exports.DropTableContext = exports.RecoverPartitionsContext = exports.SetTableLocationContext = exports.DropTablePartitionsContext = exports.RenameTablePartitionContext = exports.AddTablePartitionContext = exports.SetTableSerDeContext = exports.HiveReplaceColumnsContext = exports.HiveChangeColumnContext = exports.AlterTableAlterColumnContext = exports.UnsetTablePropertiesContext = exports.SetTablePropertiesContext = exports.RenameTableContext = exports.DropTableColumnsContext = exports.RenameTableColumnContext = exports.AddTableColumnsContext = exports.AnalyzeTablesContext = exports.AnalyzeContext = exports.ReplaceTableContext = exports.CreateTableLikeContext = exports.CreateTableContext = exports.ShowNamespacesContext = exports.DropNamespaceContext = exports.SetNamespaceLocationContext = exports.SetNamespacePropertiesContext = exports.CreateNamespaceContext = exports.UseContext = exports.DmlStatementContext = exports.StatementDefaultContext = exports.StatementContext = exports.SingleTableSchemaContext = exports.SingleDataTypeContext = exports.SingleFunctionIdentifierContext = exports.SingleMultipartIdentifierContext = exports.SingleTableIdentifierContext = exports.SingleExpressionContext = exports.SingleStatementContext = exports.SqlBaseParser = void 0; exports.TableProviderContext = exports.NamedQueryContext = exports.CtesContext = exports.DescribeColNameContext = exports.DescribeFuncNameContext = exports.NamespaceContext = exports.PartitionValContext = exports.PartitionSpecContext = exports.PartitionSpecLocationContext = exports.InsertOverwriteDirContext = exports.InsertOverwriteHiveDirContext = exports.InsertIntoTableContext = exports.InsertOverwriteTableContext = exports.InsertIntoContext = exports.QueryContext = exports.CommentSpecContext = exports.LocationSpecContext = exports.SkewSpecContext = exports.BucketSpecContext = exports.ReplaceTableHeaderContext = exports.CreateTableHeaderContext = exports.UnsupportedHiveNativeCommandsContext = exports.ConfigValueContext = exports.ConfigKeyContext = exports.ResetConfigurationContext = exports.ResetQuotedConfigurationContext = exports.SetConfigurationContext = exports.SetQuotedConfigurationContext = exports.SetTimeZoneContext = exports.FailNativeCommandContext = exports.ManageResourceContext = exports.RepairTableContext = exports.TruncateTableContext = exports.LoadDataContext = exports.ClearCacheContext = exports.UncacheTableContext = exports.CacheTableContext = exports.RefreshResourceContext = exports.RefreshFunctionContext = exports.RefreshTableContext = exports.CommentTableContext = exports.CommentNamespaceContext = exports.DescribeQueryContext = exports.DescribeRelationContext = exports.DescribeNamespaceContext = exports.DescribeFunctionContext = exports.ShowCurrentNamespaceContext = exports.ShowCreateTableContext = exports.ShowFunctionsContext = exports.ShowPartitionsContext = void 0; exports.FromClauseContext = exports.HintStatementContext = exports.HintContext = exports.HavingClauseContext = exports.WhereClauseContext = exports.AssignmentContext = exports.AssignmentListContext = exports.NotMatchedActionContext = exports.MatchedActionContext = exports.NotMatchedClauseContext = exports.MatchedClauseContext = exports.SetClauseContext = exports.SelectClauseContext = exports.TransformClauseContext = exports.RegularQuerySpecificationContext = exports.TransformQuerySpecificationContext = exports.QuerySpecificationContext = exports.FromStatementBodyContext = exports.FromStatementContext = exports.SortItemContext = exports.SubqueryContext = exports.InlineTableDefault1Context = exports.TableContext = exports.FromStmtContext = exports.QueryPrimaryDefaultContext = exports.QueryPrimaryContext = exports.SetOperationContext = exports.QueryTermDefaultContext = exports.QueryTermContext = exports.MultiInsertQueryBodyContext = exports.QueryOrganizationContext = exports.MergeIntoTableContext = exports.UpdateTableContext = exports.DeleteFromTableContext = exports.MultiInsertQueryContext = exports.SingleInsertQueryContext = exports.DmlStatementNoWithContext = exports.ResourceContext = exports.StorageHandlerContext = exports.GenericFileFormatContext = exports.TableFileFormatContext = exports.FileFormatContext = exports.CreateFileFormatContext = exports.NestedConstantListContext = exports.ConstantListContext = exports.TablePropertyValueContext = exports.TablePropertyKeyContext = exports.TablePropertyContext = exports.TablePropertyListContext = exports.CreateTableClausesContext = void 0; exports.PartitionColumnContext = exports.PartitionTransformContext = exports.PartitionFieldContext = exports.PartitionFieldListContext = exports.NamedExpressionSeqContext = exports.NamedExpressionContext = exports.FunctionIdentifierContext = exports.TableIdentifierContext = exports.MultipartIdentifierContext = exports.MultipartIdentifierListContext = exports.RowFormatDelimitedContext = exports.RowFormatSerdeContext = exports.RowFormatContext = exports.TableAliasContext = exports.FunctionTableContext = exports.InlineTableContext = exports.TableValuedFunctionContext = exports.InlineTableDefault2Context = exports.AliasedRelationContext = exports.AliasedQueryContext = exports.TableNameContext = exports.RelationPrimaryContext = exports.IdentifierCommentContext = exports.IdentifierCommentListContext = exports.OrderedIdentifierContext = exports.OrderedIdentifierListContext = exports.IdentifierSeqContext = exports.IdentifierListContext = exports.SampleByBytesContext = exports.SampleByBucketContext = exports.SampleByRowsContext = exports.SampleByPercentileContext = exports.SampleMethodContext = exports.SampleContext = exports.JoinCriteriaUsingContext = exports.JoinCriteriaOnContext = exports.JoinCriteriaContext = exports.JoinTypeContext = exports.JoinRelationContext = exports.RelationContext = exports.SetQuantifierContext = exports.LateralViewContext = exports.PivotValueContext = exports.PivotColumnContext = exports.PivotClauseContext = exports.GroupingSetContext = exports.GroupingElementContext = exports.GroupingAnalyticsContext = exports.GroupByClauseContext = exports.AggregationClauseContext = void 0; exports.ComparisonOperatorContext = exports.StringLiteralContext = exports.BooleanLiteralContext = exports.NumericLiteralContext = exports.TypeConstructorContext = exports.IntervalLiteralContext = exports.NullLiteralContext = exports.ConstantContext = exports.OverlayContext = exports.TrimContext = exports.SubstringContext = exports.ExtractContext = exports.ParenthesizedExpressionContext = exports.PostgresJsonContext = exports.PostgresCastContext = exports.DereferenceContext = exports.ColumnReferenceContext = exports.SubscriptContext = exports.LambdaContext = exports.FunctionCallContext = exports.SubqueryExpressionContext = exports.RowConstructorContext = exports.StarContext = exports.ConstantDefaultContext = exports.PositionContext = exports.LastContext = exports.FirstContext = exports.StructContext = exports.CastContext = exports.SimpleCaseContext = exports.SearchedCaseContext = exports.CurrentLikeContext = exports.PrimaryExpressionContext = exports.ComparisonContext = exports.ArithmeticBinaryContext = exports.ArithmeticUnaryContext = exports.ValueExpressionDefaultContext = exports.ValueExpressionContext = exports.PredicateContext = exports.LogicalBinaryContext = exports.PredicatedContext = exports.ExistsContext = exports.LogicalNotContext = exports.BooleanExpressionContext = exports.ExpressionSeqContext = exports.ExpressionContext = exports.TransformArgumentContext = exports.ApplyTransformContext = exports.IdentityTransformContext = exports.TransformContext = void 0; exports.DoubleLiteralContext = exports.TinyIntLiteralContext = exports.SmallIntLiteralContext = exports.BigIntLiteralContext = exports.IntegerLiteralContext = exports.LegacyDecimalLiteralContext = exports.DecimalLiteralContext = exports.ExponentLiteralContext = exports.NumberContext = exports.QuotedIdentifierContext = exports.QuotedIdentifierAlternativeContext = exports.UnquotedIdentifierContext = exports.StrictIdentifierContext = exports.IdentifierContext = exports.RealIdentContext = exports.ErrorIdentContext = exports.ErrorCapturingIdentifierExtraContext = exports.ErrorCapturingIdentifierContext = exports.QualifiedNameContext = exports.FunctionNameContext = exports.QualifiedNameListContext = exports.FrameBoundContext = exports.WindowFrameContext = exports.WindowDefContext = exports.WindowRefContext = exports.WindowSpecContext = exports.NamedWindowContext = exports.WindowClauseContext = exports.WhenClauseContext = exports.ComplexColTypeContext = exports.ComplexColTypeListContext = exports.ColTypeContext = exports.ColTypeListContext = exports.QualifiedColTypeWithPositionContext = exports.QualifiedColTypeWithPositionListContext = exports.PrimitiveDataTypeContext = exports.DayTimeIntervalDataTypeContext = exports.YearMonthIntervalDataTypeContext = exports.ComplexDataTypeContext = exports.DataTypeContext = exports.ColPositionContext = exports.IntervalValueContext = exports.UnitToUnitIntervalContext = exports.ErrorCapturingUnitToUnitIntervalContext = exports.MultiUnitsIntervalContext = exports.ErrorCapturingMultiUnitsIntervalContext = exports.IntervalContext = exports.BooleanValueContext = exports.PredicateOperatorContext = exports.ArithmeticOperatorContext = void 0; exports.NonReservedContext = exports.StrictNonReservedContext = exports.AnsiNonReservedContext = exports.AlterColumnActionContext = exports.BigDecimalLiteralContext = exports.FloatLiteralContext = 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 SqlBaseParser extends Parser_1.Parser { constructor(input) { super(input); this.backquoted_identifier = true; this.doublequoted_identifier = false; /** * When false, INTERSECT is given the greater precedence over the other set * operations (UNION, EXCEPT and MINUS) as per the SQL standard. */ this.legacy_setops_precedence_enabled = false; /** * When false, a literal with an exponent would be converted into * double type rather than decimal type. */ this.legacy_exponent_literal_as_decimal_enabled = false; /** * When true, the behavior of keywords follows ANSI SQL standard. */ this.SQL_standard_keyword_behavior = true; this._interp = new ParserATNSimulator_1.ParserATNSimulator(SqlBaseParser._ATN, this); } // @Override // @NotNull get vocabulary() { return SqlBaseParser.VOCABULARY; } // tslint:enable:no-trailing-whitespace // @Override get grammarFileName() { return "SqlBase.g4"; } // @Override get ruleNames() { return SqlBaseParser.ruleNames; } // @Override get serializedATN() { return SqlBaseParser._serializedATN; } createFailedPredicateException(predicate, message) { return new FailedPredicateException_1.FailedPredicateException(this, predicate, message); } // @RuleVersion(0) singleStatement() { const _localctx = new SingleStatementContext(this._ctx, this.state); this.enterRule(_localctx, 0, SqlBaseParser.RULE_singleStatement); let _la; try { this.enterOuterAlt(_localctx, 1); { this.state = 286; this.statement(); this.state = 290; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === SqlBaseParser.T__0) { { { this.state = 287; this.match(SqlBaseParser.T__0); } } this.state = 292; this._errHandler.sync(this); _la = this._input.LA(1); } this.state = 293; this.match(SqlBaseParser.EOF); } } 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; } // @RuleVersion(0) singleExpression() { const _localctx = new SingleExpressionContext(this._ctx, this.state); this.enterRule(_localctx, 2, SqlBaseParser.RULE_singleExpression); try { this.enterOuterAlt(_localctx, 1); { this.state = 295; this.namedExpression(); this.state = 296; this.match(SqlBaseParser.EOF); } } 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; } // @RuleVersion(0) singleTableIdentifier() { const _localctx = new SingleTableIdentifierContext(this._ctx, this.state); this.enterRule(_localctx, 4, SqlBaseParser.RULE_singleTableIdentifier); try { this.enterOuterAlt(_localctx, 1); { this.state = 298; this.tableIdentifier(); this.state = 299; this.match(SqlBaseParser.EOF); } } 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; } // @RuleVersion(0) singleMultipartIdentifier() { const _localctx = new SingleMultipartIdentifierContext(this._ctx, this.state); this.enterRule(_localctx, 6, SqlBaseParser.RULE_singleMultipartIdentifier); try { this.enterOuterAlt(_localctx, 1); { this.state = 301; this.multipartIdentifier(); this.state = 302; this.match(SqlBaseParser.EOF); } } 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; } // @RuleVersion(0) singleFunctionIdentifier() { const _localctx = new SingleFunctionIdentifierContext(this._ctx, this.state); this.enterRule(_localctx, 8, SqlBaseParser.RULE_singleFunctionIdentifier); try { this.enterOuterAlt(_localctx, 1); { this.state = 304; this.functionIdentifier(); this.state = 305; this.match(SqlBaseParser.EOF); } } 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; } // @RuleVersion(0) singleDataType() { const _localctx = new SingleDataTypeContext(this._ctx, this.state); this.enterRule(_localctx, 10, SqlBaseParser.RULE_singleDataType); try { this.enterOuterAlt(_localctx, 1); { this.state = 307; this.dataType(); this.state = 308; this.match(SqlBaseParser.EOF); } } 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; } // @RuleVersion(0) singleTableSchema() { const _localctx = new SingleTableSchemaContext(this._ctx, this.state); this.enterRule(_localctx, 12, SqlBaseParser.RULE_singleTableSchema); try { this.enterOuterAlt(_localctx, 1); { this.state = 310; this.colTypeList(); this.state = 311; this.match(SqlBaseParser.EOF); } } 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; } // @RuleVersion(0) statement() { let _localctx = new StatementContext(this._ctx, this.state); this.enterRule(_localctx, 14, SqlBaseParser.RULE_statement); let _la; try { let _alt; this.state = 1050; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 109, this._ctx)) { case 1: _localctx = new StatementDefaultContext(_localctx); this.enterOuterAlt(_localctx, 1); { this.state = 313; this.query(); } break; case 2: _localctx = new DmlStatementContext(_localctx); this.enterOuterAlt(_localctx, 2); { this.state = 315; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.WITH) { { this.state = 314; this.ctes(); } } this.state = 317; this.dmlStatementNoWith(); } break; case 3: _localctx = new UseContext(_localctx); this.enterOuterAlt(_localctx, 3); { this.state = 318; this.match(SqlBaseParser.USE); this.state = 320; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 2, this._ctx)) { case 1: { this.state = 319; this.match(SqlBaseParser.NAMESPACE); } break; } this.state = 322; this.multipartIdentifier(); } break; case 4: _localctx = new CreateNamespaceContext(_localctx); this.enterOuterAlt(_localctx, 4); { this.state = 323; this.match(SqlBaseParser.CREATE); this.state = 324; this.namespace(); this.state = 328; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 3, this._ctx)) { case 1: { this.state = 325; this.match(SqlBaseParser.IF); this.state = 326; this.match(SqlBaseParser.NOT); this.state = 327; this.match(SqlBaseParser.EXISTS); } break; } this.state = 330; this.multipartIdentifier(); this.state = 338; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === SqlBaseParser.COMMENT || _la === SqlBaseParser.LOCATION || _la === SqlBaseParser.WITH) { { this.state = 336; this._errHandler.sync(this); switch (this._input.LA(1)) { case SqlBaseParser.COMMENT: { this.state = 331; this.commentSpec(); } break; case SqlBaseParser.LOCATION: { this.state = 332; this.locationSpec(); } break; case SqlBaseParser.WITH: { { this.state = 333; this.match(SqlBaseParser.WITH); this.state = 334; _la = this._input.LA(1); if (!(_la === SqlBaseParser.DBPROPERTIES || _la === SqlBaseParser.PROPERTIES)) { 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 = 335; this.tablePropertyList(); } } break; default: throw new NoViableAltException_1.NoViableAltException(this); } } this.state = 340; this._errHandler.sync(this); _la = this._input.LA(1); } } break; case 5: _localctx = new SetNamespacePropertiesContext(_localctx); this.enterOuterAlt(_localctx, 5); { this.state = 341; this.match(SqlBaseParser.ALTER); this.state = 342; this.namespace(); this.state = 343; this.multipartIdentifier(); this.state = 344; this.match(SqlBaseParser.SET); this.state = 345; _la = this._input.LA(1); if (!(_la === SqlBaseParser.DBPROPERTIES || _la === SqlBaseParser.PROPERTIES)) { 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 = 346; this.tablePropertyList(); } break; case 6: _localctx = new SetNamespaceLocationContext(_localctx); this.enterOuterAlt(_localctx, 6); { this.state = 348; this.match(SqlBaseParser.ALTER); this.state = 349; this.namespace(); this.state = 350; this.multipartIdentifier(); this.state = 351; this.match(SqlBaseParser.SET); this.state = 352; this.locationSpec(); } break; case 7: _localctx = new DropNamespaceContext(_localctx); this.enterOuterAlt(_localctx, 7); { this.state = 354; this.match(SqlBaseParser.DROP); this.state = 355; this.namespace(); this.state = 358; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 6, this._ctx)) { case 1: { this.state = 356; this.match(SqlBaseParser.IF); this.state = 357; this.match(SqlBaseParser.EXISTS); } break; } this.state = 360; this.multipartIdentifier(); this.state = 362; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.CASCADE || _la === SqlBaseParser.RESTRICT) { { this.state = 361; _la = this._input.LA(1); if (!(_la === SqlBaseParser.CASCADE || _la === SqlBaseParser.RESTRICT)) { this._errHandler.recoverInline(this); } else { if (this._input.LA(1) === Token_1.Token.EOF) { this.matchedEOF = true; } this._errHandler.reportMatch(this); this.consume(); } } } } break; case 8: _localctx = new ShowNamespacesContext(_localctx); this.enterOuterAlt(_localctx, 8); { this.state = 364; this.match(SqlBaseParser.SHOW); this.state = 365; _la = this._input.LA(1); if (!(_la === SqlBaseParser.DATABASES || _la === SqlBaseParser.NAMESPACES)) { 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 = 368; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.FROM || _la === SqlBaseParser.IN) { { this.state = 366; _la = this._input.LA(1); if (!(_la === SqlBaseParser.FROM || _la === SqlBaseParser.IN)) { 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 = 367; this.multipartIdentifier(); } } this.state = 374; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.LIKE || _la === SqlBaseParser.STRING) { { this.state = 371; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.LIKE) { { this.state = 370; this.match(SqlBaseParser.LIKE); } } this.state = 373; _localctx._pattern = this.match(SqlBaseParser.STRING); } } } break; case 9: _localctx = new CreateTableContext(_localctx); this.enterOuterAlt(_localctx, 9); { this.state = 376; this.createTableHeader(); this.state = 381; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 11, this._ctx)) { case 1: { this.state = 377; this.match(SqlBaseParser.T__1); this.state = 378; this.colTypeList(); this.state = 379; this.match(SqlBaseParser.T__2); } break; } this.state = 384; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.USING) { { this.state = 383; this.tableProvider(); } } this.state = 386; this.createTableClauses(); this.state = 391; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.T__1 || _la === SqlBaseParser.AS || _la === SqlBaseParser.FROM || _la === SqlBaseParser.MAP || _la === SqlBaseParser.REDUCE || _la === SqlBaseParser.SELECT || _la === SqlBaseParser.TABLE || _la === SqlBaseParser.VALUES || _la === SqlBaseParser.WITH) { { this.state = 388; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.AS) { { this.state = 387; this.match(SqlBaseParser.AS); } } this.state = 390; this.query(); } } } break; case 10: _localctx = new CreateTableLikeContext(_localctx); this.enterOuterAlt(_localctx, 10); { this.state = 393; this.match(SqlBaseParser.CREATE); this.state = 394; this.match(SqlBaseParser.TABLE); this.state = 398; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 15, this._ctx)) { case 1: { this.state = 395; this.match(SqlBaseParser.IF); this.state = 396; this.match(SqlBaseParser.NOT); this.state = 397; this.match(SqlBaseParser.EXISTS); } break; } this.state = 400; _localctx._target = this.tableIdentifier(); this.state = 401; this.match(SqlBaseParser.LIKE); this.state = 402; _localctx._source = this.tableIdentifier(); this.state = 411; this._errHandler.sync(this); _la = this._input.LA(1); while (_la === SqlBaseParser.LOCATION || (((_la - 208) & ~0x1f) === 0 && ((1 << (_la - 208)) & ((1 << (SqlBaseParser.ROW - 208)) | (1 << (SqlBaseParser.STORED - 208)) | (1 << (SqlBaseParser.TBLPROPERTIES - 208)))) !== 0) || _la === SqlBaseParser.USING) { { this.state = 409; this._errHandler.sync(this); switch (this._input.LA(1)) { case SqlBaseParser.USING: { this.state = 403; this.tableProvider(); } break; case SqlBaseParser.ROW: { this.state = 404; this.rowFormat(); } break; case SqlBaseParser.STORED: { this.state = 405; this.createFileFormat(); } break; case SqlBaseParser.LOCATION: { this.state = 406; this.locationSpec(); } break; case SqlBaseParser.TBLPROPERTIES: { { this.state = 407; this.match(SqlBaseParser.TBLPROPERTIES); this.state = 408; _localctx._tableProps = this.tablePropertyList(); } } break; default: throw new NoViableAltException_1.NoViableAltException(this); } } this.state = 413; this._errHandler.sync(this); _la = this._input.LA(1); } } break; case 11: _localctx = new ReplaceTableContext(_localctx); this.enterOuterAlt(_localctx, 11); { this.state = 414; this.replaceTableHeader(); this.state = 419; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 18, this._ctx)) { case 1: { this.state = 415; this.match(SqlBaseParser.T__1); this.state = 416; this.colTypeList(); this.state = 417; this.match(SqlBaseParser.T__2); } break; } this.state = 422; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.USING) { { this.state = 421; this.tableProvider(); } } this.state = 424; this.createTableClauses(); this.state = 429; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.T__1 || _la === SqlBaseParser.AS || _la === SqlBaseParser.FROM || _la === SqlBaseParser.MAP || _la === SqlBaseParser.REDUCE || _la === SqlBaseParser.SELECT || _la === SqlBaseParser.TABLE || _la === SqlBaseParser.VALUES || _la === SqlBaseParser.WITH) { { this.state = 426; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.AS) { { this.state = 425; this.match(SqlBaseParser.AS); } } this.state = 428; this.query(); } } } break; case 12: _localctx = new AnalyzeContext(_localctx); this.enterOuterAlt(_localctx, 12); { this.state = 431; this.match(SqlBaseParser.ANALYZE); this.state = 432; this.match(SqlBaseParser.TABLE); this.state = 433; this.multipartIdentifier(); this.state = 435; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.PARTITION) { { this.state = 434; this.partitionSpec(); } } this.state = 437; this.match(SqlBaseParser.COMPUTE); this.state = 438; this.match(SqlBaseParser.STATISTICS); this.state = 446; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 23, this._ctx)) { case 1: { this.state = 439; this.identifier(); } break; case 2: { this.state = 440; this.match(SqlBaseParser.FOR); this.state = 441; this.match(SqlBaseParser.COLUMNS); this.state = 442; this.identifierSeq(); } break; case 3: { this.state = 443; this.match(SqlBaseParser.FOR); this.state = 444; this.match(SqlBaseParser.ALL); this.state = 445; this.match(SqlBaseParser.COLUMNS); } break; } } break; case 13: _localctx = new AnalyzeTablesContext(_localctx); this.enterOuterAlt(_localctx, 13); { this.state = 448; this.match(SqlBaseParser.ANALYZE); this.state = 449; this.match(SqlBaseParser.TABLES); this.state = 452; this._errHandler.sync(this); _la = this._input.LA(1); if (_la === SqlBaseParser.FROM || _la === SqlBaseParser.IN) { { this.state = 450; _la = this._input.LA(1); if (!(_la === SqlBaseParser.FROM || _la === SqlBaseParser.IN)) { 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 = 451; this.multipartIdentifier(); } } this.state = 454; this.match(SqlBaseParser.COMPUTE); this.state = 455; this.match(SqlBaseParser.STATISTICS); this.state = 457; this._errHandler.sync(this); switch (this.interpreter.adaptivePredict(this._input, 25, this._ctx)) { case 1: { this.state = 456; this.identifier(); } break; } } break; case 14: _localctx = new AddTableColumnsContext(_localctx); this.enterOuterAlt(_localctx, 14); { this.state = 459; this.match(SqlBaseParser.ALTER); this.state = 460; this.match(SqlBaseParser.TABLE); this.state = 461; this.multipartIdentifier(); this.state = 462; this.match(SqlBaseParser.ADD); this.state = 463; _la = this._input.LA(1); if (!(_la === SqlBaseParser.COLUMN || _la === SqlBaseParser.COLUMNS)) { 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 = 464; _localctx._columns = this.qualifiedColTypeWithPositionList(); } break; case 15: _localctx = new AddTableColumnsContext(_localctx); this.enterOuterAlt(_localctx, 15); { this.state = 466; this.match(SqlBaseParser.ALTER);