|
|||||||||
| 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 |
| Field Summary | |
|---|---|
static JdbcDialectFactory |
FACTORY
|
| Fields inherited from class mondrian.spi.impl.JdbcDialectImpl |
|---|
databaseProduct, permitsSelectNotInGroupBy, productVersion |
| Constructor Summary | |
|---|---|
MySqlDialect(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 |
boolean |
allowsRegularExpressionInWhereClause()
Informs Mondrian if the dialect supports regular expressions when creating the 'where' or the 'having' clause. |
void |
appendHintsAfterFromClause(StringBuilder buf,
Map<String,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 String |
deduceIdentifierQuoteString(DatabaseMetaData databaseMetaData)
|
protected String |
deduceProductName(DatabaseMetaData databaseMetaData)
|
protected boolean |
deduceSupportsSelectNotInGroupBy(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. |
String |
generateInline(List<String> columnNames,
List<String> columnTypes,
List<String[]> valueList)
Generates a SQL statement to represent an inline dataset. |
protected String |
generateOrderByNulls(String expr,
boolean ascending,
boolean collateNullsLast)
Generates SQL to force null values to collate last. |
String |
generateRegularExpression(String source,
String javaRegex)
Must generate a String representing a regular expression match operation between a string literal and a Java regular expression. |
static boolean |
isInfobright(DatabaseMetaData databaseMetaData)
Detects whether this database is Infobright. |
void |
quoteStringLiteral(StringBuilder buf,
String s)
Appends to a buffer a single-quoted SQL string. |
boolean |
requiresAliasForFromQuery()
Returns whether this Dialect requires subqueries in the FROM clause to have an alias. |
boolean |
requiresHavingAlias()
Returns true if this Dialect can include expressions in the HAVING clause only by adding an expression to the SELECT clause and using its 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(Connection connection)
throws SQLException
connection - Connection
SQLException - on error| Method Detail |
|---|
public static boolean isInfobright(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 String deduceProductName(DatabaseMetaData databaseMetaData)
deduceProductName in class JdbcDialectImplprotected String deduceIdentifierQuoteString(DatabaseMetaData databaseMetaData)
deduceIdentifierQuoteString in class JdbcDialectImpl
protected boolean deduceSupportsSelectNotInGroupBy(Connection connection)
throws SQLException
JdbcDialectImplDetects 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 JdbcDialectImplconnection - The database connection
SQLException - on error
public void appendHintsAfterFromClause(StringBuilder buf,
Map<String,String> hints)
Dialect
appendHintsAfterFromClause in interface DialectappendHintsAfterFromClause in class JdbcDialectImplbuf - 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 DialectrequiresAliasForFromQuery in class JdbcDialectImplDialect.allowsFromQuery()public boolean allowsFromQuery()
DialectSELECT * FROM (SELECT * FROM t) AS
x
allowsFromQuery in interface DialectallowsFromQuery in class JdbcDialectImplDialect.requiresAliasForFromQuery()public boolean allowsCompoundCountDistinct()
DialectCOUNT(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 void quoteStringLiteral(StringBuilder buf,
String s)
DialectFor example, in the default dialect,
quoteStringLiteral(buf, "Can't") appends
"'Can''t'" to buf.
quoteStringLiteral in interface DialectquoteStringLiteral in class JdbcDialectImplbuf - Buffer to append tos - Literal
public String generateInline(List<String> columnNames,
List<String> columnTypes,
List<String[]> valueList)
DialectFor 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 DialectgenerateInline in class JdbcDialectImplcolumnNames - List of column namescolumnTypes - List of column types ("String" or "Numeric")valueList - List of rows values
protected String generateOrderByNulls(String expr,
boolean ascending,
boolean collateNullsLast)
JdbcDialectImplThis default implementation makes use of the ANSI SQL 1999 CASE-WHEN-THEN-ELSE in conjunction with IS NULL syntax. The resulting SQL will look something like this:
CASE WHEN "expr" IS NULL THEN 0 ELSE 1 END
You can override this method for a particular database to use something more efficient, like ISNULL().
ANSI SQL provides the syntax "ASC/DESC NULLS LAST" and
"ASC/DESC NULLS FIRST". If your database supports the ANSI
syntax, implement this method by calling
JdbcDialectImpl.generateOrderByNullsAnsi(java.lang.String, boolean, boolean).
This method is only called from
JdbcDialectImpl.generateOrderItem(String, boolean, boolean, boolean).
Some dialects override that method and therefore never call
this method.
generateOrderByNulls in class JdbcDialectImplexpr - Expression.ascending - Whether ascending.collateNullsLast - Whether nulls should appear first or last.
public boolean requiresOrderByAlias()
DialectFor 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 DialectrequiresOrderByAlias in class JdbcDialectImplpublic boolean requiresHavingAlias()
DialectFor example, in such a dialect,
SELECT CONCAT(x) as foo FROM t HAVING CONCAT(x) LIKE "%"
would be illegal, but
SELECT CONCAT(x) as foo FROM t HAVING foo LIKE "%"
would be legal.
MySQL is an example of such dialects.
requiresHavingAlias in interface DialectrequiresHavingAlias in class JdbcDialectImplpublic boolean supportsMultiValueInExpr()
DialectWHERE (col1, col2) IN ((val1a, val2a), (val1b, val2b))
supportsMultiValueInExpr in interface DialectsupportsMultiValueInExpr in class JdbcDialectImplpublic boolean allowsRegularExpressionInWhereClause()
Dialect
allowsRegularExpressionInWhereClause in interface DialectallowsRegularExpressionInWhereClause in class JdbcDialectImpl
public String generateRegularExpression(String source,
String javaRegex)
DialectPostgres / Greenplum example:
generateRegularExpression(
"'foodmart'.'customer_name'", "(?i).*oo.*") ->
'foodmart'.'customer_name' ~ "(?i).*oo.*"
Oracle example:
generateRegularExpression(
"'foodmart'.'customer_name'", ".*oo.*") ->
REGEXP_LIKE('foodmart'.'customer_name', ".*oo.*")
Dialects are allowed to return null if the dialect cannot convert that particular regular expression into something that the database would support.
generateRegularExpression in interface DialectgenerateRegularExpression in class JdbcDialectImplsource - A String identifying the column to match against.javaRegex - A Java regular expression to match against.
|
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||