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
FieldsModifier and TypeFieldDescriptionstatic final SqlDialectstatic final SqlDialect.Contextstatic final RelDataTypeSystemMssql 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
Constructors -
Method Summary
Modifier and TypeMethodDescription@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.booleanReturns 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.voidunparseBoolLiteral(SqlWriter writer, SqlLiteral literal, int leftPrec, int rightPrec) voidunparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec) voidunparseDateTimeLiteral(SqlWriter writer, SqlAbstractDateTimeLiteral literal, int leftPrec, int rightPrec) voidunparseOffsetFetch(SqlWriter writer, @Nullable SqlNode offset, @Nullable SqlNode fetch) Converts an offset and fetch into SQL.voidunparseSqlDatetimeArithmetic(SqlWriter writer, SqlCall call, SqlKind sqlKind, int leftPrec, int rightPrec) voidunparseSqlIntervalLiteral(SqlWriter writer, SqlIntervalLiteral literal, int leftPrec, int rightPrec) Converts an interval literal to a SQL string.voidunparseSqlIntervalQualifier(SqlWriter writer, SqlIntervalQualifier qualifier, RelDataTypeSystem typeSystem) Converts an interval qualifier to a SQL string.voidunparseTopN(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, prepareUnparse, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteStringLiteral, quoteStringLiteral, quoteStringLiteralUnicode, quoteTimestampLiteral, requiresAliasForFromItems, rewriteMaxMin, rewriteMaxMinExpr, rewriteSingleValueExpr, supportBooleanCaseWhen, supportGenerateSelectStar, supportsAggregateFunction, supportsAggregateFunctionFilter, supportsAliasedValues, supportsDataType, supportsFunction, supportsGroupByLiteral, supportsImplicitTypeCoercion, supportsJoinType, supportsNestedAggregations, supportsOffsetFetch, supportsOrderByLiteral, supportsTimestampPrecision, supportsWindowFunctions, unparseFetchUsingAnsi, unparseFetchUsingLimit, unparseLimit, unparseNumericLiteral, unparseOffset, unparseSqlSetOption, 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 ornullif no emulation needs to be done.MSSQL does not support NULLS FIRST, so we emulate using CASE expressions. For example,
ORDER BY x NULLS FIRSTbecomes
ORDER BY CASE WHEN x IS NULL THEN 0 ELSE 1 END, x- 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
-
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:
-
unparseTopN
Description copied from class:SqlDialectConverts 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:
unparseTopNin 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:
unparseDateTimeLiteralin classSqlDialect
-
unparseCall
- Overrides:
unparseCallin classSqlDialect
-
unparseBoolLiteral
- Overrides:
unparseBoolLiteralin classSqlDialect
-
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
-
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
-
supportsGroupByWithCube
public boolean supportsGroupByWithCube()Description copied from class:SqlDialectReturns whether this dialect supports "WITH CUBE" in "GROUP BY" clause.- Overrides:
supportsGroupByWithCubein classSqlDialect
-
unparseSqlDatetimeArithmetic
public void unparseSqlDatetimeArithmetic(SqlWriter writer, SqlCall call, SqlKind sqlKind, int leftPrec, int rightPrec) - Overrides:
unparseSqlDatetimeArithmeticin 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
-
unparseSqlIntervalLiteral
public void unparseSqlIntervalLiteral(SqlWriter writer, SqlIntervalLiteral literal, int leftPrec, int rightPrec) Description copied from class:SqlDialectConverts an interval literal to a SQL string. The default implementation returns strings such asINTERVAL '1 2:3:4' DAY(4) TO SECOND(4).- Overrides:
unparseSqlIntervalLiteralin classSqlDialect
-