public class MysqlSqlDialect extends SqlDialect
SqlDialect implementation for the MySQL database.SqlDialect.CalendarPolicy, SqlDialect.Context, SqlDialect.DatabaseProduct, SqlDialect.FakeUtil| Modifier and Type | Field and Description |
|---|---|
static SqlDialect |
DEFAULT |
static SqlDialect.Context |
DEFAULT_CONTEXT |
static SqlFunction |
ISNULL_FUNCTION
MySQL specific function.
|
static RelDataTypeSystem |
MYSQL_TYPE_SYSTEM
MySQL type system.
|
BUILT_IN_OPERATORS_LIST, EMPTY_CONTEXT, identifierEndQuoteString, identifierEscapedQuote, identifierQuoteString, literalEndQuoteString, literalEscapedQuote, literalQuoteString, LOGGER, nullCollation| Constructor and Description |
|---|
MysqlSqlDialect(SqlDialect.Context context)
Creates a MysqlSqlDialect.
|
| 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. |
SqlDialect.CalendarPolicy |
getCalendarPolicy() |
@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 |
requiresAliasForFromItems()
Whether a sub-query in the FROM clause must have an alias.
|
SqlNode |
rewriteSingleValueExpr(SqlNode aggCall)
Rewrite SINGLE_VALUE into expression based on database variants
E.g.
|
boolean |
supportsAggregateFunction(SqlKind kind) |
boolean |
supportsAliasedValues()
Returns whether the dialect supports VALUES in a sub-query with
and an "AS t(column, ...)" values to define column names.
|
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 |
supportsGroupByWithRollup()
Returns whether this dialect supports "WITH ROLLUP" in the "GROUP BY"
clause.
|
boolean |
supportsJoinType(JoinRelType joinType)
Returns whether this dialect support the specified type of join.
|
boolean |
supportsNestedAggregations()
Returns whether the dialect supports nested aggregations, for instance
SELECT SUM(SUM(1)) . |
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.
|
void |
unparseSqlIntervalQualifier(SqlWriter writer,
SqlIntervalQualifier qualifier,
RelDataTypeSystem typeSystem)
Converts an interval qualifier to a SQL string.
|
allowsAs, configureParser, configureParser, containsNonAscii, create, defaultNullDirection, emulateJoinTypeForCrossJoin, emulateNullDirectionWithIsNull, getConformance, getDatabaseProduct, getNullCollation, getProduct, getQuotedCasing, getQuoting, getSingleRowTableName, getTypeSystem, getUnquotedCasing, hasImplicitTableAlias, identifierNeedsQuote, isCaseSensitive, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteStringLiteral, quoteStringLiteral, quoteStringLiteralUnicode, quoteTimestampLiteral, supportsAggregateFunctionFilter, supportsApproxCountDistinct, supportsDataType, supportsFunction, supportsGroupByLiteral, supportsGroupByWithCube, supportsImplicitTypeCoercion, supportsOffsetFetch, supportsWindowFunctions, unparseDateTimeLiteral, unparseFetchUsingAnsi, unparseFetchUsingLimit, unparseLimit, unparseOffset, unparseSqlDatetimeArithmetic, unparseSqlIntervalLiteral, unparseTableScanHints, unparseTopN, unquoteStringLiteralpublic static final RelDataTypeSystem MYSQL_TYPE_SYSTEM
public static final SqlDialect.Context DEFAULT_CONTEXT
public static final SqlDialect DEFAULT
public static final SqlFunction ISNULL_FUNCTION
public MysqlSqlDialect(SqlDialect.Context context)
public boolean supportsCharSet()
SqlDialectVARCHAR(30) CHARACTER SET `ISO-8859-1`.supportsCharSet in class SqlDialectpublic boolean requiresAliasForFromItems()
SqlDialectFor 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.
requiresAliasForFromItems in class SqlDialectpublic boolean supportsAliasedValues()
SqlDialectCurrently, 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.
supportsAliasedValues in class SqlDialectpublic 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 @Nullable SqlNode emulateNullDirection(SqlNode node, boolean nullsFirst, boolean desc)
SqlDialectnull if no emulation needs to be done.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 boolean supportsAggregateFunction(SqlKind kind)
supportsAggregateFunction in class SqlDialectpublic boolean supportsNestedAggregations()
SqlDialectSELECT SUM(SUM(1)) .supportsNestedAggregations 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 SqlDialect.CalendarPolicy getCalendarPolicy()
getCalendarPolicy in class SqlDialectpublic @Nullable SqlNode getCastSpec(RelDataType type)
SqlDialectIf 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 as NULL.
getCastSpec in class SqlDialectpublic SqlNode rewriteSingleValueExpr(SqlNode aggCall)
SqlDialectrewriteSingleValueExpr in class SqlDialectpublic void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
unparseCall 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 boolean supportsJoinType(JoinRelType joinType)
SqlDialectsupportsJoinType in class SqlDialectCopyright © 2012-2022 Apache Software Foundation. All Rights Reserved.