Package org.apache.calcite.sql.dialect
Class MysqlSqlDialect
- java.lang.Object
-
- org.apache.calcite.sql.SqlDialect
-
- org.apache.calcite.sql.dialect.MysqlSqlDialect
-
public class MysqlSqlDialect extends SqlDialect
ASqlDialect
implementation for the MySQL 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 Modifier and Type Field Description static SqlDialect
DEFAULT
static SqlFunction
ISNULL_FUNCTION
MySQL specific function.-
Fields inherited from class org.apache.calcite.sql.SqlDialect
BUILT_IN_OPERATORS_LIST, CALCITE, DUMMY, EMPTY_CONTEXT, LOGGER, nullCollation
-
-
Constructor Summary
Constructors Constructor Description MysqlSqlDialect(SqlDialect.Context context)
Creates a MysqlSqlDialect.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.SqlDialect.CalendarPolicy
getCalendarPolicy()
SqlNode
getCastSpec(RelDataType type)
SqlNode
rewriteSingleValueExpr(SqlNode aggCall)
Rewrite SINGLE_VALUE into expression based on database variants E.g.boolean
supportsAggregateFunction(SqlKind kind)
boolean
supportsCharSet()
Returns whether the dialect supports character set names as part of a data type, for instanceVARCHAR(30) CHARACTER SET `ISO-8859-1`
.boolean
supportsNestedAggregations()
Returns whether the dialect supports nested aggregations, for instanceSELECT SUM(SUM(1))
.void
unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
private void
unparseFloor(SqlWriter writer, SqlCall call)
Unparses datetime floor for MySQL.void
unparseOffsetFetch(SqlWriter writer, SqlNode offset, 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.private org.apache.calcite.avatica.util.TimeUnit
validate(org.apache.calcite.avatica.util.TimeUnit timeUnit)
-
Methods inherited from class org.apache.calcite.sql.SqlDialect
allowsAs, create, defaultNullDirection, emptyContext, emulateNullDirectionWithIsNull, getDatabaseProduct, getNullCollation, getProduct, getTypeSystem, hasImplicitTableAlias, identifierNeedsToBeQuoted, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteStringLiteral, quoteStringLiteralUnicode, quoteTimestampLiteral, requiresAliasForFromItems, supportsAliasedValues, supportsFunction, supportsOffsetFetch, supportsWindowFunctions, unparseDateTimeLiteral, unparseFetchUsingAnsi, unparseFetchUsingLimit, unparseSqlDatetimeArithmetic, unparseSqlIntervalLiteral, unquoteStringLiteral
-
-
-
-
Field Detail
-
DEFAULT
public static final SqlDialect DEFAULT
-
ISNULL_FUNCTION
public static final SqlFunction ISNULL_FUNCTION
MySQL specific function.
-
-
Constructor Detail
-
MysqlSqlDialect
public MysqlSqlDialect(SqlDialect.Context context)
Creates a MysqlSqlDialect.
-
-
Method Detail
-
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
-
unparseOffsetFetch
public void unparseOffsetFetch(SqlWriter writer, SqlNode offset, SqlNode fetch)
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:
SqlDialect.unparseFetchUsingAnsi(SqlWriter, SqlNode, SqlNode)
,SqlDialect.unparseFetchUsingLimit(SqlWriter, SqlNode, SqlNode)
-
emulateNullDirection
public SqlNode emulateNullDirection(SqlNode node, boolean nullsFirst, boolean desc)
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
-
supportsAggregateFunction
public boolean supportsAggregateFunction(SqlKind kind)
- Overrides:
supportsAggregateFunction
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
-
getCalendarPolicy
public SqlDialect.CalendarPolicy getCalendarPolicy()
- Overrides:
getCalendarPolicy
in classSqlDialect
-
getCastSpec
public SqlNode getCastSpec(RelDataType type)
- Overrides:
getCastSpec
in classSqlDialect
-
rewriteSingleValueExpr
public SqlNode rewriteSingleValueExpr(SqlNode aggCall)
Description copied from class:SqlDialect
Rewrite SINGLE_VALUE into expression based on database variants E.g. HSQLDB, MYSQL, ORACLE, etc- Overrides:
rewriteSingleValueExpr
in classSqlDialect
-
unparseCall
public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
- Overrides:
unparseCall
in classSqlDialect
-
unparseFloor
private void unparseFloor(SqlWriter writer, SqlCall call)
Unparses datetime floor for MySQL. There is no TRUNC function, so simulate this using calls to DATE_FORMAT.- Parameters:
writer
- Writercall
- Call
-
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
-
validate
private org.apache.calcite.avatica.util.TimeUnit validate(org.apache.calcite.avatica.util.TimeUnit timeUnit)
-
-