Package org.eigenbase.sql

Provides an SQL parser and object model.


Interface Summary
SqlLiteral.SqlSymbol A value must implement this interface if it is to be embedded as a SqlLiteral of type SYMBOL.
SqlOperatorTable SqlOperatorTable defines a directory interface for enumerating and looking up SQL operators and functions.
SqlWriter A SqlWriter 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.

Class Summary
ExplicitOperatorBinding ExplicitOperatorBinding implements SqlOperatorBinding via an underlying array of known operand types.
SqlAbstractDateTimeLiteral A SQL literal representing a DATE, TIME or TIMESTAMP value.
SqlAbstractStringLiteral Abstract base for chararacter and binary string literals.
SqlAccessType SqlAccessType is represented by a set of allowed access types
SqlAggFunction Abstract base class for the definition of an aggregate function: an operator which aggregates sets of values into a result.
SqlAsOperator The AS operator associates an expression with an alias.
SqlBinaryOperator SqlBinaryOperator is a binary operator.
SqlBinaryStringLiteral A binary (or hexadecimal) string literal.
SqlCall A SqlCall is a call to an operator.
SqlCallBinding SqlCallBinding implements SqlOperatorBinding by analyzing to the operands of a SqlCall with a SqlValidator.
SqlCharStringLiteral A character string literal.
SqlCollation A SqlCollation is an object representing a Collate statement.
SqlDataTypeSpec Represents a SQL data type specification in a parse tree.
SqlDateLiteral A SQL literal representing a DATE value, such as DATE '2004-10-22'.
SqlDelete A SqlDelete is a node of a parse tree which represents a DELETE statement.
SqlDialect SqlDialect encapsulates the differences between dialects of SQL, for the benefit of a SqlWriter.
SqlDynamicParam A SqlDynamicParam represents a dynamic parameter marker in an SQL statement.
SqlExplain A SqlExplain is a node of a parse tree which represents an EXPLAIN PLAN statement.
SqlFunction A SqlFunction is a type of operator which has conventional function-call syntax.
SqlFunctionalOperator SqlFunctionalOperator is a base class for special operators which use functional syntax.
SqlIdentifier A SqlIdentifier 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 A SqlInsert is a node of a parse tree which represents an INSERT statement.
SqlInsertKeyword Defines the keywords which can occur immediately after the "INSERT" keyword.
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 A SqlJdbcFunctionCall is a node of a parse tree which represents a JDBC function call.
SqlJdbcFunctionCall.JdbcToInternalLookupTable Lookup table between JDBC functions and internal representation
SqlJdbcFunctionCall.MakeCall Represent a Strategy Object to create a SqlCall by providing the feature of reording, adding/dropping operands.
SqlJoin A SqlJoin is ...
SqlJoinOperator SqlJoinOperator describes the syntax of the SQL JOIN operator.
SqlKind Enumerates the possible types of SqlNode.
SqlLiteral A SqlLiteral is a constant.
SqlMerge A SqlMerge is a node of a parse tree which represents a MERGE statement.
SqlNode A SqlNode is a SQL parse tree.
SqlNodeList A SqlNodeList is a list of SqlNodes.
SqlNumericLiteral A numeric SQL literal.
SqlOperandCountRange A class that describes how many operands an operator can take.
SqlOperator A SqlOperator 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 an SqlOperator to actual operands, along with any additional information required to validate those operands if needed.
SqlOrderByOperator SqlOrderByOperator is used to represent an ORDER BY on a query other than a SELECT (e.g.
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.
SqlSelect A SqlSelect is a node of a parse tree which represents a select statement.
SqlSelectKeyword Defines the keywords which can occur immediately after the "SELECT" keyword.
SqlSelectOperator An operator describing a query.
SqlSetOperator SqlSetOperator represents a relational set theory operator (UNION, INTERSECT, MINUS).
SqlSpecialOperator Generic operator for nodes with special syntax.
SqlTimeLiteral A SQL literal representing a TIME value, for example TIME '14:33:44.567'.
SqlTimestampLiteral A SQL literal representing a TIMESTAMP value, for example TIMESTAMP '1969-07-21 03:15 GMT'.
SqlUnnestOperator The UNNESToperator.
SqlUpdate A SqlUpdate 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 particular DatabaseMetaData methods; invocations of other methods will fall through to the base class, BarfingInvocationHandler, which will throw an error.
SqlValuesOperator The VALUES operator.
SqlWindow SQL window specifcation.
SqlWindowOperator An operator describing a window specification.

Enum Summary
SqlAccessEnum Enumeration representing different access types
SqlCollation.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.
SqlExplain.Depth The level of abstraction with which to display the plan.
SqlExplainLevel SqlExplainLevel defines detail levels for EXPLAIN PLAN.
SqlFunctionCategory SqlFunctionCategory is an enumeration of the categories of SQL-invoked routines.
SqlIntervalQualifier.TimeUnit Enumeration of time units used to construct an interval.
SqlJoinOperator.ConditionType Enumerates the types of condition in a join expression.
SqlJoinOperator.JoinType Enumerates the types of join.
SqlNullSemantics SqlNullSemantics defines the possible comparison rules for values which might be null.
SqlStateCodes Contains Glossary.Sql2003 SQL state codes.
SqlSyntax Enumeration of possible syntactic types of operators.
SqlWindowOperator.Bound An enumeration of types of bounds in a window: CURRENT ROW, UNBOUNDED PRECEDING, and UNBOUNDED FOLLOWING.
SqlWriter.FrameTypeEnum Enumerates the types of frame.
SqlWriter.SubqueryStyle Style of formatting subqueries.

Package org.eigenbase.sql Description

Provides an SQL parser and object model. This package, and the dependent org.eigenbase.sql.parser package, are independent of the other saffron packages, so may be used standalone.


Revision $Id: //open/dev/farrago/src/org/eigenbase/sql/package.html#7 $
Copyright Copyright (C) 2005-2009 The Eigenbase Project
Copyright (C) 2003-2009 SQLstream, Inc.
Copyright (C) 2005-2009 LucidEra, Inc.
Author Julian Hyde


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:

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 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.


SqlValidator checks that a tree of SqlNodes 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 SqlNodes into a SQL string. A SqlDialect defines how this happens.