Class SqlDelegatingConformance
- All Implemented Interfaces:
SqlConformance
SqlConformance that delegates all methods to
another object. You can create a sub-class that overrides particular
methods.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.calcite.sql.validate.SqlConformance
SqlConformance.SelectAliasLookup -
Field Summary
Fields inherited from interface org.apache.calcite.sql.validate.SqlConformance
DEFAULT, ORACLE_10, PRAGMATIC_2003, PRAGMATIC_99, STRICT_2003, STRICT_92, STRICT_99 -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedSqlDelegatingConformance(SqlConformance delegate) Creates a SqlDelegatingConformance. -
Method Summary
Modifier and TypeMethodDescriptionbooleanWhether directly alias array items in UNNEST.booleanWhether this dialect allows character literals as column aliases.booleanWhether to allow SQL syntax "ROW(expr1, expr2, expr3)".booleanWhether to allow mixing table columns with extended columns inINSERT(orUPSERT).booleanWhether TRIM should support more than one trim character.booleanWhether to allow geo-spatial extensions, including the GEOMETRY type.booleanWhether to allow hyphens in an unquoted table name.booleanWhether to allow lenient type coercions.booleanWhether to allow parentheses to be specified in calls to niladic functions of returned the specific constant value.booleanWhether to allow parentheses to be specified in calls to niladic functions and procedures (that is, functions and procedures with no parameters).booleanWhether interval literals should allow plural time units such as "YEARS" and "DAYS" in interval literals.booleanWhether to allow a qualified common column in a query that has a NATURAL join or a join with a USING clause.booleanWhether the implementation uses checked arithmetic.booleanWhetherCROSS APPLYandOUTER APPLYoperators are allowed in the parser.booleanWhether the bang-equal token != is allowed as an alternative to <> in the parser.booleanWhetherFROMclause is required in aSELECTstatement.booleanWhether to allow aliases from theSELECTclause to be used as column names in theGROUP BYclause.booleanWhetherGROUP BY 2is interpreted to mean 'group by the 2nd column in the select list'.booleanWhether to allow aliases from theSELECTclause to be used as column names in theHAVINGclause.booleanWhether to allowINSERT(orUPSERT) with no column list but fewer values than the target table.booleanWhether this dialect supports features from a wide variety of dialects.booleanWhether to allow the SQL syntax "LIMIT start, count".booleanWhetherMINUSis allowed as an alternative toEXCEPTin the parser.booleanWhether to allow the SQL syntax "OFFSET start LIMIT count" (that is,OFFSETbeforeLIMIT, in addition toLIMITbeforeOFFSETandOFFSETbeforeFETCH).booleanWhether the "%" operator is allowed by the parser as an alternative to themodfunction.Whether to allow aliases from theSELECTclause to be used as column names in the sameSELECTclause.booleanWhether '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.booleanWhether "empno" is invalid in "select empno as x from emp order by empno" because the alias "x" obscures it.booleanWhether 'ORDER BY 2' is interpreted to mean 'sort by the 2nd column in the select list'.booleanWhether this dialect supports dual table.booleanWhetherVALUEis allowed as an alternative toVALUESin the parser.Controls the behavior of operators that are part of Standard SQL but nevertheless have different behavior in different databases.booleanWhether the least restrictive type of a number of CHAR types of different lengths should be a VARCHAR type.booleanWhether to split a quoted table name.
-
Constructor Details
-
SqlDelegatingConformance
Creates a SqlDelegatingConformance.
-
-
Method Details
-
isLiberal
public boolean isLiberal()Description copied from interface:SqlConformanceWhether this dialect supports features from a wide variety of dialects. This is enabled for the Babel parser, disabled otherwise.- Specified by:
isLiberalin interfaceSqlConformance
-
allowCharLiteralAlias
public boolean allowCharLiteralAlias()Description copied from interface:SqlConformanceWhether 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.- Specified by:
allowCharLiteralAliasin interfaceSqlConformance
-
isSupportedDualTable
public boolean isSupportedDualTable()Description copied from interface:SqlConformanceWhether this dialect supports dual table.For example,
SELECT 1 + 1 FROM DUAL
Among the built-in conformance levels, true in
SqlConformanceEnum.MYSQL_5,SqlConformanceEnum.ORACLE_10,SqlConformanceEnum.ORACLE_12, false otherwise.- Specified by:
isSupportedDualTablein interfaceSqlConformance
-
isGroupByAlias
public boolean isGroupByAlias()Description copied from interface:SqlConformanceWhether to allow aliases from theSELECTclause to be used as column names in theGROUP BYclause.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL,SqlConformanceEnum.BIG_QUERY,SqlConformanceEnum.LENIENT,SqlConformanceEnum.MYSQL_5; false otherwise.- Specified by:
isGroupByAliasin interfaceSqlConformance
-
isSelectAlias
Description copied from interface:SqlConformanceWhether to allow aliases from theSELECTclause to be used as column names in the sameSELECTclause. E.g., SELECT 1 as X, X+1 as Y; Name lookup considers an identifier in the same SELECT only if other lookups failed. Supported by Spark, Snowflake, Redshift, DuckDB.Note: this usually requires
SqlConformance.isGroupByAlias()to also return true.- Specified by:
isSelectAliasin interfaceSqlConformance
-
isGroupByOrdinal
public boolean isGroupByOrdinal()Description copied from interface:SqlConformanceWhetherGROUP BY 2is 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.- Specified by:
isGroupByOrdinalin interfaceSqlConformance
-
isHavingAlias
public boolean isHavingAlias()Description copied from interface:SqlConformanceWhether to allow aliases from theSELECTclause to be used as column names in theHAVINGclause.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL,SqlConformanceEnum.BIG_QUERY,SqlConformanceEnum.LENIENT,SqlConformanceEnum.MYSQL_5; false otherwise.- Specified by:
isHavingAliasin interfaceSqlConformance
-
isSortByOrdinal
public boolean isSortByOrdinal()Description copied from interface:SqlConformanceWhether '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.- Specified by:
isSortByOrdinalin interfaceSqlConformance
-
isSortByAlias
public boolean isSortByAlias()Description copied from interface:SqlConformanceWhether '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.- Specified by:
isSortByAliasin interfaceSqlConformance
-
isSortByAliasObscures
public boolean isSortByAliasObscures()Description copied from interface:SqlConformanceWhether "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.- Specified by:
isSortByAliasObscuresin interfaceSqlConformance
-
isFromRequired
public boolean isFromRequired()Description copied from interface:SqlConformanceWhetherFROMclause is required in aSELECTstatement.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.- Specified by:
isFromRequiredin interfaceSqlConformance
-
splitQuotedTableName
public boolean splitQuotedTableName()Description copied from interface:SqlConformanceWhether 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.- Specified by:
splitQuotedTableNamein interfaceSqlConformance
-
allowHyphenInUnquotedTableName
public boolean allowHyphenInUnquotedTableName()Description copied from interface:SqlConformanceWhether to allow hyphens in an unquoted table name.If true,
SELECT * FROM foo-bar.baz-buzzis 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.- Specified by:
allowHyphenInUnquotedTableNamein interfaceSqlConformance
-
isBangEqualAllowed
public boolean isBangEqualAllowed()Description copied from interface:SqlConformanceWhether 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.- Specified by:
isBangEqualAllowedin interfaceSqlConformance
-
isPercentRemainderAllowed
public boolean isPercentRemainderAllowed()Description copied from interface:SqlConformanceWhether the "%" operator is allowed by the parser as an alternative to themodfunction.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL,SqlConformanceEnum.LENIENT,SqlConformanceEnum.MYSQL_5,SqlConformanceEnum.PRESTO; false otherwise.- Specified by:
isPercentRemainderAllowedin interfaceSqlConformance
-
isMinusAllowed
public boolean isMinusAllowed()Description copied from interface:SqlConformanceWhetherMINUSis allowed as an alternative toEXCEPTin 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
MINUSorEXCEPT(as of version 5.5).- Specified by:
isMinusAllowedin interfaceSqlConformance
-
isApplyAllowed
public boolean isApplyAllowed()Description copied from interface:SqlConformanceWhetherCROSS APPLYandOUTER APPLYoperators are allowed in the parser.APPLYinvokes 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.- Specified by:
isApplyAllowedin interfaceSqlConformance
-
isInsertSubsetColumnsAllowed
public boolean isInsertSubsetColumnsAllowed()Description copied from interface:SqlConformanceWhether 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
DEFAULTclause in theCREATE TABLEstatement, or isNULLif 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.- Specified by:
isInsertSubsetColumnsAllowedin interfaceSqlConformance
-
allowAliasUnnestItems
public boolean allowAliasUnnestItems()Description copied from interface:SqlConformanceWhether 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.- Specified by:
allowAliasUnnestItemsin interfaceSqlConformance
-
allowNiladicParentheses
public boolean allowNiladicParentheses()Description copied from interface:SqlConformanceWhether to allow parentheses to be specified in calls to niladic functions and procedures (that is, functions and procedures with no parameters).For example,
CURRENT_DATEis a niladic system function. In standard SQL it must be invoked without parentheses:VALUES CURRENT_DATEIf
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.- Specified by:
allowNiladicParenthesesin interfaceSqlConformance
-
allowNiladicConstantWithoutParentheses
public boolean allowNiladicConstantWithoutParentheses()Description copied from interface:SqlConformanceWhether to allow parentheses to be specified in calls to niladic functions of returned the specific constant value.For example,
PIis a niladic function and return specific constant values pi. In standard SQL it must be invoked with parentheses:VALUES PI()If
allowNiladicConstantWithoutParentheses, the following syntax is also valid:VALUES PIThe same function include E which result is Euler's constant.
Among the built-in conformance levels, true in
SqlConformanceEnum.ORACLE_10,SqlConformanceEnum.ORACLE_12,SqlConformanceEnum.DEFAULT;SqlConformanceEnum.LENIENT; false otherwise.- Specified by:
allowNiladicConstantWithoutParenthesesin interfaceSqlConformance
-
allowExplicitRowValueConstructor
public boolean allowExplicitRowValueConstructor()Description copied from interface:SqlConformanceWhether 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
VALUESclause.Among the built-in conformance levels, true in
SqlConformanceEnum.DEFAULT,SqlConformanceEnum.LENIENT,SqlConformanceEnum.PRESTO; false otherwise.- Specified by:
allowExplicitRowValueConstructorin interfaceSqlConformance
-
allowExtend
public boolean allowExtend()Description copied from interface:SqlConformanceWhether to allow mixing table columns with extended columns inINSERT(orUPSERT).For example, suppose that the declaration of table
Thas columnsAandB, and you want to insert data of columnC INTEGERnot present in the table declaration as an extended column. You can specify the columns in anINSERTstatement 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.- Specified by:
allowExtendin interfaceSqlConformance
-
isLimitStartCountAllowed
public boolean isLimitStartCountAllowed()Description copied from interface:SqlConformanceWhether 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.- Specified by:
isLimitStartCountAllowedin interfaceSqlConformance
-
isOffsetLimitAllowed
public boolean isOffsetLimitAllowed()Description copied from interface:SqlConformanceWhether to allow the SQL syntax "OFFSET start LIMIT count" (that is,OFFSETbeforeLIMIT, in addition toLIMITbeforeOFFSETandOFFSETbeforeFETCH).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.- Specified by:
isOffsetLimitAllowedin interfaceSqlConformance
-
allowGeometry
public boolean allowGeometry()Description copied from interface:SqlConformanceWhether 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.- Specified by:
allowGeometryin interfaceSqlConformance
-
shouldConvertRaggedUnionTypesToVarying
public boolean shouldConvertRaggedUnionTypesToVarying()Description copied from interface:SqlConformanceWhether 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.- Specified by:
shouldConvertRaggedUnionTypesToVaryingin interfaceSqlConformance
- Under strict SQL:2003 behavior, its column has type
-
allowExtendedTrim
public boolean allowExtendedTrim()Description copied from interface:SqlConformanceWhether 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.- Specified by:
allowExtendedTrimin interfaceSqlConformance
-
allowPluralTimeUnits
public boolean allowPluralTimeUnits()Description copied from interface:SqlConformanceWhether interval literals should allow plural time units such as "YEARS" and "DAYS" in interval literals.Under strict behavior,
INTERVAL '2' DAYis valid andINTERVAL '2' DAYSis invalid; PostgreSQL allows both; Oracle only allows singular time units.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL,SqlConformanceEnum.LENIENT; false otherwise.- Specified by:
allowPluralTimeUnitsin interfaceSqlConformance
-
allowQualifyingCommonColumn
public boolean allowQualifyingCommonColumn()Description copied from interface:SqlConformanceWhether 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)
deptnois the common column. A qualified common column such asemp.deptnois 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.- Specified by:
allowQualifyingCommonColumnin interfaceSqlConformance
-
isValueAllowed
public boolean isValueAllowed()Description copied from interface:SqlConformanceWhetherVALUEis allowed as an alternative toVALUESin the parser.Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL,SqlConformanceEnum.LENIENT,SqlConformanceEnum.MYSQL_5; false otherwise.- Specified by:
isValueAllowedin interfaceSqlConformance
-
semantics
Description copied from interface:SqlConformanceControls the behavior of operators that are part of Standard SQL but nevertheless have different behavior in different databases.Consider the
SUBSTRINGoperator. 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_QUERYin your connection parameters,SUBSTRINGwill give the BigQuery behavior. Similarly MySQL and Oracle.Among the built-in conformance levels:
SqlConformanceEnum.BIG_QUERYreturnsSqlLibrary.BIG_QUERY;SqlConformanceEnum.MYSQL_5returnsSqlLibrary.MYSQL;SqlConformanceEnum.ORACLE_10andSqlConformanceEnum.ORACLE_12returnSqlLibrary.ORACLE;- otherwise returns
SqlLibrary.STANDARD.
- Specified by:
semanticsin interfaceSqlConformance
-
allowLenientCoercion
public boolean allowLenientCoercion()Description copied from interface:SqlConformanceWhether 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
BOOLEANvalues to one of the following numeric types:TINYINT,SMALLINT,INTEGER,BIGINT.
Among the built-in conformance levels, true in
SqlConformanceEnum.BABEL, false otherwise.- Specified by:
allowLenientCoercionin interfaceSqlConformance
- Coercion of string literal to array literal. For example,
-
checkedArithmetic
public boolean checkedArithmetic()Description copied from interface:SqlConformanceWhether the implementation uses checked arithmetic. Most SQL dialects use checked arithmetic at runtime: they terminate with a fatal error on overflow.- Specified by:
checkedArithmeticin interfaceSqlConformance
-