public class MssqlSqlDialect extends SqlDialect
SqlDialect implementation for the Microsoft SQL Server
database.SqlDialect.CalendarPolicy, SqlDialect.Context, SqlDialect.DatabaseProduct, SqlDialect.FakeUtil| Modifier and Type | Field and Description |
|---|---|
static SqlDialect |
DEFAULT |
static SqlDialect.Context |
DEFAULT_CONTEXT |
BUILT_IN_OPERATORS_LIST, EMPTY_CONTEXT, identifierEndQuoteString, identifierEscapedQuote, identifierQuoteString, literalEndQuoteString, literalEscapedQuote, literalQuoteString, LOGGER, nullCollation| Constructor and Description |
|---|
MssqlSqlDialect(SqlDialect.Context context)
Creates a MssqlSqlDialect.
|
| Modifier and Type | Method and Description |
|---|---|
@Nullable SqlNode |
emulateNullDirection(SqlNode node,
boolean nullsFirst,
boolean desc)
Returns the SqlNode for emulating the null direction for the given field
or
null if no emulation needs to be done. |
boolean |
supportsCharSet()
Returns whether the dialect supports character set names as part of a
data type, for instance
VARCHAR(30) CHARACTER SET `ISO-8859-1`. |
boolean |
supportsGroupByWithCube()
Returns whether this dialect supports "WITH CUBE" in "GROUP BY" clause.
|
boolean |
supportsGroupByWithRollup()
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)".
|
allowsAs, configureParser, configureParser, containsNonAscii, create, defaultNullDirection, emulateJoinTypeForCrossJoin, emulateNullDirectionWithIsNull, getCalendarPolicy, getCastSpec, getConformance, getDatabaseProduct, getNullCollation, getProduct, getQuotedCasing, getQuoting, getSingleRowTableName, getTypeSystem, getUnquotedCasing, hasImplicitTableAlias, identifierNeedsQuote, isCaseSensitive, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteStringLiteral, quoteStringLiteral, quoteStringLiteralUnicode, quoteTimestampLiteral, requiresAliasForFromItems, rewriteSingleValueExpr, supportsAggregateFunction, supportsAggregateFunctionFilter, supportsAliasedValues, supportsApproxCountDistinct, supportsDataType, supportsFunction, supportsGroupByLiteral, supportsImplicitTypeCoercion, supportsJoinType, supportsNestedAggregations, supportsOffsetFetch, supportsWindowFunctions, unparseFetchUsingAnsi, unparseFetchUsingLimit, unparseLimit, unparseOffset, unparseTableScanHints, unquoteStringLiteralpublic static final SqlDialect.Context DEFAULT_CONTEXT
public static final SqlDialect DEFAULT
public MssqlSqlDialect(SqlDialect.Context context)
public @Nullable SqlNode emulateNullDirection(SqlNode node, boolean nullsFirst, boolean desc)
null 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
emulateNullDirection in class SqlDialectnode - The SqlNode representing the expressionnullsFirst - Whether nulls should come firstdesc - Whether the sort direction is
RelFieldCollation.Direction#DESCENDING or
RelFieldCollation.Direction#STRICTLY_DESCENDINGnull if not requiredpublic void unparseOffsetFetch(SqlWriter writer, @Nullable SqlNode offset, @Nullable SqlNode fetch)
SqlDialectAt least one of offset and fetch 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)
unparseOffsetFetch in class SqlDialectwriter - Writeroffset - Number of rows to skip before emitting, or nullfetch - Number of rows to fetch, or nullSqlDialect.unparseFetchUsingAnsi(SqlWriter, SqlNode, SqlNode),
SqlDialect.unparseFetchUsingLimit(SqlWriter, SqlNode, SqlNode)public void unparseTopN(SqlWriter writer, @Nullable SqlNode offset, @Nullable SqlNode fetch)
SqlDialectA 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.
unparseTopN in class SqlDialectwriter - Writeroffset - Number of rows to skip before emitting, or nullfetch - Number of rows to fetch, or nullpublic void unparseDateTimeLiteral(SqlWriter writer, SqlAbstractDateTimeLiteral literal, int leftPrec, int rightPrec)
unparseDateTimeLiteral in class SqlDialectpublic void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
unparseCall in class SqlDialectpublic boolean supportsCharSet()
SqlDialectVARCHAR(30) CHARACTER SET `ISO-8859-1`.supportsCharSet in class SqlDialectpublic boolean supportsGroupByWithRollup()
SqlDialectFor 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 to
SqlKind.ROLLUP, which returns true in MySQL 8 and higher.
supportsGroupByWithRollup in class SqlDialectpublic boolean supportsGroupByWithCube()
SqlDialectsupportsGroupByWithCube in class SqlDialectpublic void unparseSqlDatetimeArithmetic(SqlWriter writer, SqlCall call, SqlKind sqlKind, int leftPrec, int rightPrec)
unparseSqlDatetimeArithmetic in class SqlDialectpublic void unparseSqlIntervalQualifier(SqlWriter writer, SqlIntervalQualifier qualifier, RelDataTypeSystem typeSystem)
SqlDialectINTERVAL '1 2:3:4' DAY(4) TO SECOND(4).unparseSqlIntervalQualifier in class SqlDialectpublic void unparseSqlIntervalLiteral(SqlWriter writer, SqlIntervalLiteral literal, int leftPrec, int rightPrec)
SqlDialectINTERVAL '1 2:3:4' DAY(4) TO SECOND(4).unparseSqlIntervalLiteral in class SqlDialectCopyright © 2012-2022 Apache Software Foundation. All Rights Reserved.