Class PrestoSqlDialect
- Direct Known Subclasses:
TrinoSqlDialect
SqlDialect implementation for the Presto database.-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.calcite.sql.SqlDialect
SqlDialect.CalendarPolicy, SqlDialect.Context, SqlDialect.DatabaseProduct, SqlDialect.FakeUtil -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final SqlDialectstatic final SqlDialect.Contextstatic final RelDataTypeSystemFields inherited from class org.apache.calcite.sql.SqlDialect
BUILT_IN_OPERATORS_LIST, EMPTY_CONTEXT, identifierEndQuoteString, identifierEscapedQuote, identifierQuoteString, literalEndQuoteString, literalEscapedQuote, literalQuoteString, LOGGER, nullCollation -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic SqlCallconvertMapValueCall(SqlCall call) Converts a Presto MapValue call fromMAP['k1', 'v1', 'k2', 'v2']toMAP[ARRAY['k1', 'k2'], ARRAY['v1', 'v2']].@Nullable SqlNodeemulateNullDirection(SqlNode node, boolean nullsFirst, boolean desc) Returns the SqlNode for emulating the null direction for the given field ornullif no emulation needs to be done.@Nullable SqlNodegetCastSpec(RelDataType type) Returns SqlNode for type in "cast(column as type)", which might be different between databases by type name, precision etc.prepareUnparse(RexNode rexNode) booleanWhether a sub-query in the FROM clause must have an alias.booleanbooleanReturns whether this dialect supports APPROX_COUNT_DISTINCT functions.booleanReturns whether the dialect supports character set names as part of a data type, for instanceVARCHAR(30) CHARACTER SET `ISO-8859-1`.booleanReturns whether this dialect supports "WITH CUBE" in "GROUP BY" clause.booleanReturns whether this dialect supports "WITH ROLLUP" in the "GROUP BY" clause.booleanReturns whether the dialect supports implicit type coercion.booleanReturns whether the dialect supports nested aggregations, for instanceSELECT SUM(SUM(1)).booleanReturns whether this dialect supports TIMESTAMP with precision.voidunparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) static voidunparseMapValue(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) change map open/close symbol from default [] to ().voidunparseOffsetFetch(SqlWriter writer, @Nullable SqlNode offset, @Nullable SqlNode fetch) Converts an offset and fetch into SQL.voidunparseSqlIntervalQualifier(SqlWriter writer, SqlIntervalQualifier qualifier, RelDataTypeSystem typeSystem) Converts an interval qualifier to a SQL string.Methods inherited from class org.apache.calcite.sql.SqlDialect
allowsAs, configureParser, configureParser, containsNonAscii, create, defaultNullDirection, emulateJoinTypeForCrossJoin, emulateNullDirectionWithIsNull, getConformance, getDatabaseProduct, getFormatModel, getNullCollation, getProduct, getQuotedCasing, getQuoting, getSingleRowTableName, getTypeSystem, getUnquotedCasing, hasImplicitTableAlias, identifierNeedsQuote, isCaseSensitive, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteStringLiteral, quoteStringLiteral, quoteStringLiteralUnicode, quoteTimestampLiteral, rewriteMaxMin, rewriteMaxMinExpr, rewriteSingleValueExpr, supportBooleanCaseWhen, supportsAggregateFunctionFilter, supportsAliasedValues, supportsDataType, supportsFunction, supportsGroupByLiteral, supportsJoinType, supportsOffsetFetch, supportsWindowFunctions, unparseBoolLiteral, unparseDateTimeLiteral, unparseFetchUsingAnsi, unparseFetchUsingLimit, unparseLimit, unparseNumericLiteral, unparseOffset, unparseSqlDatetimeArithmetic, unparseSqlIntervalLiteral, unparseSqlSetOption, unparseTableScanHints, unparseTopN, unquoteStringLiteral
-
Field Details
-
TYPE_SYSTEM
-
DEFAULT_CONTEXT
-
DEFAULT
-
-
Constructor Details
-
PrestoSqlDialect
Creates a PrestoSqlDialect.
-
-
Method Details
-
supportsApproxCountDistinct
public boolean supportsApproxCountDistinct()Description copied from class:SqlDialectReturns whether this dialect supports APPROX_COUNT_DISTINCT functions.- Overrides:
supportsApproxCountDistinctin classSqlDialect
-
supportsCharSet
public boolean supportsCharSet()Description copied from class:SqlDialectReturns whether the dialect supports character set names as part of a data type, for instanceVARCHAR(30) CHARACTER SET `ISO-8859-1`.- Overrides:
supportsCharSetin classSqlDialect
-
requiresAliasForFromItems
public boolean requiresAliasForFromItems()Description copied from class:SqlDialectWhether a sub-query in the FROM clause must have an alias.For example, in PostgreSQL, this query is legal:
SELECT * FROM (SELECT * FROM Emp) As ebut remove the alias
eand it is not:SELECT * FROM (SELECT * FROM Emp)In Oracle, both queries are legal.
- Overrides:
requiresAliasForFromItemsin classSqlDialect
-
supportsTimestampPrecision
public boolean supportsTimestampPrecision()Description copied from class:SqlDialectReturns whether this dialect supports TIMESTAMP with precision.- Overrides:
supportsTimestampPrecisionin classSqlDialect
-
unparseOffsetFetch
Description copied from class:SqlDialectConverts an offset and fetch into SQL.At least one of
offsetandfetchmust be provided.Common options:
OFFSET offset ROWS FETCH NEXT fetch ROWS ONLY(ANSI standard SQL, Oracle, PostgreSQL, and the default)LIMIT fetch OFFSET offset(Apache Hive, MySQL, Redshift)
- Overrides:
unparseOffsetFetchin classSqlDialect- Parameters:
writer- Writeroffset- Number of rows to skip before emitting, or nullfetch- Number of rows to fetch, or null- See Also:
-
supportsImplicitTypeCoercion
Description copied from class:SqlDialectReturns whether the dialect supports implicit type coercion.Most of the sql dialects support implicit type coercion, so we make this method default return true. For instance, "cast('10' as integer) > 5" can be simplified to "'10' > 5" if the dialect supports implicit type coercion for VARCHAR and INTEGER comparison.
For sql dialect that does not support implicit type coercion, such as the BigQuery, we can not convert '10' into INT64 implicitly.
Now this method is used for some auxiliary decision when translating some
RexCalls, see SqlImplementor#stripCastFromString for details.- Overrides:
supportsImplicitTypeCoercionin classSqlDialect- Parameters:
call- the call to make decision
-
emulateNullDirection
Description copied from class:SqlDialectReturns the SqlNode for emulating the null direction for the given field ornullif no emulation needs to be done.- Overrides:
emulateNullDirectionin classSqlDialect- Parameters:
node- The SqlNode representing the expressionnullsFirst- Whether nulls should come firstdesc- Whether the sort direction isRelFieldCollation.Direction.DESCENDINGorRelFieldCollation.Direction.STRICTLY_DESCENDING- Returns:
- A SqlNode for null direction emulation or
nullif not required
-
supportsAggregateFunction
- Overrides:
supportsAggregateFunctionin classSqlDialect
-
supportsGroupByWithCube
public boolean supportsGroupByWithCube()Description copied from class:SqlDialectReturns whether this dialect supports "WITH CUBE" in "GROUP BY" clause.- Overrides:
supportsGroupByWithCubein classSqlDialect
-
supportsNestedAggregations
public boolean supportsNestedAggregations()Description copied from class:SqlDialectReturns whether the dialect supports nested aggregations, for instanceSELECT SUM(SUM(1)).- Overrides:
supportsNestedAggregationsin classSqlDialect
-
supportsGroupByWithRollup
public boolean supportsGroupByWithRollup()Description copied from class:SqlDialectReturns whether this dialect supports "WITH ROLLUP" in the "GROUP BY" clause.For instance, in MySQL version 5,
SELECT deptno, job, COUNT(*) AS c FROM emp GROUP BY deptno, job WITH ROLLUPis equivalent to standard SQL
SELECT deptno, job, COUNT(*) AS c FROM emp GROUP BY ROLLUP(deptno, job) ORDER BY deptno, jobThe "WITH ROLLUP" clause was introduced in MySQL and is not standard SQL.
See also
SqlDialect.supportsAggregateFunction(SqlKind)applied toSqlKind.ROLLUP, which returns true in MySQL 8 and higher.- Overrides:
supportsGroupByWithRollupin classSqlDialect
-
getCalendarPolicy
- Overrides:
getCalendarPolicyin classSqlDialect
-
getCastSpec
Description copied from class:SqlDialectReturns SqlNode for type in "cast(column as type)", which might be different between databases by type name, precision etc.If this method returns null, the cast will be omitted. In the default implementation, this is the case for the NULL type, and therefore
CAST(NULL AS <nulltype>)is rendered asNULL.- Overrides:
getCastSpecin classSqlDialect
-
prepareUnparse
Description copied from class:SqlDialect- Overrides:
prepareUnparsein classSqlDialect
-
unparseCall
- Overrides:
unparseCallin classSqlDialect
-
unparseSqlIntervalQualifier
public void unparseSqlIntervalQualifier(SqlWriter writer, SqlIntervalQualifier qualifier, RelDataTypeSystem typeSystem) Description copied from class:SqlDialectConverts an interval qualifier to a SQL string. The default implementation returns strings such asINTERVAL '1 2:3:4' DAY(4) TO SECOND(4).- Overrides:
unparseSqlIntervalQualifierin classSqlDialect
-
unparseMapValue
change map open/close symbol from default [] to (). -
convertMapValueCall
Converts a Presto MapValue call fromMAP['k1', 'v1', 'k2', 'v2']toMAP[ARRAY['k1', 'k2'], ARRAY['v1', 'v2']].
-