ru.yandex.clickhouse.jdbc.parser

## Class ClickHouseSqlParser

- java.lang.Object
- - ru.yandex.clickhouse.jdbc.parser.ClickHouseSqlParser

All Implemented Interfaces:
  ClickHouseSqlParserConstants

    public class ClickHouseSqlParser
    extends Object
    implements ClickHouseSqlParserConstants

### Field Summary

Fields
`Token` `jj_nt` Next token.
`Token` `token` Current token.
`ClickHouseSqlParserTokenManager` `token_source` Generated Token Manager.

### Fields inherited from interface ru.yandex.clickhouse.jdbc.parser.ClickHouseSqlParserConstants

`A, ALL, ALTER, AND, APPLY, ARRAY, ARROW, AS, ASOF, ASTERISK, AT, ATTACH, B, BACK_QUOTE, BACK_QUOTED_NAME, BACK_SLASH, BETWEEN, C, CASE, CHECK, CLUSTER, COLON, COMMA, CONCAT, CREATE, D, DASH, DATABASE, DATABASES, DATE, DAY, DEC_DIGIT, DECIMAL_LITERAL, DEFAULT, DELETE, DESC, DESCRIBE, DETACH, DICTIONARIES, DICTIONARY, DISTINCT, DOLLAR, DOT, DOUBLE_QUOTE, DOUBLE_QUOTED_NAME, DROP, E, ELSE, END, EOF, EQ_DOUBLE, EQ_SINGLE, EXCEPT, EXISTS, EXPLAIN, F, FINAL, FLOATING_LITERAL, FORMAT, FROM, FULL, FUNCTION, G, GE, GLOBAL, GRANT, GROUP, GT, H, HASH, HAVING, HEX_DIGIT, HEXADECIMAL_LITERAL, HOUR, I, IDENTIFIER, IF, ILIKE, IN, INF, INNER, INSERT, INTERVAL, INTO, IS, J, JOIN, K, KILL, L, LBRACE, LBRACKET, LE, LEFT, LETTER, LIKE, LIMIT, LIVE, LPAREN, LT, M, MATERIALIZED, MINUTE, MONTH, MULTI_LINE_COMMENT, N, NAN, NOT, NOT_EQ, NULL, O, OFFSET, ON, OPTIMIZE, OR, ORDER, OUTFILE, P, PERCENT, PLUS, POLICY, PREWHERE, PROFILE, Q, QUARTER, QUERY, QUOTA, R, RBRACE, RBRACKET, RENAME, REPLACE, REVOKE, RIGHT, ROLE, ROW, RPAREN, S, SAMPLE, SECOND, SELECT, SEMICOLON, SET, SETTINGS, SHOW, SINGLE_LINE_COMMENT, SINGLE_QUOTE, SLASH, STRING_LITERAL, SYSTEM, T, TABLE, TABLES, TEMPORARY, THEN, TIES, TIMESTAMP, tokenImage, TOP, TOTALS, TRUNCATE, U, UNDERSCORE, UNION, UPDATE, USE, USER, USING, V, VALUES, VIEW, W, WATCH, WEEK, WHEN, WHERE, WHITESPACE, WITH, X, Y, YEAR, Z, ZERO`

### Constructor Summary

Constructors
Constructor and Description
`ClickHouseSqlParser(ClickHouseSqlParserTokenManager tm)` Constructor with generated Token Manager.
`ClickHouseSqlParser(InputStream stream)` Constructor with InputStream.
`ClickHouseSqlParser(InputStream stream, Charset encoding)` Constructor with InputStream and supplied encoding
`ClickHouseSqlParser(Reader stream)` Constructor with InputStream.
`ClickHouseSqlParser(String sql, ClickHouseProperties properties, ParseHandler handler)`

### Method Summary

