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
Modifier and TypeClassDescriptionstatic interface
Interface to define the configuration for a SQL parser.static class
Deprecated. -
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
Deprecated.static final int
static final com.google.common.collect.ImmutableMap<String,
org.apache.calcite.avatica.util.TimeUnit> Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionstatic SqlParser.Config
config()
Returns a defaultSqlParser.Config
.static SqlParser.ConfigBuilder
Deprecated.static SqlParser.ConfigBuilder
configBuilder
(SqlParser.Config config) Deprecated.Useconfig
, and modify it using its mutator methodsstatic SqlParser
create
(Reader reader, SqlParser.Config config) Creates aSqlParser
to parse the given string using the parser implementation created from givenSqlParserImplFactory
with given quoting syntax and casing policies for identifiers.static SqlParser
Creates aSqlParser
to parse the given string using Calcite's parser implementation.static SqlParser
create
(String sql, SqlParser.Config config) Creates aSqlParser
to parse the given string using the parser implementation created from givenSqlParserImplFactory
with given quoting syntax and casing policies for identifiers.org.apache.calcite.sql.parser.SqlAbstractParserImpl.Metadata
Get the parser metadata.Returns the warnings that were generated by the previous invocation of the parser.Parses a SQL expression.Parses aSELECT
statement.parseQuery
(String sql) Parses aSELECT
statement 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 aSqlParser
to 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 aSqlParser
to parse the given string using the parser implementation created from givenSqlParserImplFactory
with 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 aSqlParser
to parse the given string using the parser implementation created from givenSqlParserImplFactory
with 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 aSELECT
statement.- Returns:
- A
SqlSelect
for a regularSELECT
statement; aSqlBinaryOperator
for aUNION
,INTERSECT
, orEXCEPT
. - Throws:
SqlParseException
- if there is a parse error
-
parseQuery
Parses aSELECT
statement and reuses parser.- Parameters:
sql
- sql to parse- Returns:
- A
SqlSelect
for a regularSELECT
statement; aSqlBinaryOperator
for 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.Metadata
implementation 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.Config
that starts with an existingConfig
.
-
config()