Package org.apache.calcite.sql.parser
Class SqlParser
java.lang.Object
org.apache.calcite.sql.parser.SqlParser
A
SqlParser parses a SQL statement.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceInterface to define the configuration for a SQL parser.static classDeprecated. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final booleanDeprecated.static final intstatic final com.google.common.collect.ImmutableMap<String,org.apache.calcite.avatica.util.TimeUnit> Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic SqlParser.Configconfig()Returns a defaultSqlParser.Config.static SqlParser.ConfigBuilderDeprecated.static SqlParser.ConfigBuilderconfigBuilder(SqlParser.Config config) Deprecated.Useconfig, and modify it using its mutator methodsstatic SqlParsercreate(Reader reader, SqlParser.Config config) Creates aSqlParserto parse the given string using the parser implementation created from givenSqlParserImplFactorywith given quoting syntax and casing policies for identifiers.static SqlParserCreates aSqlParserto parse the given string using Calcite's parser implementation.static SqlParsercreate(String sql, SqlParser.Config config) Creates aSqlParserto parse the given string using the parser implementation created from givenSqlParserImplFactorywith given quoting syntax and casing policies for identifiers.org.apache.calcite.sql.parser.SqlAbstractParserImpl.MetadataGet the parser metadata.Returns the warnings that were generated by the previous invocation of the parser.Parses a SQL expression.Parses aSELECTstatement.parseQuery(String sql) Parses aSELECTstatement and reuses parser.Parses an SQL statement.Parses a list of SQL statements separated by semicolon.
-
Field Details
-
DEFAULT_IDENTIFIER_MAX_LENGTH
public static final int DEFAULT_IDENTIFIER_MAX_LENGTH- See Also:
-
DEFAULT_IDENTIFIER_TIMEUNIT_MAP
@Deprecated public static final com.google.common.collect.ImmutableMap<String,org.apache.calcite.avatica.util.TimeUnit> DEFAULT_IDENTIFIER_TIMEUNIT_MAPDeprecated.Default value ofSqlParser.Config.timeUnitCodes(). The map is empty, which means that there are no abbreviations other than the time unit names ("YEAR", "SECOND", etc.) -
DEFAULT_ALLOW_BANG_EQUAL
Deprecated.
-
-
Method Details
-
create
Creates aSqlParserto parse the given string using Calcite's parser implementation.The default lexical policy is similar to Oracle.
- Parameters:
s- An SQL statement or expression to parse.- Returns:
- A parser
- See Also:
-
create
Creates aSqlParserto parse the given string using the parser implementation created from givenSqlParserImplFactorywith given quoting syntax and casing policies for identifiers.- Parameters:
sql- A SQL statement or expression to parseconfig- The parser configuration (identifier max length, etc.)- Returns:
- A parser
-
create
Creates aSqlParserto parse the given string using the parser implementation created from givenSqlParserImplFactorywith given quoting syntax and casing policies for identifiers.Unlike
create(java.lang.String, org.apache.calcite.sql.parser.SqlParser.Config), the parser is not able to return the original query string, but will instead return "?".- Parameters:
reader- The source for the SQL statement or expression to parseconfig- The parser configuration (identifier max length, etc.)- Returns:
- A parser
-
parseExpression
Parses a SQL expression.- Throws:
SqlParseException- if there is a parse error
-
parseQuery
Parses aSELECTstatement.- Returns:
- A
SqlSelectfor a regularSELECTstatement; aSqlBinaryOperatorfor aUNION,INTERSECT, orEXCEPT. - Throws:
SqlParseException- if there is a parse error
-
parseQuery
Parses aSELECTstatement and reuses parser.- Parameters:
sql- sql to parse- Returns:
- A
SqlSelectfor a regularSELECTstatement; aSqlBinaryOperatorfor aUNION,INTERSECT, orEXCEPT. - Throws:
SqlParseException- if there is a parse error
-
parseStmt
Parses an SQL statement.- Returns:
- top-level SqlNode representing stmt
- Throws:
SqlParseException- if there is a parse error
-
parseStmtList
Parses a list of SQL statements separated by semicolon. The semicolon is required between statements, but is optional at the end.- Returns:
- list of SqlNodeList representing the list of SQL statements
- Throws:
SqlParseException- if there is a parse error
-
getMetadata
public org.apache.calcite.sql.parser.SqlAbstractParserImpl.Metadata getMetadata()Get the parser metadata.- Returns:
SqlAbstractParserImpl.Metadataimplementation of underlying parser.
-
getWarnings
Returns the warnings that were generated by the previous invocation of the parser. -
config
Returns a defaultSqlParser.Config. -
configBuilder
Deprecated.Useconfig()Builder for aSqlParser.Config. -
configBuilder
Deprecated.Useconfig, and modify it using its mutator methodsBuilder for aSqlParser.Configthat starts with an existingConfig.
-
config()