Package org.apache.calcite.sql.dialect
Class MssqlSqlDialect
java.lang.Object
org.apache.calcite.sql.SqlDialect
org.apache.calcite.sql.dialect.MssqlSqlDialect
A
SqlDialect
implementation for the Microsoft SQL Server
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
Modifier and TypeFieldDescriptionstatic final SqlDialect
static final SqlDialect.Context
static final RelDataTypeSystem
Mssql type system.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 TypeMethodDescription@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.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.void
unparseCall
(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) void
unparseDateTimeLiteral
(SqlWriter writer, SqlAbstractDateTimeLiteral literal, int leftPrec, int rightPrec) void
unparseOffsetFetch
(SqlWriter writer, @Nullable SqlNode offset, @Nullable SqlNode fetch) Converts an offset and fetch into SQL.void
unparseSqlDatetimeArithmetic
(SqlWriter writer, SqlCall call, SqlKind sqlKind, int leftPrec, int rightPrec) void
unparseSqlIntervalLiteral
(SqlWriter writer, SqlIntervalLiteral literal, int leftPrec, int rightPrec) Converts an interval literal to a SQL string.void
unparseSqlIntervalQualifier
(SqlWriter writer, SqlIntervalQualifier qualifier, RelDataTypeSystem typeSystem) Converts an interval qualifier to a SQL string.void
unparseTopN
(SqlWriter writer, @Nullable SqlNode offset, @Nullable SqlNode fetch) Converts a fetch into a "SELECT TOP(fetch)".Methods inherited from class org.apache.calcite.sql.SqlDialect
allowsAs, configureParser, configureParser, containsNonAscii, create, defaultNullDirection, emulateJoinTypeForCrossJoin, emulateNullDirectionWithIsNull, getCalendarPolicy, getCastSpec, getConformance, getDatabaseProduct, getFormatModel, getNullCollation, getProduct, getQuotedCasing, getQuoting, getSingleRowTableName, getTypeSystem, getUnquotedCasing, hasImplicitTableAlias, identifierNeedsQuote, isCaseSensitive, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteStringLiteral, quoteStringLiteral, quoteStringLiteralUnicode, quoteTimestampLiteral, requiresAliasForFromItems, rewriteMaxMin, rewriteMaxMinExpr, rewriteSingleValueExpr, supportBooleanCaseWhen, supportsAggregateFunction, supportsAggregateFunctionFilter, supportsAliasedValues, supportsApproxCountDistinct, supportsDataType, supportsFunction, supportsGroupByLiteral, supportsImplicitTypeCoercion, supportsJoinType, supportsNestedAggregations, supportsOffsetFetch, supportsTimestampPrecision, supportsWindowFunctions, unparseBoolLiteral, unparseFetchUsingAnsi, unparseFetchUsingLimit, unparseLimit, unparseOffset, unparseTableScanHints, unquoteStringLiteral
-
Field Details
-
MSSQL_TYPE_SYSTEM
Mssql type system. -
DEFAULT_CONTEXT
-
DEFAULT
-
-
Constructor Details
-
MssqlSqlDialect
Creates a MssqlSqlDialect.
-
-
Method Details
-
emulateNullDirection
Returns the SqlNode for emulating the null direction for the given field ornull
if no emulation needs to be done.MSSQL does not support NULLS FIRST, so we emulate using CASE expressions. For example,
ORDER BY x NULLS FIRST
becomes
ORDER BY CASE WHEN x IS NULL THEN 0 ELSE 1 END, x
- 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
-
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:
-
unparseTopN
Description copied from class:SqlDialect
Converts a fetch into a "SELECT TOP(fetch)".A dialect that uses "TOP" syntax should override this method to print "TOP(fetch)", and override
SqlDialect.unparseOffsetFetch(org.apache.calcite.sql.SqlWriter, org.apache.calcite.sql.SqlNode, org.apache.calcite.sql.SqlNode)
to no-op.The default implementation of this method is no-op.
- Overrides:
unparseTopN
in classSqlDialect
- Parameters:
writer
- Writeroffset
- Number of rows to skip before emitting, or nullfetch
- Number of rows to fetch, or null
-
unparseDateTimeLiteral
public void unparseDateTimeLiteral(SqlWriter writer, SqlAbstractDateTimeLiteral literal, int leftPrec, int rightPrec) - Overrides:
unparseDateTimeLiteral
in classSqlDialect
-
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
-
unparseSqlDatetimeArithmetic
public void unparseSqlDatetimeArithmetic(SqlWriter writer, SqlCall call, SqlKind sqlKind, int leftPrec, int rightPrec) - Overrides:
unparseSqlDatetimeArithmetic
in classSqlDialect
-
unparseSqlIntervalQualifier
public void unparseSqlIntervalQualifier(SqlWriter writer, SqlIntervalQualifier qualifier, RelDataTypeSystem typeSystem) Description copied from class:SqlDialect
Converts an interval qualifier to a SQL string. The default implementation returns strings such asINTERVAL '1 2:3:4' DAY(4) TO SECOND(4)
.- Overrides:
unparseSqlIntervalQualifier
in classSqlDialect
-
unparseSqlIntervalLiteral
public void unparseSqlIntervalLiteral(SqlWriter writer, SqlIntervalLiteral literal, int leftPrec, int rightPrec) Description copied from class:SqlDialect
Converts an interval literal to a SQL string. The default implementation returns strings such asINTERVAL '1 2:3:4' DAY(4) TO SECOND(4)
.- Overrides:
unparseSqlIntervalLiteral
in classSqlDialect
-