Package org.apache.calcite.sql.dialect
Class SparkSqlDialect
java.lang.Object
org.apache.calcite.sql.SqlDialect
org.apache.calcite.sql.dialect.SparkSqlDialect
A
SqlDialect implementation for the APACHE SPARK 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
FieldsFields 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 TypeMethodDescriptionprotected booleanallowsAs()@Nullable SqlNodegetCastSpec(RelDataType type) Returns SqlNode for type in "cast(column as type)", which might be different between databases by type name, precision etc.rewriteSingleValueExpr(SqlNode aggCall, RelDataType relDataType) Rewrite SINGLE_VALUE(result).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 nested aggregations, for instanceSELECT SUM(SUM(1)).booleanReturns whether this dialect supports TIMESTAMP with precision.voidunparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) voidunparseOffsetFetch(SqlWriter writer, @Nullable SqlNode offset, @Nullable SqlNode fetch) Converts an offset and fetch into SQL.Methods inherited from class org.apache.calcite.sql.SqlDialect
configureParser, configureParser, containsNonAscii, create, defaultNullDirection, emulateNullDirection, emulateNullDirectionWithIsNull, getCalendarPolicy, getConformance, getDatabaseProduct, getFormatModel, getNullCollation, getProduct, getQuotedCasing, getQuoting, getSingleRowTableName, getTypeSystem, getUnquotedCasing, hasImplicitTableAlias, identifierNeedsQuote, isCaseSensitive, prepareUnparse, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteStringLiteral, quoteStringLiteral, quoteStringLiteralUnicode, quoteTimestampLiteral, requiresAliasForFromItems, rewriteMaxMin, rewriteMaxMinExpr, supportBooleanCaseWhen, supportsAggregateFunctionFilter, supportsAliasedValues, supportsDataType, supportsFunction, supportsGroupByLiteral, supportsImplicitTypeCoercion, supportsJoinType, supportsOffsetFetch, supportsWindowFunctions, unparseBoolLiteral, unparseDateTimeLiteral, unparseFetchUsingAnsi, unparseFetchUsingLimit, unparseLimit, unparseNumericLiteral, unparseOffset, unparseSqlDatetimeArithmetic, unparseSqlIntervalLiteral, unparseSqlIntervalQualifier, unparseSqlSetOption, unparseTableScanHints, unparseTopN, unquoteStringLiteral
-
Field Details
-
DEFAULT_CONTEXT
-
DEFAULT
-
-
Constructor Details
-
SparkSqlDialect
Creates a SparkSqlDialect.
-
-
Method Details
-
allowsAs
protected boolean allowsAs()- Overrides:
allowsAsin 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
-
emulateJoinTypeForCrossJoin
- Overrides:
emulateJoinTypeForCrossJoinin 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
-
supportsNestedAggregations
public boolean supportsNestedAggregations()Description copied from class:SqlDialectReturns whether the dialect supports nested aggregations, for instanceSELECT SUM(SUM(1)).- Overrides:
supportsNestedAggregationsin classSqlDialect
-
supportsAggregateFunction
- Overrides:
supportsAggregateFunctionin classSqlDialect
-
supportsApproxCountDistinct
public boolean supportsApproxCountDistinct()Description copied from class:SqlDialectReturns whether this dialect supports APPROX_COUNT_DISTINCT functions.- Overrides:
supportsApproxCountDistinctin classSqlDialect
-
supportsGroupByWithCube
public boolean supportsGroupByWithCube()Description copied from class:SqlDialectReturns whether this dialect supports "WITH CUBE" in "GROUP BY" clause.- Overrides:
supportsGroupByWithCubein 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:
-
unparseCall
- Overrides:
unparseCallin 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
-
rewriteSingleValueExpr
Rewrite SINGLE_VALUE(result).CASE COUNT(*) WHEN 0 THEN NULL WHEN 1 THEN MIN(<result>) ELSE RAISE_ERROR("more than one value in agg SINGLE_VALUE")RAISE_ERROR("more than one value in agg SINGLE_VALUE") will throw exception when result includes more than one value.- Overrides:
rewriteSingleValueExprin classSqlDialect
-