|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmondrian.spi.impl.JdbcDialectImpl
mondrian.spi.impl.MySqlDialect
public class MySqlDialect
Implementation of Dialect
for the MySQL database.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface mondrian.spi.Dialect |
---|
Dialect.DatabaseProduct, Dialect.Datatype, Dialect.NullCollation |
Field Summary | |
---|---|
static JdbcDialectFactory |
FACTORY
|
Fields inherited from class mondrian.spi.impl.JdbcDialectImpl |
---|
databaseProduct, permitsSelectNotInGroupBy, productVersion |
Constructor Summary | |
---|---|
MySqlDialect(java.sql.Connection connection)
Creates a MySqlDialect. |
Method Summary | |
---|---|
boolean |
allowsCompoundCountDistinct()
Returns whether this Dialect allows multiple arguments to the COUNT(DISTINCT ...) aggregate function, for example
|
boolean |
allowsFromQuery()
Returns whether this Dialect allows a subquery in the from clause, for example SELECT * FROM (SELECT * FROM t) AS
x |
void |
appendHintsAfterFromClause(java.lang.StringBuilder buf,
java.util.Map<java.lang.String,java.lang.String> hints)
Assembles and returns a string containing any hints that should be appended after the FROM clause in a SELECT statement, based on any hints provided. |
protected java.lang.String |
deduceIdentifierQuoteString(java.sql.DatabaseMetaData databaseMetaData)
|
protected java.lang.String |
deduceProductName(java.sql.DatabaseMetaData databaseMetaData)
|
protected boolean |
deduceSupportsSelectNotInGroupBy(java.sql.Connection connection)
Detects whether the database is configured to permit queries that include columns in the SELECT that are not also in the GROUP BY. |
java.lang.String |
generateInline(java.util.List<java.lang.String> columnNames,
java.util.List<java.lang.String> columnTypes,
java.util.List<java.lang.String[]> valueList)
Generates a SQL statement to represent an inline dataset. |
java.lang.String |
generateOrderItem(java.lang.String expr,
boolean nullable,
boolean ascending)
Generates an item for an ORDER BY clause, sorting in the required direction, and ensuring that NULL values collate after all non-NULL values. |
Dialect.NullCollation |
getNullCollation()
Returns the rule which determines whether NULL values appear first or last when sorted using ORDER BY. |
static boolean |
isInfobright(java.sql.DatabaseMetaData databaseMetaData)
Detects whether this database is Infobright. |
boolean |
requiresAliasForFromQuery()
Returns whether this Dialect requires subqueries in the FROM clause to have an alias. |
boolean |
requiresOrderByAlias()
Returns true if this Dialect can include expressions in the ORDER BY clause only by adding an expression to the SELECT clause and using its alias. |
boolean |
supportsMultiValueInExpr()
Returns true if this dialect supports multi-value IN expressions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final JdbcDialectFactory FACTORY
Constructor Detail |
---|
public MySqlDialect(java.sql.Connection connection) throws java.sql.SQLException
connection
- Connection
java.sql.SQLException
Method Detail |
---|
public static boolean isInfobright(java.sql.DatabaseMetaData databaseMetaData)
Infobright uses the MySQL driver and appears to be a MySQL instance. The only difference is the presence of the BRIGHTHOUSE engine.
databaseMetaData
- Database metadata
protected java.lang.String deduceProductName(java.sql.DatabaseMetaData databaseMetaData)
deduceProductName
in class JdbcDialectImpl
protected java.lang.String deduceIdentifierQuoteString(java.sql.DatabaseMetaData databaseMetaData)
deduceIdentifierQuoteString
in class JdbcDialectImpl
protected boolean deduceSupportsSelectNotInGroupBy(java.sql.Connection connection) throws java.sql.SQLException
JdbcDialectImpl
Detects whether the database is configured to permit queries that include columns in the SELECT that are not also in the GROUP BY. MySQL is an example of one that does, though this is configurable.
The expectation is that this will not change while Mondrian is running, though some databases (MySQL) allow changing it on the fly.
deduceSupportsSelectNotInGroupBy
in class JdbcDialectImpl
connection
- The database connection
java.sql.SQLException
public void appendHintsAfterFromClause(java.lang.StringBuilder buf, java.util.Map<java.lang.String,java.lang.String> hints)
Dialect
appendHintsAfterFromClause
in interface Dialect
appendHintsAfterFromClause
in class JdbcDialectImpl
buf
- The Stringbuffer to which the dialect-specific syntax
for any relevant table hints may be appended. Must not be null.hints
- A map of table hints provided in the schema definitionpublic boolean requiresAliasForFromQuery()
Dialect
requiresAliasForFromQuery
in interface Dialect
requiresAliasForFromQuery
in class JdbcDialectImpl
Dialect.allowsFromQuery()
public boolean allowsFromQuery()
Dialect
SELECT * FROM (SELECT * FROM t) AS
x
allowsFromQuery
in interface Dialect
allowsFromQuery
in class JdbcDialectImpl
Dialect.requiresAliasForFromQuery()
public boolean allowsCompoundCountDistinct()
Dialect
COUNT(DISTINCT ...) aggregate function, for example
SELECT COUNT(DISTINCT x, y) FROM t
- Specified by:
allowsCompoundCountDistinct
in interface Dialect
- Overrides:
allowsCompoundCountDistinct
in class JdbcDialectImpl
- Returns:
- whether Dialect allows multiple arguments to COUNT DISTINCT
- See Also:
Dialect.allowsCountDistinct()
,
Dialect.allowsMultipleCountDistinct()
public java.lang.String generateInline(java.util.List<java.lang.String> columnNames, java.util.List<java.lang.String> columnTypes, java.util.List<java.lang.String[]> valueList)
Dialect
For example, for Oracle, generates
SELECT 1 AS FOO, 'a' AS BAR FROM dual UNION ALL SELECT 2 AS FOO, 'b' AS BAR FROM dual
For ANSI SQL, generates:
VALUES (1, 'a'), (2, 'b')
generateInline
in interface Dialect
generateInline
in class JdbcDialectImpl
columnNames
- List of column namescolumnTypes
- List of column types ("String" or "Numeric")valueList
- List of rows values
public Dialect.NullCollation getNullCollation()
Dialect
According to the SQL standard, this is implementation-specific.
The default behavior is
Dialect.NullCollation.POSINF
.
getNullCollation
in interface Dialect
getNullCollation
in class JdbcDialectImpl
public java.lang.String generateOrderItem(java.lang.String expr, boolean nullable, boolean ascending)
Dialect
By default, generateOrderItem(expr, true)
generates "expr ASC"
and generateOrderItem(expr, false)
generates "expr DESC". But
depending on Dialect.getNullCollation()
and ascending
, there
may need to be additional code.
For example, on Oracle, where NULLs collate higher than all other
values, generateOrderItem(expr, true)
generates "expr ASC" and
generateOrderItem(expr, false)
generates "expr DESC NULLS LAST".
On MySQL, where NULLs collate lower than all other values,
generateOrderItem(expr, true)
generates "ISNULL(expr), expr ASC"
and generateOrderItem(expr, false)
generates "expr DESC".
generateOrderItem
in interface Dialect
generateOrderItem
in class JdbcDialectImpl
expr
- Expressionnullable
- Whether expression may have NULL valuesascending
- Whether to sort expression ascending
public boolean requiresOrderByAlias()
Dialect
For example, in such a dialect,
SELECT x FROM t ORDER BY x + y
would be illegal, but
SELECT x, x + y AS z FROM t ORDER BY z
would be legal.
MySQL, DB2 and Ingres are examples of such dialects.
requiresOrderByAlias
in interface Dialect
requiresOrderByAlias
in class JdbcDialectImpl
public boolean supportsMultiValueInExpr()
Dialect
WHERE (col1, col2) IN ((val1a, val2a), (val1b, val2b))
supportsMultiValueInExpr
in interface Dialect
supportsMultiValueInExpr
in class JdbcDialectImpl
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |