Class ImpalaDialect
- java.lang.Object
-
- mondrian.spi.impl.JdbcDialectImpl
-
- mondrian.spi.impl.HiveDialect
-
- mondrian.spi.impl.ImpalaDialect
-
- All Implemented Interfaces:
Dialect
public class ImpalaDialect extends HiveDialect
Dialect for Cloudera's Impala DB.- Since:
- 2/11/13
- Author:
- cboyden
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface mondrian.spi.Dialect
Dialect.DatabaseProduct, Dialect.Datatype
-
-
Field Summary
Fields Modifier and Type Field Description static JdbcDialectFactory
FACTORY
-
Fields inherited from class mondrian.spi.impl.JdbcDialectImpl
databaseProduct, permitsSelectNotInGroupBy, productVersion
-
-
Constructor Summary
Constructors Constructor Description ImpalaDialect(Connection connection)
Creates an ImpalaDialect.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
allowsCompoundCountDistinct()
Returns whether this Dialect allows multiple arguments to theCOUNT(DISTINCT ...) aggregate function, for example
SELECT COUNT(DISTINCT x, y) FROM t
boolean
allowsDdl()
Returns whether this dialect supports common SQL Data Definition Language (DDL) statements such asCREATE TABLE
andDROP INDEX
.boolean
allowsJoinOn()
Returns whether this dialect supports "ANSI-style JOIN syntax",FROM leftTable JOIN rightTable ON conditon
.boolean
allowsMultipleCountDistinct()
Returns whether this Dialect supports more than one distinct aggregation in the same query.boolean
allowsRegularExpressionInWhereClause()
Informs Mondrian if the dialect supports regular expressions when creating the 'where' or the 'having' clause.boolean
allowsSelectNotInGroupBy()
Returns whether the database currently permits queries to include in the SELECT clause expressions that are not listed in the GROUP BY clause.protected String
deduceIdentifierQuoteString(DatabaseMetaData databaseMetaData)
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
generateOrderItem(String expr, boolean nullable, boolean ascending, boolean collateNullsLast)
Generates an item for an ORDER BY clause, sorting in the required direction, and ensuring that NULL values collate either before or after all non-NULL values, depending on thecollateNullsLast
parameter.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.Dialect.DatabaseProduct
getDatabaseProduct()
Returns the database for this Dialect, orDialect.DatabaseProduct.UNKNOWN
if the database is not a common database.void
quoteStringLiteral(StringBuilder buf, String value)
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
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
supportsGroupByExpressions()
Returns whether this Dialect supports expressions in the GROUP BY clause.-
Methods inherited from class mondrian.spi.impl.HiveDialect
allowsAs, allowsOrderByAlias, deduceMaxColumnNameLength, deduceReadOnly, deduceSupportedResultSetStyles, quoteDateLiteral, quoteTimestampLiteral, requiresGroupByAlias, requiresUnionOrderByExprToBeInSelectClause, requiresUnionOrderByOrdinal
-
Methods inherited from class mondrian.spi.impl.JdbcDialectImpl
allowsCountDistinct, allowsCountDistinctWithOtherAggs, allowsDialectSharing, allowsFromQuery, allowsMultipleDistinctSqlMeasures, appendHintsAfterFromClause, caseWhenElse, computeStatisticsProviders, deduceProductName, deduceProductVersion, deduceSupportsSelectNotInGroupBy, extractEmbeddedFlags, generateCountExpression, generateInlineForAnsi, generateInlineGeneric, generateOrderByNullsAnsi, getMaxColumnNameLength, getProduct, getQuoteIdentifierString, getStatisticsProviders, getType, isDatabase, needsExponent, quote, quoteBooleanLiteral, quoteDateLiteral, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteNumericLiteral, quoteTimeLiteral, quoteTimestampLiteral, requiresHavingAlias, supportsGroupingSets, supportsMultiValueInExpr, supportsResultSetConcurrency, supportsUnlimitedValueList, toString, toUpper
-
-
-
-
Field Detail
-
FACTORY
public static final JdbcDialectFactory FACTORY
-
-
Constructor Detail
-
ImpalaDialect
public ImpalaDialect(Connection connection) throws SQLException
Creates an ImpalaDialect.- Parameters:
connection
- Connection- Throws:
SQLException
- on error
-
-
Method Detail
-
deduceIdentifierQuoteString
protected String deduceIdentifierQuoteString(DatabaseMetaData databaseMetaData)
- Overrides:
deduceIdentifierQuoteString
in classHiveDialect
-
getDatabaseProduct
public Dialect.DatabaseProduct getDatabaseProduct()
Description copied from interface:Dialect
Returns the database for this Dialect, orDialect.DatabaseProduct.UNKNOWN
if the database is not a common database.- Specified by:
getDatabaseProduct
in interfaceDialect
- Overrides:
getDatabaseProduct
in classJdbcDialectImpl
- Returns:
- Database
-
generateOrderByNulls
protected String generateOrderByNulls(String expr, boolean ascending, boolean collateNullsLast)
Description copied from class:JdbcDialectImpl
Generates SQL to force null values to collate last.This 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.- Overrides:
generateOrderByNulls
in classHiveDialect
- Parameters:
expr
- Expression.ascending
- Whether ascending.collateNullsLast
- Whether nulls should appear first or last.- Returns:
- Expression to force null values to collate last or first.
-
generateOrderItem
public String generateOrderItem(String expr, boolean nullable, boolean ascending, boolean collateNullsLast)
Description copied from interface:Dialect
Generates an item for an ORDER BY clause, sorting in the required direction, and ensuring that NULL values collate either before or after all non-NULL values, depending on thecollateNullsLast
parameter.- Specified by:
generateOrderItem
in interfaceDialect
- Overrides:
generateOrderItem
in classJdbcDialectImpl
- Parameters:
expr
- Expressionnullable
- Whether expression may have NULL valuesascending
- Whether to sort expression ascendingcollateNullsLast
- Whether the null values should be sorted first or last.- Returns:
- Expression modified so that NULL values collate last
-
allowsMultipleCountDistinct
public boolean allowsMultipleCountDistinct()
Description copied from interface:Dialect
Returns whether this Dialect supports more than one distinct aggregation in the same query.In Derby 10.1,
select couunt(distinct x) from t
select couunt(distinct x), count(distinct y) from t
- Specified by:
allowsMultipleCountDistinct
in interfaceDialect
- Overrides:
allowsMultipleCountDistinct
in classJdbcDialectImpl
- Returns:
- whether this Dialect supports more than one distinct aggregation in the same query
-
allowsCompoundCountDistinct
public boolean allowsCompoundCountDistinct()
Description copied from interface:Dialect
Returns whether this Dialect allows multiple arguments to theCOUNT(DISTINCT ...) aggregate function, for example
SELECT COUNT(DISTINCT x, y) FROM t
- Specified by:
allowsCompoundCountDistinct
in interfaceDialect
- Overrides:
allowsCompoundCountDistinct
in classHiveDialect
- Returns:
- whether Dialect allows multiple arguments to COUNT DISTINCT
- See Also:
Dialect.allowsCountDistinct()
,Dialect.allowsMultipleCountDistinct()
-
requiresOrderByAlias
public boolean requiresOrderByAlias()
Description copied from interface:Dialect
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.For example, in such a dialect,
SELECT x FROM t ORDER BY x + y
SELECT x, x + y AS z FROM t ORDER BY z
MySQL, DB2 and Ingres are examples of such dialects.
- Specified by:
requiresOrderByAlias
in interfaceDialect
- Overrides:
requiresOrderByAlias
in classHiveDialect
- Returns:
- Whether this Dialect can include expressions in the ORDER BY clause only by adding an expression to the SELECT clause and using its alias
-
requiresAliasForFromQuery
public boolean requiresAliasForFromQuery()
Description copied from interface:Dialect
Returns whether this Dialect requires subqueries in the FROM clause to have an alias.- Specified by:
requiresAliasForFromQuery
in interfaceDialect
- Overrides:
requiresAliasForFromQuery
in classHiveDialect
- Returns:
- whether dialewct requires subqueries to have an alias
- See Also:
Dialect.allowsFromQuery()
-
supportsGroupByExpressions
public boolean supportsGroupByExpressions()
Description copied from interface:Dialect
Returns whether this Dialect supports expressions in the GROUP BY clause. Derby/Cloudscape and Infobright do not.- Specified by:
supportsGroupByExpressions
in interfaceDialect
- Overrides:
supportsGroupByExpressions
in classJdbcDialectImpl
- Returns:
- Whether this Dialect allows expressions in the GROUP BY clause
-
allowsSelectNotInGroupBy
public boolean allowsSelectNotInGroupBy()
Description copied from interface:Dialect
Returns whether the database currently permits queries to include in the SELECT clause expressions that are not listed in the GROUP BY clause. The SQL standard allows this if the database can deduce that the expression is functionally dependent on columns in the GROUP BY clause.For example,
SELECT empno, first_name || ' ' || last_name FROM emps GROUP BY empno
is valid becauseempno
is the primary key of theemps
table, and therefore all columns are dependent on it. For a given value ofempno
,first_name || ' ' || last_name
has a unique value.Most databases do not, MySQL is an example of one that does (if the functioality is enabled).
- Specified by:
allowsSelectNotInGroupBy
in interfaceDialect
- Overrides:
allowsSelectNotInGroupBy
in classJdbcDialectImpl
- Returns:
- Whether this Dialect allows SELECT clauses to contain columns that are not in the GROUP BY clause
-
generateInline
public String generateInline(List<String> columnNames, List<String> columnTypes, List<String[]> valueList)
Description copied from interface:Dialect
Generates a SQL statement to represent an inline dataset.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')
- Specified by:
generateInline
in interfaceDialect
- Overrides:
generateInline
in classHiveDialect
- Parameters:
columnNames
- List of column namescolumnTypes
- List of column types ("String" or "Numeric")valueList
- List of rows values- Returns:
- SQL string
-
allowsJoinOn
public boolean allowsJoinOn()
Description copied from interface:Dialect
Returns whether this dialect supports "ANSI-style JOIN syntax",FROM leftTable JOIN rightTable ON conditon
.- Specified by:
allowsJoinOn
in interfaceDialect
- Overrides:
allowsJoinOn
in classHiveDialect
- Returns:
- Whether this dialect supports FROM-JOIN-ON syntax.
-
quoteStringLiteral
public void quoteStringLiteral(StringBuilder buf, String value)
Description copied from interface:Dialect
Appends to a buffer a single-quoted SQL string.For example, in the default dialect,
quoteStringLiteral(buf, "Can't")
appends "'Can''t'
" tobuf
.- Specified by:
quoteStringLiteral
in interfaceDialect
- Overrides:
quoteStringLiteral
in classJdbcDialectImpl
- Parameters:
buf
- Buffer to append tovalue
- Literal
-
allowsRegularExpressionInWhereClause
public boolean allowsRegularExpressionInWhereClause()
Description copied from interface:Dialect
Informs Mondrian if the dialect supports regular expressions when creating the 'where' or the 'having' clause.- Specified by:
allowsRegularExpressionInWhereClause
in interfaceDialect
- Overrides:
allowsRegularExpressionInWhereClause
in classJdbcDialectImpl
- Returns:
- True if regular expressions are supported.
-
generateRegularExpression
public String generateRegularExpression(String source, String javaRegex)
Description copied from interface:Dialect
Must generate a String representing a regular expression match operation between a string literal and a Java regular expression. The string literal might be a column identifier or some other identifier, but the implementation must presume that it is already escaped and fit for use. The regular expression is not escaped and must be adapted to the proper dialect rules.Postgres / 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.
- Specified by:
generateRegularExpression
in interfaceDialect
- Overrides:
generateRegularExpression
in classJdbcDialectImpl
- Parameters:
source
- A String identifying the column to match against.javaRegex
- A Java regular expression to match against.- Returns:
- A dialect specific matching operation, or null if the dialect cannot convert that particular regular expression into something that the database would support.
-
allowsDdl
public boolean allowsDdl()
Description copied from interface:Dialect
Returns whether this dialect supports common SQL Data Definition Language (DDL) statements such asCREATE TABLE
andDROP INDEX
.Access seems to allow DDL iff the .mdb file is writeable.
- Specified by:
allowsDdl
in interfaceDialect
- Overrides:
allowsDdl
in classJdbcDialectImpl
- Returns:
- whether this Dialect supports DDL
- See Also:
DatabaseMetaData.isReadOnly()
-
-