All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
`void` `addStatement()`
`Token` `aliasExpr()`
`void` `allColumnsExpr()`
`void` `alterStmt()`
`void` `anyColumnExpr()`
`void` `anyExpr()`
`void` `anyExprList()`
`Token` `anyIdentifier()`
`Token` `anyKeyword()`
`void` `anyNestedExpr()`
`void` `attachStmt()`
`void` `betweenExpr()`
`void` `calcExpr()`
`void` `checkStmt()`
`void` `clusterClause()`
`void` `columnExpr()`
`void` `columnExprList()`
`void` `columnsExpr()`
`void` `createStmt()`
`void` `databaseIdentifier(boolean record)`
`void` `dataClause()`
`Token` `dateLiteral()`
`void` `deleteStmt()`
`void` `describeStmt()`
`void` `detachStmt()`
`void` `disable_tracing()` Disable tracing.
`void` `dropStmt()`
`void` `enable_tracing()` Enable tracing.
`void` `existsStmt()`
`void` `explainStmt()`
`void` `formatPart()`
`void` `functionExpr()`
`ParseException` `generateParseException()` Generate ParseException.
`Token` `getNextToken()`
`Token` `getToken(int index)`
`void` `grantStmt()`
`Token` `identifier()`
`void` `insertStmt()`
`void` `interval()`
`Token` `keyword()`
`void` `killStmt()`
`Token` `literal()`
`void` `macro()`
`void` `nestedExpr()`
`void` `nestedIdentifier()`
`Token` `numberLiteral()`
`void` `operator()`
`void` `optimizeStmt()`
`void` `outfilePart()`
`static ClickHouseSqlStatement[]` `parse(String sql, ClickHouseProperties properties)`
`static ClickHouseSqlStatement[]` `parse(String sql, ClickHouseProperties properties, ParseHandler handler)`
`static ClickHouseSqlStatement` `parseSingleStatement(String sql, ClickHouseProperties properties)` Deprecated. This method will be removed in the near future. Use `parse(String, ClickHouseProperties)` instead.
`static ClickHouseSqlStatement` `parseSingleStatement(String sql, ClickHouseProperties properties, ParseHandler handler)` Deprecated. This method will be removed in the near future. Use `parse(String, ClickHouseProperties, ParseHandler)` instead.
`void` `ReInit(ClickHouseSqlParserTokenManager tm)` Reinitialise
`void` `ReInit(InputStream stream)` Reinitialise
`void` `ReInit(InputStream stream, Charset encoding)` Reinitialise
`void` `ReInit(Reader stream)` Reinitialise
`void` `renameStmt()`
`void` `revokeStmt()`
`void` `selectStmt()`
`void` `setStmt()`
`void` `settingExpr()`
`void` `settingExprList()`
`void` `showStmt()`
`ClickHouseSqlStatement[]` `sql()`
`void` `stmt()`
`void` `stmts()`
`void` `systemStmt()`
`void` `tableClause(boolean record)`
`void` `tableIdentifier(boolean record)`
`void` `topClause()`
`boolean` `trace_enabled()`
`void` `truncateStmt()`
`void` `updateStmt()`
`void` `useStmt()`
`Token` `variable()`
`void` `watchStmt()`
`void` `withClause()`
`void` `withExpr()`
`void` `withTotalPart()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### token_source

    public ClickHouseSqlParserTokenManager token_source

Generated Token Manager.

#### token

    public Token token

Current token.

#### jj_nt

    public Token jj_nt

Next token.

### Constructor Detail

#### ClickHouseSqlParser

    public ClickHouseSqlParser(String sql,
                               ClickHouseProperties properties,
                               ParseHandler handler)

#### ClickHouseSqlParser

    public ClickHouseSqlParser(InputStream stream)

Constructor with InputStream.

Parameters:
  `stream` - input stream

#### ClickHouseSqlParser

    public ClickHouseSqlParser(InputStream stream,
                               Charset encoding)

Constructor with InputStream and supplied encoding

Parameters:
  `stream` - input stream
  `encoding` - charset to be used

#### ClickHouseSqlParser

    public ClickHouseSqlParser(Reader stream)

Constructor with InputStream.

Parameters:
  `stream` - char stream

#### ClickHouseSqlParser

    public ClickHouseSqlParser(ClickHouseSqlParserTokenManager tm)

Constructor with generated Token Manager.

Parameters:
  `tm` - Token manager to use

### Method Detail

#### parseSingleStatement

    public static ClickHouseSqlStatement parseSingleStatement(String sql,
                                                              ClickHouseProperties properties)

Deprecated. This method will be removed in the near future.

Use `parse(String, ClickHouseProperties)` instead.

Parse given SQL.

Parameters:
  `sql` - SQL query
  `properties` - properties
Returns:
  parsed SQL statement

#### parseSingleStatement

    public static ClickHouseSqlStatement parseSingleStatement(String sql,
                                                              ClickHouseProperties properties,
                                                              ParseHandler handler)

Deprecated. This method will be removed in the near future.

Use `parse(String, ClickHouseProperties, ParseHandler)` instead.

Parse given SQL.

Parameters:
  `sql` - SQL query
  `properties` - properties
  `handler` - parse handler
Returns:
  parsed SQL statement

#### parse

    public static ClickHouseSqlStatement[] parse(String sql,
                                                 ClickHouseProperties properties)

#### parse

    public static ClickHouseSqlStatement[] parse(String sql,
                                                 ClickHouseProperties properties,
                                                 ParseHandler handler)

#### addStatement

    public void addStatement()

#### sql

    public final ClickHouseSqlStatement[] sql()
                                       throws ParseException

Throws:
  `ParseException`

#### stmts

    public final void stmts()
                     throws ParseException

Throws:
  `ParseException`

#### stmt

    public final void stmt()
                    throws ParseException

Throws:
  `ParseException`

#### alterStmt

    public final void alterStmt()
                         throws ParseException

Throws:
  `ParseException`

#### clusterClause

    public final void clusterClause()
                             throws ParseException

Throws:
  `ParseException`

#### attachStmt

    public final void attachStmt()
                          throws ParseException

Throws:
  `ParseException`

#### checkStmt

    public final void checkStmt()
                         throws ParseException

Throws:
  `ParseException`

#### createStmt

    public final void createStmt()
                          throws ParseException

Throws:
  `ParseException`

#### deleteStmt

    public final void deleteStmt()
                          throws ParseException

Throws:
  `ParseException`

#### describeStmt

    public final void describeStmt()
                            throws ParseException

Throws:
  `ParseException`

#### detachStmt

    public final void detachStmt()
                          throws ParseException

Throws:
  `ParseException`

#### dropStmt

    public final void dropStmt()
                        throws ParseException

Throws:
  `ParseException`

#### existsStmt

    public final void existsStmt()
                          throws ParseException

Throws:
  `ParseException`

#### explainStmt

    public final void explainStmt()
                           throws ParseException

Throws:
  `ParseException`

#### grantStmt

    public final void grantStmt()
                         throws ParseException

Throws:
  `ParseException`

#### insertStmt

    public final void insertStmt()
                          throws ParseException

Throws:
  `ParseException`

#### dataClause

    public final void dataClause()
                          throws ParseException

Throws:
  `ParseException`

#### killStmt

    public final void killStmt()
                        throws ParseException

Throws:
  `ParseException`

#### optimizeStmt

    public final void optimizeStmt()
                            throws ParseException

Throws:
  `ParseException`

#### renameStmt

    public final void renameStmt()
                          throws ParseException

Throws:
  `ParseException`

#### revokeStmt

    public final void revokeStmt()
                          throws ParseException

Throws:
  `ParseException`

#### selectStmt

    public final void selectStmt()
                          throws ParseException

Throws:
  `ParseException`

#### withClause

    public final void withClause()
                          throws ParseException

Throws:
  `ParseException`

#### topClause

    public final void topClause()
                         throws ParseException

Throws:
  `ParseException`

#### tableClause

    public final void tableClause(boolean record)
                           throws ParseException

Throws:
  `ParseException`

#### setStmt

    public final void setStmt()
                       throws ParseException

Throws:
  `ParseException`

#### showStmt

    public final void showStmt()
                        throws ParseException

Throws:
  `ParseException`

#### systemStmt

    public final void systemStmt()
                          throws ParseException

Throws:
  `ParseException`

#### truncateStmt

    public final void truncateStmt()
                            throws ParseException

Throws:
  `ParseException`

#### updateStmt

    public final void updateStmt()
                          throws ParseException

Throws:
  `ParseException`

#### useStmt

    public final void useStmt()
                       throws ParseException

Throws:
  `ParseException`

#### watchStmt

    public final void watchStmt()
                         throws ParseException

Throws:
  `ParseException`

#### columnExprList

    public final void columnExprList()
                              throws ParseException

Throws:
  `ParseException`

#### withExpr

    public final void withExpr()
                        throws ParseException

Throws:
  `ParseException`

#### columnsExpr

    public final void columnsExpr()
                           throws ParseException

Throws:
  `ParseException`

#### allColumnsExpr

    public final void allColumnsExpr()
                              throws ParseException

Throws:
  `ParseException`

#### nestedExpr

    public final void nestedExpr()
                          throws ParseException

Throws:
  `ParseException`

#### calcExpr

    public final void calcExpr()
                        throws ParseException

Throws:
  `ParseException`

#### betweenExpr

    public final void betweenExpr()
                           throws ParseException

Throws:
  `ParseException`

#### functionExpr

    public final void functionExpr()
                            throws ParseException

Throws:
  `ParseException`

#### columnExpr

    public final void columnExpr()
                          throws ParseException

Throws:
  `ParseException`

#### formatPart

    public final void formatPart()
                          throws ParseException

Throws:
  `ParseException`

#### outfilePart

    public final void outfilePart()
                           throws ParseException

Throws:
  `ParseException`

#### withTotalPart

    public final void withTotalPart()
                             throws ParseException

Throws:
  `ParseException`

#### anyExprList

    public final void anyExprList()
                           throws ParseException

Throws:
  `ParseException`

#### anyExpr

    public final void anyExpr()
                       throws ParseException

Throws:
  `ParseException`

#### anyNestedExpr

    public final void anyNestedExpr()
                             throws ParseException

Throws:
  `ParseException`

#### anyColumnExpr

    public final void anyColumnExpr()
                             throws ParseException

Throws:
  `ParseException`

#### aliasExpr

    public final Token aliasExpr()
                          throws ParseException

Throws:
  `ParseException`

#### nestedIdentifier

    public final void nestedIdentifier()
                                throws ParseException

Throws:
  `ParseException`

#### tableIdentifier

    public final void tableIdentifier(boolean record)
                               throws ParseException

Throws:
  `ParseException`

#### databaseIdentifier

    public final void databaseIdentifier(boolean record)
                                  throws ParseException

Throws:
  `ParseException`

#### settingExprList

    public final void settingExprList()
                               throws ParseException

Throws:
  `ParseException`

#### settingExpr

    public final void settingExpr()
                           throws ParseException

Throws:
  `ParseException`

#### anyIdentifier

    public final Token anyIdentifier()
                              throws ParseException

Throws:
  `ParseException`

#### identifier

    public final Token identifier()
                           throws ParseException

Throws:
  `ParseException`

#### interval

    public final void interval()
                        throws ParseException

Throws:
  `ParseException`

#### literal

    public final Token literal()
                        throws ParseException

Throws:
  `ParseException`

#### dateLiteral

    public final Token dateLiteral()
                            throws ParseException

Throws:
  `ParseException`

#### numberLiteral

    public final Token numberLiteral()
                              throws ParseException

Throws:
  `ParseException`

#### operator

    public final void operator()
                        throws ParseException

Throws:
  `ParseException`

#### macro

    public final void macro()
                     throws ParseException

Throws:
  `ParseException`

#### variable

    public final Token variable()
                         throws ParseException

Throws:
  `ParseException`

#### anyKeyword

    public final Token anyKeyword()
                           throws ParseException

Throws:
  `ParseException`

#### keyword

    public final Token keyword()
                        throws ParseException

Throws:
  `ParseException`

#### ReInit

    public void ReInit(InputStream stream)

Reinitialise

Parameters:
  `stream` - input stream

#### ReInit

    public void ReInit(InputStream stream,
                       Charset encoding)

Reinitialise

Parameters:
  `stream` - input stream
  `encoding` - charset to be used

#### ReInit

    public void ReInit(Reader stream)

Reinitialise

Parameters:
  `stream` - char stream

#### ReInit

    public void ReInit(ClickHouseSqlParserTokenManager tm)

Reinitialise

Parameters:
  `tm` - Token manager to use

#### getNextToken

    public final Token getNextToken()

Returns:
  the next Token.

#### getToken

    public final Token getToken(int index)

Parameters:
  `index` - index to be retrieved
Returns:
  the specific Token.

#### generateParseException

    public ParseException generateParseException()

Generate ParseException.

#### trace_enabled

    public final boolean trace_enabled()

Returns:
  Always `false`.

#### enable_tracing

    public final void enable_tracing()

Enable tracing.

#### disable_tracing

    public final void disable_tracing()

Disable tracing.