Package org.apache.calcite.sql
This package, and the dependent org.apache.calcite.sql.parser
package, are independent of the other Calcite packages, so may be used
standalone.
Parser
SqlParser
parses a SQL string to a
parse tree. It only performs the most basic syntactic validation.
Object model
Every node in the parse tree is a SqlNode
.
Sub-types are:
SqlLiteral
represents a boolean, numeric, string, or date constant, or the valueNULL
.SqlIdentifier
represents an identifier, such asEMPNO
oremp.deptno
.SqlCall
is a call to an operator or function. By means of special operators, we can use this construct to represent virtually every non-leaf node in the tree. For example, aselect
statement is a call to the 'select' operator.SqlNodeList
is a list of nodes.
A SqlOperator
describes the behavior of a
node in the tree, such as how to un-parse a
SqlCall
into a SQL string. It is
important to note that operators are metadata, not data: there is only
one SqlOperator
instance representing the '=' operator, even
though there may be many calls to it.
SqlOperator
has several derived classes which make it easy to
define new operators: SqlFunction
,
SqlBinaryOperator
,
SqlPrefixOperator
,
SqlPostfixOperator
.
And there are singleton classes for special syntactic constructs
SqlSelectOperator
and SqlJoin.SqlJoinOperator
. (These
special operators even have their own sub-types of
SqlCall
:
SqlSelect
and
SqlJoin
.)
A SqlOperatorTable
is a collection of
operators. By supplying your own operator table, you can customize the
dialect of SQL without modifying the parser.
Validation
SqlValidator
checks that
a tree of SqlNode
s is
semantically valid. You supply a
SqlOperatorTable
to describe the available
functions and operators, and a
SqlValidatorCatalogReader
for
access to the database's catalog.
Generating SQL
A SqlWriter
converts a tree of
SqlNode
s into a SQL string. A
SqlDialect
defines how this happens.
-
Interface Summary Interface Description SqlDialect.Context Information for creating a dialect.SqlDialectFactory Creates aSqlDialect
appropriate for a given database metadata object.SqlExecutableStatement Mix-in interface forSqlNode
that allows DDL commands to be executed directly.SqlJdbcFunctionCall.MakeCall Converts a call to a JDBC function to a call to a regular function.SqlLiteral.SqlSymbol Deprecated. SqlOperandCountRange A class that describes how many operands an operator can take.SqlOperatorTable SqlOperatorTable defines a directory interface for enumerating and looking up SQL operators and functions.SqlSpecialOperator.TokenSequence List of tokens: the input to a parser.SqlSplittableAggFunction Aggregate function that can be split into partial aggregates.SqlSplittableAggFunction.Registry<E> Collection in which one can register an element.SqlWriter ASqlWriter
is the target to construct a SQL statement from a parse tree.SqlWriter.Frame A Frame is a piece of generated text which shares a common indentation level.SqlWriter.FrameType Frame type. -
Class Summary Class Description ExplicitOperatorBinding ExplicitOperatorBinding
implementsSqlOperatorBinding
via an underlying array of known operand types.SqlAbstractDateTimeLiteral A SQL literal representing a DATE, TIME or TIMESTAMP value.SqlAbstractStringLiteral Abstract base for character and binary string literals.SqlAccessType SqlAccessType is represented by a set of allowed access typesSqlAggFunction Abstract base class for the definition of an aggregate function: an operator which aggregates sets of values into a result.SqlAlter Base class for an ALTER statements parse tree nodes.SqlAsOperator TheAS
operator associates an expression with an alias.SqlBasicCall Implementation ofSqlCall
that keeps its operands in an array.SqlBinaryOperator SqlBinaryOperator
is a binary operator.SqlBinaryStringLiteral A binary (or hexadecimal) string literal.SqlCall ASqlCall
is a call to anoperator
.SqlCallBinding SqlCallBinding
implementsSqlOperatorBinding
by analyzing to the operands of aSqlCall
with aSqlValidator
.SqlCharStringLiteral A character string literal.SqlCollation ASqlCollation
is an object representing aCollate
statement.SqlCreate Base class for an CREATE statements parse tree nodes.SqlDataTypeSpec Represents a SQL data type specification in a parse tree.SqlDateLiteral A SQL literal representing a DATE value, such asDATE '2004-10-22'
.SqlDdl Base class for CREATE, DROP and other DDL statements.SqlDelete ASqlDelete
is a node of a parse tree which represents a DELETE statement.SqlDescribeSchema ASqlDescribeSchema
is a node of a parse tree that represents aDESCRIBE SCHEMA
statement.SqlDescribeTable ASqlDescribeTable
is a node of a parse tree that represents aDESCRIBE TABLE
statement.SqlDialect SqlDialect
encapsulates the differences between dialects of SQL.SqlDialect.ContextImpl Implementation of Context.SqlDialect.FakeUtil A few utility functions copied from org.apache.calcite.util.Util.SqlDialectFactoryImpl The default implementation of aSqlDialectFactory
.SqlDrop Base class for an DROP statements parse tree nodes.SqlDynamicParam ASqlDynamicParam
represents a dynamic parameter marker in an SQL statement.SqlExplain ASqlExplain
is a node of a parse tree which represents an EXPLAIN PLAN statement.SqlFilterOperator An operator that applies a filter before rows are included in an aggregate function.SqlFunction ASqlFunction
is a type of operator which has conventional function-call syntax.SqlFunctionalOperator SqlFunctionalOperator is a base class for special operators which use functional syntax.SqlGroupedWindowFunction SQL function that computes keys by which rows can be partitioned and aggregated.SqlIdentifier ASqlIdentifier
is an identifier, possibly compound.SqlInfixOperator A generalization of a binary operator to involve several (two or more) arguments, and keywords between each pair of arguments.SqlInsert ASqlInsert
is a node of a parse tree which represents an INSERT statement.SqlInternalOperator Generic operator for nodes with internal syntax.SqlIntervalLiteral A SQL literal representing a time interval.SqlIntervalLiteral.IntervalValue A Interval value.SqlIntervalQualifier Represents an INTERVAL qualifier.SqlJdbcFunctionCall ASqlJdbcFunctionCall
is a node of a parse tree which represents a JDBC function call.SqlJdbcFunctionCall.JdbcToInternalLookupTable Lookup table between JDBC functions and internal representationSqlJdbcFunctionCall.PermutingMakeCall Implementation ofSqlJdbcFunctionCall.MakeCall
that can re-order or ignore operands.SqlJdbcFunctionCall.SimpleMakeCall Converter that calls a built-in function with the same arguments.SqlJoin Parse tree node representing aJOIN
clause.SqlJoin.SqlJoinOperator SqlJoinOperator
describes the syntax of the SQLJOIN
operator.SqlLateralOperator An operator describing a LATERAL specification.SqlLiteral ASqlLiteral
is a constant.SqlMatchRecognize SqlNode for MATCH_RECOGNIZE clause.SqlMatchRecognize.SqlMatchRecognizeOperator An operator describing a MATCH_RECOGNIZE specification.SqlMerge ASqlMerge
is a node of a parse tree which represents a MERGE statement.SqlNode ASqlNode
is a SQL parse tree.SqlNodeList ASqlNodeList
is a list ofSqlNode
s.SqlNumericLiteral A numeric SQL literal.SqlOperator ASqlOperator
is a type of node in a SQL parse tree (it is NOT a node in a SQL parse tree).SqlOperatorBinding SqlOperatorBinding
represents the binding of anSqlOperator
to actual operands, along with any additional information required to validate those operands if needed.SqlOrderBy Parse tree node that represents anORDER BY
on a query other than aSELECT
(e.g.SqlOrderBy.Operator Definition ofORDER BY
operator.SqlOverOperator An operator describing a window function specification.SqlPostfixOperator A postfix unary operator.SqlPrefixOperator A unary operator.SqlProcedureCallOperator SqlProcedureCallOperator represents the CALL statement.SqlRankFunction Operator which aggregates sets of values into a result.SqlSampleSpec Specification of a SQL sample.SqlSampleSpec.SqlSubstitutionSampleSpec Sample specification that orders substitution.SqlSampleSpec.SqlTableSampleSpec Sample specification.SqlSelect ASqlSelect
is a node of a parse tree which represents a select statement.SqlSelectOperator An operator describing a query.SqlSetOperator SqlSetOperator represents a relational set theory operator (UNION, INTERSECT, MINUS).SqlSetOption SQL parse tree node to representSET
andRESET
statements, optionally preceded byALTER SYSTEM
orALTER SESSION
.SqlSpecialOperator Generic operator for nodes with special syntax.SqlSplittableAggFunction.AbstractSumSplitter Common splitting strategy forSUM
andSUM0
functions.SqlSplittableAggFunction.CountSplitter Splitting strategy forCOUNT
.SqlSplittableAggFunction.SelfSplitter Aggregate function that splits into two applications of itself.SqlSplittableAggFunction.Sum0Splitter Splitting strategy forSUM0
function.SqlSplittableAggFunction.SumSplitter Splitting strategy forSUM
function.SqlTimeLiteral A SQL literal representing a TIME value, for exampleTIME '14:33:44.567'
.SqlTimestampLiteral A SQL literal representing a TIMESTAMP value, for exampleTIMESTAMP '1969-07-21 03:15 GMT'
.SqlUnnestOperator TheUNNEST
operator.SqlUnresolvedFunction Placeholder for an unresolved function.SqlUpdate ASqlUpdate
is a node of a parse tree which represents an UPDATE statement.SqlUtil Contains utility functions related to SQL parsing, all static.SqlUtil.DatabaseMetaDataInvocationHandler Handles particularDatabaseMetaData
methods; invocations of other methods will fall through to the base class,BarfingInvocationHandler
, which will throw an error.SqlUtil.Genealogist Walks over aSqlNode
tree and returns the ancestry stack when it finds a given node.SqlValuesOperator TheVALUES
operator.SqlWindow SQL window specification.SqlWindow.SqlWindowOperator An operator describing a window specification.SqlWith The WITH clause of a query.SqlWith.SqlWithOperator SqlWithOperator is used to represent a WITH clause of a query.SqlWithinGroupOperator An operator that applies a sort operation before rows are included in an aggregate function.SqlWithItem An item in a WITH clause of a query.SqlWithItem.SqlWithItemOperator SqlWithItemOperator is used to represent an item in a WITH clause of a query. -
Enum Summary Enum Description JoinConditionType Enumerates the types of condition in a join expression.JoinType Enumerates the types of join.SemiJoinType Enumeration representing different join types used in correlation relations.SqlAccessEnum Enumeration representing different access typesSqlCollation.Coercibility A <character value expression> consisting of a column reference has the coercibility characteristic Implicit, with collating sequence as defined when the column was created.SqlDialect.CalendarPolicy Whether this JDBC driver needs you to pass a Calendar object to methods such asResultSet.getTimestamp(int, java.util.Calendar)
.SqlDialect.DatabaseProduct Rough list of flavors of database.SqlExplain.Depth The level of abstraction with which to display the plan.SqlExplainFormat Output format forEXPLAIN PLAN
statement.SqlExplainLevel SqlExplainLevel defines detail levels for EXPLAIN PLAN.SqlFunctionCategory Enumeration of the categories of SQL-invoked routines.SqlFunctionCategory.Property Property of a SqlFunctionCategory.SqlInsertKeyword Defines the keywords that can occur immediately after the "INSERT" keyword.SqlJdbcDataTypeName Defines the name of the types which can occur as a type argument in a JDBC{fn CONVERT(value, type)}
function.SqlJsonConstructorNullClause Indicating that how do Json constructors handle nullSqlJsonEmptyOrError Flag to indicate if the json value is missing or an error is thrown where EmptyOrErrorBehavior is invoked.SqlJsonEncoding Supported json encodings that could be passed to aJsonValueExpression
.SqlJsonExistsErrorBehavior Categorizing Json exists error behaviors.SqlJsonQueryEmptyOrErrorBehavior Categorizing Json query empty or error behaviors.SqlJsonQueryWrapperBehavior How json query function handle array result.SqlJsonValueEmptyOrErrorBehavior Categorizing Json value empty or error behaviors.SqlKind Enumerates the possible types ofSqlNode
.SqlMatchRecognize.AfterOption Options forAFTER MATCH
clause.SqlMatchRecognize.RowsPerMatchOption Options forROWS PER MATCH
.SqlNullSemantics SqlNullSemantics defines the possible comparison rules for values which might be null.SqlSelectKeyword Defines the keywords which can occur immediately after the "SELECT" keyword.SqlStateCodes Deprecated. Useorg.apache.calcite.avatica.SqlState
SqlSyntax Enumeration of possible syntactic types ofoperators
.SqlWindow.Bound An enumeration of types of bounds in a window:CURRENT ROW
,UNBOUNDED PRECEDING
, andUNBOUNDED FOLLOWING
.SqlWriter.FrameTypeEnum Enumerates the types of frame.SqlWriter.SubQueryStyle Style of formatting sub-queries.