Interface SqlConformance
- All Known Implementing Classes:
SqlAbstractConformance
,SqlConformanceEnum
,SqlDelegatingConformance
For most purposes, one of the built-in compatibility modes in enum
SqlConformanceEnum
will suffice.
If you wish to implement this interface to build your own conformance,
we strongly recommend that you extend SqlAbstractConformance
,
or use a SqlDelegatingConformance
,
so that you won't be broken by future changes.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final SqlConformanceEnum
Deprecated.static final SqlConformanceEnum
Deprecated.static final SqlConformanceEnum
Deprecated.static final SqlConformanceEnum
Deprecated.static final SqlConformanceEnum
Deprecated.static final SqlConformanceEnum
Deprecated.static final SqlConformanceEnum
Deprecated. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Whether directly alias array items in UNNEST.boolean
Whether this dialect allows character literals as column aliases.boolean
Whether to allow SQL syntax "ROW(expr1, expr2, expr3)
".boolean
Whether to allow mixing table columns with extended columns inINSERT
(orUPSERT
).boolean
Whether TRIM should support more than one trim character.boolean
Whether to allow geo-spatial extensions, including the GEOMETRY type.boolean
Whether to allow hyphens in an unquoted table name.boolean
Whether to allow lenient type coercions.boolean
Whether to allow parentheses to be specified in calls to niladic functions and procedures (that is, functions and procedures with no parameters).boolean
Whether interval literals should allow plural time units such as "YEARS" and "DAYS" in interval literals.boolean
Whether to allow a qualified common column in a query that has a NATURAL join or a join with a USING clause.boolean
WhetherCROSS APPLY
andOUTER APPLY
operators are allowed in the parser.boolean
Whether the bang-equal token != is allowed as an alternative to <> in the parser.boolean
WhetherFROM
clause is required in aSELECT
statement.boolean
Whether to allow aliases from theSELECT
clause to be used as column names in theGROUP BY
clause.boolean
WhetherGROUP BY 2
is interpreted to mean 'group by the 2nd column in the select list'.boolean
Whether to allow aliases from theSELECT
clause to be used as column names in theHAVING
clause.boolean
Whether to allowINSERT
(orUPSERT
) with no column list but fewer values than the target table.boolean
Whether this dialect supports features from a wide variety of dialects.boolean
Whether to allow the SQL syntax "LIMIT start, count
".boolean
WhetherMINUS
is allowed as an alternative toEXCEPT
in the parser.boolean
Whether to allow the SQL syntax "OFFSET start LIMIT count
" (that is,OFFSET
beforeLIMIT
, in addition toLIMIT
beforeOFFSET
andOFFSET
beforeFETCH
).boolean
Whether the "%" operator is allowed by the parser as an alternative to themod
function.boolean
Whether 'ORDER BY x
' is interpreted to mean 'sort by the select list item whose alias is x' even if there is a column called x.boolean
Whether "empno" is invalid in "select empno as x from emp order by empno" because the alias "x" obscures it.boolean
Whether 'ORDER BY 2
' is interpreted to mean 'sort by the 2nd column in the select list'.boolean
WhetherVALUE
is allowed as an alternative toVALUES
in the parser.Controls the behavior of operators that are part of Standard SQL but nevertheless have different behavior in different databases.boolean
Whether the least restrictive type of a number of CHAR types of different lengths should be a VARCHAR type.boolean
Whether to split a quoted table name.
-
Field Details
-
DEFAULT
Deprecated.Short-cut forSqlConformanceEnum.DEFAULT
. -
STRICT_92
Deprecated.Short-cut forSqlConformanceEnum.STRICT_92
. -
STRICT_99
Deprecated.Short-cut forSqlConformanceEnum.STRICT_99
. -
PRAGMATIC_99
Deprecated.Short-cut forSqlConformanceEnum.PRAGMATIC_99
. -
ORACLE_10
Deprecated.Short-cut forSqlConformanceEnum.ORACLE_10
. -
STRICT_2003
Deprecated.Short-cut forSqlConformanceEnum.STRICT_2003
. -
PRAGMATIC_2003
Deprecated.Short-cut forSqlConformanceEnum.PRAGMATIC_2003
.
-
-
Method Details
-
isLiberal
boolean isLiberal()Whether this dialect supports features from a wide variety of dialects. This is enabled for the Babel parser, disabled otherwise. -
allowCharLiteralAlias
boolean allowCharLiteralAlias()Whether this dialect allows character literals as column aliases.For example,
SELECT empno, sal + comm AS 'remuneration' FROM Emp
Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.BIG_QUERY
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
,SqlConformanceEnum.SQL_SERVER_2008
; false otherwise. -
isGroupByAlias
boolean isGroupByAlias()Whether to allow aliases from theSELECT
clause to be used as column names in theGROUP BY
clause.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.BIG_QUERY
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
; false otherwise. -
isGroupByOrdinal
boolean isGroupByOrdinal()WhetherGROUP BY 2
is interpreted to mean 'group by the 2nd column in the select list'.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.BIG_QUERY
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
,SqlConformanceEnum.PRESTO
; false otherwise. -
isHavingAlias
boolean isHavingAlias()Whether to allow aliases from theSELECT
clause to be used as column names in theHAVING
clause.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.BIG_QUERY
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
; false otherwise. -
isSortByOrdinal
boolean isSortByOrdinal()Whether 'ORDER BY 2
' is interpreted to mean 'sort by the 2nd column in the select list'.Among the built-in conformance levels, true in
SqlConformanceEnum.DEFAULT
,SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
,SqlConformanceEnum.ORACLE_10
,SqlConformanceEnum.ORACLE_12
,SqlConformanceEnum.PRAGMATIC_99
,SqlConformanceEnum.PRAGMATIC_2003
,SqlConformanceEnum.PRESTO
,SqlConformanceEnum.SQL_SERVER_2008
,SqlConformanceEnum.STRICT_92
; false otherwise. -
isSortByAlias
boolean isSortByAlias()Whether 'ORDER BY x
' is interpreted to mean 'sort by the select list item whose alias is x' even if there is a column called x.Among the built-in conformance levels, true in
SqlConformanceEnum.DEFAULT
,SqlConformanceEnum.BABEL
,SqlConformanceEnum.BIG_QUERY
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
,SqlConformanceEnum.ORACLE_10
,SqlConformanceEnum.ORACLE_12
,SqlConformanceEnum.SQL_SERVER_2008
,SqlConformanceEnum.STRICT_92
; false otherwise. -
isSortByAliasObscures
boolean isSortByAliasObscures()Whether "empno" is invalid in "select empno as x from emp order by empno" because the alias "x" obscures it.Among the built-in conformance levels, true in
SqlConformanceEnum.STRICT_92
; false otherwise. -
isFromRequired
boolean isFromRequired()WhetherFROM
clause is required in aSELECT
statement.Among the built-in conformance levels, true in
SqlConformanceEnum.ORACLE_10
,SqlConformanceEnum.ORACLE_12
,SqlConformanceEnum.STRICT_92
,SqlConformanceEnum.STRICT_99
,SqlConformanceEnum.STRICT_2003
; false otherwise. -
splitQuotedTableName
boolean splitQuotedTableName()Whether to split a quoted table name. If true,`x.y.z`
is parsed as if the user had written`x`.`y`.`z`
.Among the built-in conformance levels, true in
SqlConformanceEnum.BIG_QUERY
; false otherwise. -
allowHyphenInUnquotedTableName
boolean allowHyphenInUnquotedTableName()Whether to allow hyphens in an unquoted table name.If true,
SELECT * FROM foo-bar.baz-buzz
is valid, and is parsed as if the user had writtenSELECT * FROM `foo-bar`.`baz-buzz`
.Among the built-in conformance levels, true in
SqlConformanceEnum.BIG_QUERY
; false otherwise. -
isBangEqualAllowed
boolean isBangEqualAllowed()Whether the bang-equal token != is allowed as an alternative to <> in the parser.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
,SqlConformanceEnum.ORACLE_10
,SqlConformanceEnum.ORACLE_12
,SqlConformanceEnum.PRESTO
; false otherwise. -
isPercentRemainderAllowed
boolean isPercentRemainderAllowed()Whether the "%" operator is allowed by the parser as an alternative to themod
function.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
,SqlConformanceEnum.PRESTO
; false otherwise. -
isMinusAllowed
boolean isMinusAllowed()WhetherMINUS
is allowed as an alternative toEXCEPT
in the parser.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.ORACLE_10
,SqlConformanceEnum.ORACLE_12
; false otherwise.Note: MySQL does not support
MINUS
orEXCEPT
(as of version 5.5). -
isApplyAllowed
boolean isApplyAllowed()WhetherCROSS APPLY
andOUTER APPLY
operators are allowed in the parser.APPLY
invokes a table-valued function for each row returned by a table expression. It is syntactic sugar:SELECT * FROM emp CROSS APPLY TABLE(promote(empno)
is equivalent to
SELECT * FROM emp CROSS JOIN LATERAL TABLE(promote(empno)
SELECT * FROM emp OUTER APPLY TABLE(promote(empno)
is equivalent to
SELECT * FROM emp LEFT JOIN LATERAL TABLE(promote(empno)
ON true
Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.ORACLE_12
,SqlConformanceEnum.SQL_SERVER_2008
; false otherwise. -
isInsertSubsetColumnsAllowed
boolean isInsertSubsetColumnsAllowed()Whether to allowINSERT
(orUPSERT
) with no column list but fewer values than the target table.The N values provided are assumed to match the first N columns of the table, and for each of the remaining columns, the default value of the column is used. It is an error if any of these columns has no default value.
The default value of a column is specified by the
DEFAULT
clause in theCREATE TABLE
statement, or isNULL
if the column is not declaredNOT NULL
.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.PRAGMATIC_99
,SqlConformanceEnum.PRAGMATIC_2003
; false otherwise. -
allowAliasUnnestItems
boolean allowAliasUnnestItems()Whether directly alias array items in UNNEST.E.g. in UNNEST(a_array, b_array) AS T(a, b), a and b will be aliases of elements in a_array and b_array respectively.
Without this flag set, T will be the alias of the element in a_array and a, b will be the top level fields of T if T is a STRUCT type.
Among the built-in conformance levels, true in
SqlConformanceEnum.PRESTO
; false otherwise. -
allowNiladicParentheses
boolean allowNiladicParentheses()Whether to allow parentheses to be specified in calls to niladic functions and procedures (that is, functions and procedures with no parameters).For example,
CURRENT_DATE
is a niladic system function. In standard SQL it must be invoked without parentheses:VALUES CURRENT_DATE
If
allowNiladicParentheses
, the following syntax is also valid:VALUES CURRENT_DATE()
Of the popular databases, MySQL, Apache Phoenix and VoltDB allow this behavior; Apache Hive, HSQLDB, IBM DB2, Microsoft SQL Server, Oracle, PostgreSQL do not.
Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
; false otherwise. -
allowExplicitRowValueConstructor
boolean allowExplicitRowValueConstructor()Whether to allow SQL syntax "ROW(expr1, expr2, expr3)
".The equivalent syntax in standard SQL is "
(expr1, expr2, expr3)
".Standard SQL does not allow this because the type is not well-defined. However, PostgreSQL allows this behavior.
Standard SQL allows row expressions in other contexts, for instance inside
VALUES
clause.Among the built-in conformance levels, true in
SqlConformanceEnum.DEFAULT
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.PRESTO
; false otherwise. -
allowExtend
boolean allowExtend()Whether to allow mixing table columns with extended columns inINSERT
(orUPSERT
).For example, suppose that the declaration of table
T
has columnsA
andB
, and you want to insert data of columnC INTEGER
not present in the table declaration as an extended column. You can specify the columns in anINSERT
statement as follows:INSERT INTO T (A, B, C INTEGER) VALUES (1, 2, 3)
Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
; false otherwise. -
isLimitStartCountAllowed
boolean isLimitStartCountAllowed()Whether to allow the SQL syntax "LIMIT start, count
".The equivalent syntax in standard SQL is "
OFFSET start ROW FETCH FIRST count ROWS ONLY
", and in PostgreSQL "LIMIT count OFFSET start
".MySQL and CUBRID allow this behavior.
Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
; false otherwise. -
isOffsetLimitAllowed
boolean isOffsetLimitAllowed()Whether to allow the SQL syntax "OFFSET start LIMIT count
" (that is,OFFSET
beforeLIMIT
, in addition toLIMIT
beforeOFFSET
andOFFSET
beforeFETCH
).The equivalent syntax in standard SQL is "
OFFSET start ROW FETCH FIRST count ROWS ONLY
".Trino allows this behavior.
Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
; false otherwise. -
allowGeometry
boolean allowGeometry()Whether to allow geo-spatial extensions, including the GEOMETRY type.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
,SqlConformanceEnum.PRESTO
,SqlConformanceEnum.SQL_SERVER_2008
; false otherwise. -
shouldConvertRaggedUnionTypesToVarying
boolean shouldConvertRaggedUnionTypesToVarying()Whether the least restrictive type of a number of CHAR types of different lengths should be a VARCHAR type. And similarly BINARY to VARBINARY.For example, consider the query
SELECT 'abcde' UNION SELECT 'xyz'
The input columns have types
CHAR(5)
andCHAR(3)
, and we need a result type that is large enough for both:- Under strict SQL:2003 behavior, its column has type
CHAR(5)
, and the value in the second row will have trailing spaces. - With lenient behavior, its column has type
VARCHAR(5)
, and the values have no trailing spaces.
Among the built-in conformance levels, true in
SqlConformanceEnum.PRAGMATIC_99
,SqlConformanceEnum.PRAGMATIC_2003
,SqlConformanceEnum.MYSQL_5
,SqlConformanceEnum.ORACLE_10
,SqlConformanceEnum.ORACLE_12
,SqlConformanceEnum.PRESTO
,SqlConformanceEnum.SQL_SERVER_2008
; false otherwise. - Under strict SQL:2003 behavior, its column has type
-
allowExtendedTrim
boolean allowExtendedTrim()Whether TRIM should support more than one trim character.For example, consider the query
SELECT TRIM('eh' FROM 'hehe__hehe')
Under strict behavior, if the length of trim character is not 1, TRIM throws an exception, and the query fails. However many implementations (in databases such as MySQL and SQL Server) trim all the characters, resulting in a return value of '__'.
Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
,SqlConformanceEnum.SQL_SERVER_2008
; false otherwise. -
allowPluralTimeUnits
boolean allowPluralTimeUnits()Whether interval literals should allow plural time units such as "YEARS" and "DAYS" in interval literals.Under strict behavior,
INTERVAL '2' DAY
is valid andINTERVAL '2' DAYS
is invalid; PostgreSQL allows both; Oracle only allows singular time units.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
; false otherwise. -
allowQualifyingCommonColumn
boolean allowQualifyingCommonColumn()Whether to allow a qualified common column in a query that has a NATURAL join or a join with a USING clause.For example, in the query
SELECT emp.deptno FROM emp JOIN dept USING (deptno)
deptno
is the common column. A qualified common column such asemp.deptno
is not allowed in Oracle, but is allowed in PostgreSQL.Among the built-in conformance levels, false in
SqlConformanceEnum.ORACLE_10
,SqlConformanceEnum.ORACLE_12
,SqlConformanceEnum.PRESTO
,SqlConformanceEnum.STRICT_92
,SqlConformanceEnum.STRICT_99
,SqlConformanceEnum.STRICT_2003
; true otherwise. -
isValueAllowed
boolean isValueAllowed()WhetherVALUE
is allowed as an alternative toVALUES
in the parser.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
,SqlConformanceEnum.LENIENT
,SqlConformanceEnum.MYSQL_5
; false otherwise. -
semantics
SqlLibrary semantics()Controls the behavior of operators that are part of Standard SQL but nevertheless have different behavior in different databases.Consider the
SUBSTRING
operator. In ISO standard SQL, negative start indexes are converted to 1; in Google BigQuery, negative start indexes are treated as offsets from the end of the string. For example,SUBSTRING('abcde' FROM -3 FOR 2)
returns'ab'
in standard SQL and 'cd' in BigQuery.If you specify
conformance=BIG_QUERY
in your connection parameters,SUBSTRING
will give the BigQuery behavior. Similarly MySQL and Oracle.Among the built-in conformance levels:
SqlConformanceEnum.BIG_QUERY
returnsSqlLibrary.BIG_QUERY
;SqlConformanceEnum.MYSQL_5
returnsSqlLibrary.MYSQL
;SqlConformanceEnum.ORACLE_10
andSqlConformanceEnum.ORACLE_12
returnSqlLibrary.ORACLE
;- otherwise returns
SqlLibrary.STANDARD
.
-
allowLenientCoercion
boolean allowLenientCoercion()Whether to allow lenient type coercions.Coercions include:
- Coercion of string literal to array literal. For example,
SELECT ARRAY[0,1,2] == '{0,1,2}'
- Casting
BOOLEAN
values to one of the following numeric types:TINYINT
,SMALLINT
,INTEGER
,BIGINT
.
Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL
, false otherwise. - Coercion of string literal to array literal. For example,
-