Class HiveSqlDialect
SqlDialect
implementation for the Apache Hive 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
Fields inherited from class org.apache.calcite.sql.SqlDialect
BUILT_IN_OPERATORS_LIST, EMPTY_CONTEXT, identifierEndQuoteString, identifierEscapedQuote, identifierQuoteString, literalEndQuoteString, literalEscapedQuote, literalQuoteString, LOGGER, nullCollation
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
allowsAs()
@Nullable SqlNode
emulateNullDirection
(SqlNode node, boolean nullsFirst, boolean desc) Returns the SqlNode for emulating the null direction for the given field ornull
if no emulation needs to be done.@Nullable SqlNode
getCastSpec
(RelDataType type) Returns SqlNode for type in "cast(column as type)", which might be different between databases by type name, precision etc.boolean
Whether a sub-query in the FROM clause must have an alias.boolean
Returns whether the dialect supports VALUES in a sub-query with and an "AS t(column, ...)" values to define column names.boolean
Returns whether this dialect supports APPROX_COUNT_DISTINCT functions.boolean
Returns whether the dialect supports character set names as part of a data type, for instanceVARCHAR(30) CHARACTER SET `ISO-8859-1`
.boolean
Returns whether this dialect supports "WITH CUBE" in "GROUP BY" clause.boolean
Returns whether this dialect supports "WITH ROLLUP" in the "GROUP BY" clause.boolean
Returns whether the dialect supports nested aggregations, for instanceSELECT SUM(SUM(1))
.boolean
Returns whether this dialect supports TIMESTAMP with precision.void
unparseCall
(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) void
unparseOffsetFetch
(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, emulateJoinTypeForCrossJoin, emulateNullDirectionWithIsNull, getCalendarPolicy, getConformance, getDatabaseProduct, getFormatModel, getNullCollation, getProduct, getQuotedCasing, getQuoting, getSingleRowTableName, getTypeSystem, getUnquotedCasing, hasImplicitTableAlias, identifierNeedsQuote, isCaseSensitive, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteStringLiteral, quoteStringLiteral, quoteStringLiteralUnicode, quoteTimestampLiteral, rewriteMaxMin, rewriteMaxMinExpr, rewriteSingleValueExpr, supportBooleanCaseWhen, supportsAggregateFunction, supportsAggregateFunctionFilter, supportsDataType, supportsFunction, supportsGroupByLiteral, supportsImplicitTypeCoercion, supportsJoinType, supportsOffsetFetch, supportsWindowFunctions, unparseBoolLiteral, unparseDateTimeLiteral, unparseFetchUsingAnsi, unparseFetchUsingLimit, unparseLimit, unparseOffset, unparseSqlDatetimeArithmetic, unparseSqlIntervalLiteral, unparseSqlIntervalQualifier, unparseTableScanHints, unparseTopN, unquoteStringLiteral
-
Field Details
-
DEFAULT_CONTEXT
-
DEFAULT
-
-
Constructor Details
-
HiveSqlDialect
Creates a HiveSqlDialect.
-
-
Method Details
-
allowsAs
protected boolean allowsAs()- Overrides:
allowsAs
in classSqlDialect
-
requiresAliasForFromItems
public boolean requiresAliasForFromItems()Description copied from class:SqlDialect
Whether 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 e
but remove the alias
e
and it is not:SELECT * FROM (SELECT * FROM Emp)
In Oracle, both queries are legal.
- Overrides:
requiresAliasForFromItems
in classSqlDialect
-
supportsAliasedValues
public boolean supportsAliasedValues()Description copied from class:SqlDialect
Returns whether the dialect supports VALUES in a sub-query with and an "AS t(column, ...)" values to define column names.Currently, only Oracle does not. For this, we generate "SELECT v0 AS c0, v1 AS c1 ... UNION ALL ...". We may need to refactor this method when we support VALUES for other dialects.
- Overrides:
supportsAliasedValues
in classSqlDialect
-
unparseOffsetFetch
Description copied from class:SqlDialect
Converts an offset and fetch into SQL.At least one of
offset
andfetch
must 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:
unparseOffsetFetch
in classSqlDialect
- Parameters:
writer
- Writeroffset
- Number of rows to skip before emitting, or nullfetch
- Number of rows to fetch, or null- See Also:
-
emulateNullDirection
Description copied from class:SqlDialect
Returns the SqlNode for emulating the null direction for the given field ornull
if no emulation needs to be done.- Overrides:
emulateNullDirection
in classSqlDialect
- Parameters:
node
- The SqlNode representing the expressionnullsFirst
- Whether nulls should come firstdesc
- Whether the sort direction isRelFieldCollation.Direction.DESCENDING
orRelFieldCollation.Direction.STRICTLY_DESCENDING
- Returns:
- A SqlNode for null direction emulation or
null
if not required
-
unparseCall
- Overrides:
unparseCall
in classSqlDialect
-
supportsCharSet
public boolean supportsCharSet()Description copied from class:SqlDialect
Returns whether the dialect supports character set names as part of a data type, for instanceVARCHAR(30) CHARACTER SET `ISO-8859-1`
.- Overrides:
supportsCharSet
in classSqlDialect
-
supportsGroupByWithRollup
public boolean supportsGroupByWithRollup()Description copied from class:SqlDialect
Returns 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 ROLLUP
is equivalent to standard SQL
SELECT deptno, job, COUNT(*) AS c FROM emp GROUP BY ROLLUP(deptno, job) ORDER BY deptno, job
The "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:
supportsGroupByWithRollup
in classSqlDialect
-
supportsGroupByWithCube
public boolean supportsGroupByWithCube()Description copied from class:SqlDialect
Returns whether this dialect supports "WITH CUBE" in "GROUP BY" clause.- Overrides:
supportsGroupByWithCube
in classSqlDialect
-
supportsTimestampPrecision
public boolean supportsTimestampPrecision()Description copied from class:SqlDialect
Returns whether this dialect supports TIMESTAMP with precision.- Overrides:
supportsTimestampPrecision
in classSqlDialect
-
supportsApproxCountDistinct
public boolean supportsApproxCountDistinct()Description copied from class:SqlDialect
Returns whether this dialect supports APPROX_COUNT_DISTINCT functions.- Overrides:
supportsApproxCountDistinct
in classSqlDialect
-
supportsNestedAggregations
public boolean supportsNestedAggregations()Description copied from class:SqlDialect
Returns whether the dialect supports nested aggregations, for instanceSELECT SUM(SUM(1))
.- Overrides:
supportsNestedAggregations
in classSqlDialect
-
getCastSpec
Description copied from class:SqlDialect
Returns 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:
getCastSpec
in classSqlDialect
-