public class ImpalaDialect extends HiveDialect
Dialect.DatabaseProduct, Dialect.Datatype
Modifier and Type | Field and Description |
---|---|
static JdbcDialectFactory |
FACTORY |
databaseProduct, permitsSelectNotInGroupBy, productVersion
Constructor and Description |
---|
ImpalaDialect(Connection connection)
Creates an ImpalaDialect.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allowsCompoundCountDistinct()
Returns whether this Dialect allows multiple arguments to the
COUNT(DISTINCT ...) aggregate function, for example
|
boolean |
allowsDdl()
Returns whether this dialect supports common SQL Data Definition
Language (DDL) statements such as
CREATE TABLE and
DROP 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 the
collateNullsLast
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, or
Dialect.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.
|
allowsAs, allowsOrderByAlias, deduceMaxColumnNameLength, deduceReadOnly, deduceSupportedResultSetStyles, quoteDateLiteral, quoteTimestampLiteral, requiresGroupByAlias, requiresUnionOrderByExprToBeInSelectClause, requiresUnionOrderByOrdinal
allowsCountDistinct, allowsCountDistinctWithOtherAggs, allowsDialectSharing, allowsFromQuery, allowsMultipleDistinctSqlMeasures, appendHintsAfterFromClause, caseWhenElse, computeStatisticsProviders, deduceProductName, deduceProductVersion, deduceSupportsSelectNotInGroupBy, generateCountExpression, generateInlineForAnsi, generateInlineGeneric, generateOrderByNullsAnsi, getMaxColumnNameLength, getProduct, getQuoteIdentifierString, getStatisticsProviders, getType, isDatabase, needsExponent, quote, quoteBooleanLiteral, quoteDateLiteral, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteNumericLiteral, quoteTimeLiteral, requiresHavingAlias, supportsGroupingSets, supportsMultiValueInExpr, supportsResultSetConcurrency, supportsUnlimitedValueList, toString, toUpper
public static final JdbcDialectFactory FACTORY
public ImpalaDialect(Connection connection) throws SQLException
connection
- ConnectionSQLException
- on errorprotected String deduceIdentifierQuoteString(DatabaseMetaData databaseMetaData)
deduceIdentifierQuoteString
in class HiveDialect
public Dialect.DatabaseProduct getDatabaseProduct()
Dialect
Dialect.DatabaseProduct.UNKNOWN
if the database is
not a common database.getDatabaseProduct
in interface Dialect
getDatabaseProduct
in class JdbcDialectImpl
protected String generateOrderByNulls(String expr, boolean ascending, boolean collateNullsLast)
JdbcDialectImpl
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.
generateOrderByNulls
in class HiveDialect
expr
- Expression.ascending
- Whether ascending.collateNullsLast
- Whether nulls should appear first or last.public String generateOrderItem(String expr, boolean nullable, boolean ascending, boolean collateNullsLast)
Dialect
collateNullsLast
parameter.generateOrderItem
in interface Dialect
generateOrderItem
in class JdbcDialectImpl
expr
- Expressionnullable
- Whether expression may have NULL valuesascending
- Whether to sort expression ascendingcollateNullsLast
- Whether the null values should be sorted first
or last.public boolean allowsMultipleCountDistinct()
Dialect
In Derby 10.1,
select couunt(distinct x) from t
is OK, but
select couunt(distinct x), count(distinct y) from t
gives "Multiple DISTINCT aggregates are not supported at this time."allowsMultipleCountDistinct
in interface Dialect
allowsMultipleCountDistinct
in class JdbcDialectImpl
public boolean allowsCompoundCountDistinct()
Dialect
COUNT(DISTINCT ...) aggregate function, for example
SELECT COUNT(DISTINCT x, y) FROM t
allowsCompoundCountDistinct
in interface Dialect
allowsCompoundCountDistinct
in class HiveDialect
Dialect.allowsCountDistinct()
,
Dialect.allowsMultipleCountDistinct()
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 HiveDialect
public boolean requiresAliasForFromQuery()
Dialect
requiresAliasForFromQuery
in interface Dialect
requiresAliasForFromQuery
in class HiveDialect
Dialect.allowsFromQuery()
public boolean supportsGroupByExpressions()
Dialect
supportsGroupByExpressions
in interface Dialect
supportsGroupByExpressions
in class JdbcDialectImpl
public boolean allowsSelectNotInGroupBy()
Dialect
For example, SELECT empno, first_name || ' ' || last_name FROM
emps GROUP BY empno
is valid because empno
is the primary key of
the emps
table, and therefore all columns are dependent on it.
For a given value of empno
,
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).
allowsSelectNotInGroupBy
in interface Dialect
allowsSelectNotInGroupBy
in class JdbcDialectImpl
public String generateInline(List<String> columnNames, List<String> columnTypes, List<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 HiveDialect
columnNames
- List of column namescolumnTypes
- List of column types ("String" or "Numeric")valueList
- List of rows valuespublic boolean allowsJoinOn()
Dialect
FROM leftTable JOIN rightTable ON conditon
.allowsJoinOn
in interface Dialect
allowsJoinOn
in class HiveDialect
public void quoteStringLiteral(StringBuilder buf, String value)
Dialect
For example, in the default dialect,
quoteStringLiteral(buf, "Can't")
appends
"'Can''t'
" to buf
.
quoteStringLiteral
in interface Dialect
quoteStringLiteral
in class JdbcDialectImpl
buf
- Buffer to append tovalue
- Literalpublic boolean allowsRegularExpressionInWhereClause()
Dialect
allowsRegularExpressionInWhereClause
in interface Dialect
allowsRegularExpressionInWhereClause
in class JdbcDialectImpl
public String generateRegularExpression(String source, String javaRegex)
Dialect
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.
generateRegularExpression
in interface Dialect
generateRegularExpression
in class JdbcDialectImpl
source
- A String identifying the column to match against.javaRegex
- A Java regular expression to match against.public boolean allowsDdl()
Dialect
CREATE TABLE
and
DROP INDEX
.
Access seems to allow DDL iff the .mdb file is writeable.
allowsDdl
in interface Dialect
allowsDdl
in class JdbcDialectImpl
DatabaseMetaData.isReadOnly()
Copyright © 2018 Hitachi Vantara. All rights reserved.