public final StatementContext statement()

in x-pack/plugin/sql/src/main/java/org/elasticsearch/xpack/sql/parser/SqlBaseParser.java [1226:1937]


    public final StatementContext statement() throws RecognitionException {
        StatementContext _localctx = new StatementContext(_ctx, getState());
        enterRule(_localctx, 4, RULE_statement);
        int _la;
        try {
            setState(256);
            _errHandler.sync(this);
            switch (getInterpreter().adaptivePredict(_input, 26, _ctx)) {
                case 1:
                    _localctx = new StatementDefaultContext(_localctx);
                    enterOuterAlt(_localctx, 1); {
                    setState(126);
                    query();
                }
                    break;
                case 2:
                    _localctx = new ExplainContext(_localctx);
                    enterOuterAlt(_localctx, 2); {
                    setState(127);
                    match(EXPLAIN);
                    setState(141);
                    _errHandler.sync(this);
                    switch (getInterpreter().adaptivePredict(_input, 2, _ctx)) {
                        case 1: {
                            setState(128);
                            match(T__0);
                            setState(137);
                            _errHandler.sync(this);
                            _la = _input.LA(1);
                            while (((((_la - 39)) & ~0x3f) == 0 && ((1L << (_la - 39)) & 288230651029618689L) != 0)) {
                                {
                                    setState(135);
                                    _errHandler.sync(this);
                                    switch (_input.LA(1)) {
                                        case PLAN: {
                                            setState(129);
                                            match(PLAN);
                                            setState(130);
                                            ((ExplainContext) _localctx).type = _input.LT(1);
                                            _la = _input.LA(1);
                                            if (!((((_la) & ~0x3f) == 0 && ((1L << _la) & 576460756598390944L) != 0)
                                                || _la == OPTIMIZED
                                                || _la == PARSED)) {
                                                ((ExplainContext) _localctx).type = (Token) _errHandler.recoverInline(this);
                                            } else {
                                                if (_input.LA(1) == Token.EOF) matchedEOF = true;
                                                _errHandler.reportMatch(this);
                                                consume();
                                            }
                                        }
                                            break;
                                        case FORMAT: {
                                            setState(131);
                                            match(FORMAT);
                                            setState(132);
                                            ((ExplainContext) _localctx).format = _input.LT(1);
                                            _la = _input.LA(1);
                                            if (!(_la == GRAPHVIZ || _la == TEXT)) {
                                                ((ExplainContext) _localctx).format = (Token) _errHandler.recoverInline(this);
                                            } else {
                                                if (_input.LA(1) == Token.EOF) matchedEOF = true;
                                                _errHandler.reportMatch(this);
                                                consume();
                                            }
                                        }
                                            break;
                                        case VERIFY: {
                                            setState(133);
                                            match(VERIFY);
                                            setState(134);
                                            ((ExplainContext) _localctx).verify = booleanValue();
                                        }
                                            break;
                                        default:
                                            throw new NoViableAltException(this);
                                    }
                                }
                                setState(139);
                                _errHandler.sync(this);
                                _la = _input.LA(1);
                            }
                            setState(140);
                            match(T__1);
                        }
                            break;
                    }
                    setState(143);
                    statement();
                }
                    break;
                case 3:
                    _localctx = new DebugContext(_localctx);
                    enterOuterAlt(_localctx, 3); {
                    setState(144);
                    match(DEBUG);
                    setState(156);
                    _errHandler.sync(this);
                    switch (getInterpreter().adaptivePredict(_input, 5, _ctx)) {
                        case 1: {
                            setState(145);
                            match(T__0);
                            setState(152);
                            _errHandler.sync(this);
                            _la = _input.LA(1);
                            while (_la == FORMAT || _la == PLAN) {
                                {
                                    setState(150);
                                    _errHandler.sync(this);
                                    switch (_input.LA(1)) {
                                        case PLAN: {
                                            setState(146);
                                            match(PLAN);
                                            setState(147);
                                            ((DebugContext) _localctx).type = _input.LT(1);
                                            _la = _input.LA(1);
                                            if (!(_la == ANALYZED || _la == OPTIMIZED)) {
                                                ((DebugContext) _localctx).type = (Token) _errHandler.recoverInline(this);
                                            } else {
                                                if (_input.LA(1) == Token.EOF) matchedEOF = true;
                                                _errHandler.reportMatch(this);
                                                consume();
                                            }
                                        }
                                            break;
                                        case FORMAT: {
                                            setState(148);
                                            match(FORMAT);
                                            setState(149);
                                            ((DebugContext) _localctx).format = _input.LT(1);
                                            _la = _input.LA(1);
                                            if (!(_la == GRAPHVIZ || _la == TEXT)) {
                                                ((DebugContext) _localctx).format = (Token) _errHandler.recoverInline(this);
                                            } else {
                                                if (_input.LA(1) == Token.EOF) matchedEOF = true;
                                                _errHandler.reportMatch(this);
                                                consume();
                                            }
                                        }
                                            break;
                                        default:
                                            throw new NoViableAltException(this);
                                    }
                                }
                                setState(154);
                                _errHandler.sync(this);
                                _la = _input.LA(1);
                            }
                            setState(155);
                            match(T__1);
                        }
                            break;
                    }
                    setState(158);
                    statement();
                }
                    break;
                case 4:
                    _localctx = new ShowTablesContext(_localctx);
                    enterOuterAlt(_localctx, 4); {
                    setState(159);
                    match(SHOW);
                    setState(160);
                    match(TABLES);
                    setState(166);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == CATALOG) {
                        {
                            setState(161);
                            match(CATALOG);
                            setState(164);
                            _errHandler.sync(this);
                            switch (_input.LA(1)) {
                                case LIKE: {
                                    setState(162);
                                    ((ShowTablesContext) _localctx).clusterLike = likePattern();
                                }
                                    break;
                                case PARAM:
                                case STRING: {
                                    setState(163);
                                    ((ShowTablesContext) _localctx).cluster = string();
                                }
                                    break;
                                default:
                                    throw new NoViableAltException(this);
                            }
                        }
                    }

                    setState(170);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == INCLUDE) {
                        {
                            setState(168);
                            match(INCLUDE);
                            setState(169);
                            match(FROZEN);
                        }
                    }

                    setState(174);
                    _errHandler.sync(this);
                    switch (_input.LA(1)) {
                        case LIKE: {
                            setState(172);
                            ((ShowTablesContext) _localctx).tableLike = likePattern();
                        }
                            break;
                        case ANALYZE:
                        case ANALYZED:
                        case CATALOGS:
                        case COLUMNS:
                        case CURRENT_DATE:
                        case CURRENT_TIME:
                        case CURRENT_TIMESTAMP:
                        case DAY:
                        case DEBUG:
                        case EXECUTABLE:
                        case EXPLAIN:
                        case FIRST:
                        case FORMAT:
                        case FULL:
                        case FUNCTIONS:
                        case GRAPHVIZ:
                        case HOUR:
                        case INTERVAL:
                        case LAST:
                        case LIMIT:
                        case MAPPED:
                        case MINUTE:
                        case MONTH:
                        case OPTIMIZED:
                        case PARSED:
                        case PHYSICAL:
                        case PIVOT:
                        case PLAN:
                        case RLIKE:
                        case QUERY:
                        case SCHEMAS:
                        case SECOND:
                        case SHOW:
                        case SYS:
                        case TABLES:
                        case TEXT:
                        case TOP:
                        case TYPE:
                        case TYPES:
                        case VERIFY:
                        case YEAR:
                        case IDENTIFIER:
                        case DIGIT_IDENTIFIER:
                        case TABLE_IDENTIFIER:
                        case QUOTED_IDENTIFIER:
                        case BACKQUOTED_IDENTIFIER: {
                            setState(173);
                            ((ShowTablesContext) _localctx).tableIdent = tableIdentifier();
                        }
                            break;
                        case EOF:
                            break;
                        default:
                            break;
                    }
                }
                    break;
                case 5:
                    _localctx = new ShowColumnsContext(_localctx);
                    enterOuterAlt(_localctx, 5); {
                    setState(176);
                    match(SHOW);
                    setState(177);
                    match(COLUMNS);
                    setState(180);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == CATALOG) {
                        {
                            setState(178);
                            match(CATALOG);
                            setState(179);
                            ((ShowColumnsContext) _localctx).cluster = string();
                        }
                    }

                    setState(184);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == INCLUDE) {
                        {
                            setState(182);
                            match(INCLUDE);
                            setState(183);
                            match(FROZEN);
                        }
                    }

                    setState(186);
                    _la = _input.LA(1);
                    if (!(_la == FROM || _la == IN)) {
                        _errHandler.recoverInline(this);
                    } else {
                        if (_input.LA(1) == Token.EOF) matchedEOF = true;
                        _errHandler.reportMatch(this);
                        consume();
                    }
                    setState(189);
                    _errHandler.sync(this);
                    switch (_input.LA(1)) {
                        case LIKE: {
                            setState(187);
                            ((ShowColumnsContext) _localctx).tableLike = likePattern();
                        }
                            break;
                        case ANALYZE:
                        case ANALYZED:
                        case CATALOGS:
                        case COLUMNS:
                        case CURRENT_DATE:
                        case CURRENT_TIME:
                        case CURRENT_TIMESTAMP:
                        case DAY:
                        case DEBUG:
                        case EXECUTABLE:
                        case EXPLAIN:
                        case FIRST:
                        case FORMAT:
                        case FULL:
                        case FUNCTIONS:
                        case GRAPHVIZ:
                        case HOUR:
                        case INTERVAL:
                        case LAST:
                        case LIMIT:
                        case MAPPED:
                        case MINUTE:
                        case MONTH:
                        case OPTIMIZED:
                        case PARSED:
                        case PHYSICAL:
                        case PIVOT:
                        case PLAN:
                        case RLIKE:
                        case QUERY:
                        case SCHEMAS:
                        case SECOND:
                        case SHOW:
                        case SYS:
                        case TABLES:
                        case TEXT:
                        case TOP:
                        case TYPE:
                        case TYPES:
                        case VERIFY:
                        case YEAR:
                        case IDENTIFIER:
                        case DIGIT_IDENTIFIER:
                        case TABLE_IDENTIFIER:
                        case QUOTED_IDENTIFIER:
                        case BACKQUOTED_IDENTIFIER: {
                            setState(188);
                            ((ShowColumnsContext) _localctx).tableIdent = tableIdentifier();
                        }
                            break;
                        default:
                            throw new NoViableAltException(this);
                    }
                }
                    break;
                case 6:
                    _localctx = new ShowColumnsContext(_localctx);
                    enterOuterAlt(_localctx, 6); {
                    setState(191);
                    _la = _input.LA(1);
                    if (!(_la == DESC || _la == DESCRIBE)) {
                        _errHandler.recoverInline(this);
                    } else {
                        if (_input.LA(1) == Token.EOF) matchedEOF = true;
                        _errHandler.reportMatch(this);
                        consume();
                    }
                    setState(194);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == CATALOG) {
                        {
                            setState(192);
                            match(CATALOG);
                            setState(193);
                            ((ShowColumnsContext) _localctx).cluster = string();
                        }
                    }

                    setState(198);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == INCLUDE) {
                        {
                            setState(196);
                            match(INCLUDE);
                            setState(197);
                            match(FROZEN);
                        }
                    }

                    setState(202);
                    _errHandler.sync(this);
                    switch (_input.LA(1)) {
                        case LIKE: {
                            setState(200);
                            ((ShowColumnsContext) _localctx).tableLike = likePattern();
                        }
                            break;
                        case ANALYZE:
                        case ANALYZED:
                        case CATALOGS:
                        case COLUMNS:
                        case CURRENT_DATE:
                        case CURRENT_TIME:
                        case CURRENT_TIMESTAMP:
                        case DAY:
                        case DEBUG:
                        case EXECUTABLE:
                        case EXPLAIN:
                        case FIRST:
                        case FORMAT:
                        case FULL:
                        case FUNCTIONS:
                        case GRAPHVIZ:
                        case HOUR:
                        case INTERVAL:
                        case LAST:
                        case LIMIT:
                        case MAPPED:
                        case MINUTE:
                        case MONTH:
                        case OPTIMIZED:
                        case PARSED:
                        case PHYSICAL:
                        case PIVOT:
                        case PLAN:
                        case RLIKE:
                        case QUERY:
                        case SCHEMAS:
                        case SECOND:
                        case SHOW:
                        case SYS:
                        case TABLES:
                        case TEXT:
                        case TOP:
                        case TYPE:
                        case TYPES:
                        case VERIFY:
                        case YEAR:
                        case IDENTIFIER:
                        case DIGIT_IDENTIFIER:
                        case TABLE_IDENTIFIER:
                        case QUOTED_IDENTIFIER:
                        case BACKQUOTED_IDENTIFIER: {
                            setState(201);
                            ((ShowColumnsContext) _localctx).tableIdent = tableIdentifier();
                        }
                            break;
                        default:
                            throw new NoViableAltException(this);
                    }
                }
                    break;
                case 7:
                    _localctx = new ShowFunctionsContext(_localctx);
                    enterOuterAlt(_localctx, 7); {
                    setState(204);
                    match(SHOW);
                    setState(205);
                    match(FUNCTIONS);
                    setState(207);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == LIKE) {
                        {
                            setState(206);
                            likePattern();
                        }
                    }

                }
                    break;
                case 8:
                    _localctx = new ShowSchemasContext(_localctx);
                    enterOuterAlt(_localctx, 8); {
                    setState(209);
                    match(SHOW);
                    setState(210);
                    match(SCHEMAS);
                }
                    break;
                case 9:
                    _localctx = new ShowCatalogsContext(_localctx);
                    enterOuterAlt(_localctx, 9); {
                    setState(211);
                    match(SHOW);
                    setState(212);
                    match(CATALOGS);
                }
                    break;
                case 10:
                    _localctx = new SysTablesContext(_localctx);
                    enterOuterAlt(_localctx, 10); {
                    setState(213);
                    match(SYS);
                    setState(214);
                    match(TABLES);
                    setState(217);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == CATALOG) {
                        {
                            setState(215);
                            match(CATALOG);
                            setState(216);
                            ((SysTablesContext) _localctx).clusterLike = likePattern();
                        }
                    }

                    setState(221);
                    _errHandler.sync(this);
                    switch (getInterpreter().adaptivePredict(_input, 18, _ctx)) {
                        case 1: {
                            setState(219);
                            ((SysTablesContext) _localctx).tableLike = likePattern();
                        }
                            break;
                        case 2: {
                            setState(220);
                            ((SysTablesContext) _localctx).tableIdent = tableIdentifier();
                        }
                            break;
                    }
                    setState(232);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == TYPE) {
                        {
                            setState(223);
                            match(TYPE);
                            setState(224);
                            string();
                            setState(229);
                            _errHandler.sync(this);
                            _la = _input.LA(1);
                            while (_la == T__2) {
                                {
                                    {
                                        setState(225);
                                        match(T__2);
                                        setState(226);
                                        string();
                                    }
                                }
                                setState(231);
                                _errHandler.sync(this);
                                _la = _input.LA(1);
                            }
                        }
                    }

                }
                    break;
                case 11:
                    _localctx = new SysColumnsContext(_localctx);
                    enterOuterAlt(_localctx, 11); {
                    setState(234);
                    match(SYS);
                    setState(235);
                    match(COLUMNS);
                    setState(238);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == CATALOG) {
                        {
                            setState(236);
                            match(CATALOG);
                            setState(237);
                            ((SysColumnsContext) _localctx).cluster = string();
                        }
                    }

                    setState(243);
                    _errHandler.sync(this);
                    switch (_input.LA(1)) {
                        case TABLE: {
                            setState(240);
                            match(TABLE);
                            setState(241);
                            ((SysColumnsContext) _localctx).tableLike = likePattern();
                        }
                            break;
                        case ANALYZE:
                        case ANALYZED:
                        case CATALOGS:
                        case COLUMNS:
                        case CURRENT_DATE:
                        case CURRENT_TIME:
                        case CURRENT_TIMESTAMP:
                        case DAY:
                        case DEBUG:
                        case EXECUTABLE:
                        case EXPLAIN:
                        case FIRST:
                        case FORMAT:
                        case FULL:
                        case FUNCTIONS:
                        case GRAPHVIZ:
                        case HOUR:
                        case INTERVAL:
                        case LAST:
                        case LIMIT:
                        case MAPPED:
                        case MINUTE:
                        case MONTH:
                        case OPTIMIZED:
                        case PARSED:
                        case PHYSICAL:
                        case PIVOT:
                        case PLAN:
                        case RLIKE:
                        case QUERY:
                        case SCHEMAS:
                        case SECOND:
                        case SHOW:
                        case SYS:
                        case TABLES:
                        case TEXT:
                        case TOP:
                        case TYPE:
                        case TYPES:
                        case VERIFY:
                        case YEAR:
                        case IDENTIFIER:
                        case DIGIT_IDENTIFIER:
                        case TABLE_IDENTIFIER:
                        case QUOTED_IDENTIFIER:
                        case BACKQUOTED_IDENTIFIER: {
                            setState(242);
                            ((SysColumnsContext) _localctx).tableIdent = tableIdentifier();
                        }
                            break;
                        case EOF:
                        case LIKE:
                            break;
                        default:
                            break;
                    }
                    setState(246);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (_la == LIKE) {
                        {
                            setState(245);
                            ((SysColumnsContext) _localctx).columnPattern = likePattern();
                        }
                    }

                }
                    break;
                case 12:
                    _localctx = new SysTypesContext(_localctx);
                    enterOuterAlt(_localctx, 12); {
                    setState(248);
                    match(SYS);
                    setState(249);
                    match(TYPES);
                    setState(254);
                    _errHandler.sync(this);
                    _la = _input.LA(1);
                    if (((((_la - 119)) & ~0x3f) == 0 && ((1L << (_la - 119)) & 1539L) != 0)) {
                        {
                            setState(251);
                            _errHandler.sync(this);
                            _la = _input.LA(1);
                            if (_la == PLUS || _la == MINUS) {
                                {
                                    setState(250);
                                    _la = _input.LA(1);
                                    if (!(_la == PLUS || _la == MINUS)) {
                                        _errHandler.recoverInline(this);
                                    } else {
                                        if (_input.LA(1) == Token.EOF) matchedEOF = true;
                                        _errHandler.reportMatch(this);
                                        consume();
                                    }
                                }
                            }

                            setState(253);
                            ((SysTypesContext) _localctx).type = number();
                        }
                    }

                }
                    break;
            }
        } catch (RecognitionException re) {
            _localctx.exception = re;
            _errHandler.reportError(this, re);
            _errHandler.recover(this, re);
        } finally {
            exitRule();
        }
        return _localctx;
    }