public class HiveDialect extends JdbcDialectImpl
Dialect for the Hive database.Dialect.DatabaseProduct, Dialect.Datatype| Modifier and Type | Field and Description |
|---|---|
static JdbcDialectFactory |
FACTORY |
databaseProduct, permitsSelectNotInGroupBy, productVersion| Constructor and Description |
|---|
HiveDialect(Connection connection)
Creates a HiveDialect.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
allowsAs()
Returns whether the SQL dialect allows "AS" in the FROM clause.
|
boolean |
allowsCompoundCountDistinct()
Returns whether this Dialect allows multiple arguments to the
COUNT(DISTINCT ...) aggregate function, for example
|
boolean |
allowsJoinOn()
Returns whether this dialect supports "ANSI-style JOIN syntax",
FROM leftTable JOIN rightTable ON conditon. |
boolean |
allowsOrderByAlias()
Returns true if aliases defined in the SELECT clause can be used as
expressions in the ORDER BY clause.
|
protected String |
deduceIdentifierQuoteString(DatabaseMetaData databaseMetaData) |
protected int |
deduceMaxColumnNameLength(DatabaseMetaData databaseMetaData) |
protected boolean |
deduceReadOnly(DatabaseMetaData databaseMetaData) |
protected Set<List<Integer>> |
deduceSupportedResultSetStyles(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.
|
protected void |
quoteDateLiteral(StringBuilder buf,
String value,
Date date)
Helper method for
JdbcDialectImpl.quoteDateLiteral(StringBuilder, String). |
void |
quoteTimestampLiteral(StringBuilder buf,
String value)
Appends to a buffer a timestamp literal.
|
boolean |
requiresAliasForFromQuery()
Returns whether this Dialect requires subqueries in the FROM clause
to have an alias.
|
boolean |
requiresGroupByAlias()
Returns true if this Dialect can include expressions in the GROUP BY
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 |
requiresUnionOrderByExprToBeInSelectClause()
Returns true if this dialect allows an expression in the ORDER BY
clause of a UNION (or other set operation) query only if it occurs in
the SELECT clause.
|
boolean |
requiresUnionOrderByOrdinal()
Returns true if this dialect allows only integers in the ORDER BY
clause of a UNION (or other set operation) query.
|
allowsCountDistinct, allowsCountDistinctWithOtherAggs, allowsDdl, allowsDialectSharing, allowsFromQuery, allowsMultipleCountDistinct, allowsMultipleDistinctSqlMeasures, allowsRegularExpressionInWhereClause, allowsSelectNotInGroupBy, appendHintsAfterFromClause, caseWhenElse, computeStatisticsProviders, deduceProductName, deduceProductVersion, deduceSupportsSelectNotInGroupBy, extractEmbeddedFlags, generateCountExpression, generateInlineForAnsi, generateInlineGeneric, generateOrderByNullsAnsi, generateOrderItem, generateRegularExpression, getDatabaseProduct, getMaxColumnNameLength, getProduct, getQuoteIdentifierString, getStatisticsProviders, getType, isDatabase, needsExponent, quote, quoteBooleanLiteral, quoteDateLiteral, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteNumericLiteral, quoteStringLiteral, quoteTimeLiteral, quoteTimestampLiteral, requiresHavingAlias, supportsGroupByExpressions, supportsGroupingSets, supportsMultiValueInExpr, supportsResultSetConcurrency, supportsUnlimitedValueList, toString, toUpperpublic static final JdbcDialectFactory FACTORY
public HiveDialect(Connection connection) throws SQLException
connection - ConnectionSQLException - on errorprotected String deduceIdentifierQuoteString(DatabaseMetaData databaseMetaData)
deduceIdentifierQuoteString in class JdbcDialectImplprotected Set<List<Integer>> deduceSupportedResultSetStyles(DatabaseMetaData databaseMetaData)
deduceSupportedResultSetStyles in class JdbcDialectImplprotected boolean deduceReadOnly(DatabaseMetaData databaseMetaData)
deduceReadOnly in class JdbcDialectImplprotected int deduceMaxColumnNameLength(DatabaseMetaData databaseMetaData)
deduceMaxColumnNameLength in class JdbcDialectImplpublic boolean allowsCompoundCountDistinct()
DialectCOUNT(DISTINCT ...) aggregate function, for example
SELECT COUNT(DISTINCT x, y) FROM t
allowsCompoundCountDistinct in interface DialectallowsCompoundCountDistinct in class JdbcDialectImplDialect.allowsCountDistinct(),
Dialect.allowsMultipleCountDistinct()public boolean requiresAliasForFromQuery()
DialectrequiresAliasForFromQuery in interface DialectrequiresAliasForFromQuery in class JdbcDialectImplDialect.allowsFromQuery()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 allowsOrderByAlias()
DialectFor example, in such a dialect,
SELECT x, x + y AS z FROM t ORDER BY z
would be legal.
MySQL, DB2 and Ingres are examples of dialects where this is true; Access is a dialect where this is false.
allowsOrderByAlias in interface DialectallowsOrderByAlias in class JdbcDialectImplpublic boolean requiresGroupByAlias()
DialectFor example, in such a dialect,
SELECT x, x FROM t GROUP BY x
would be illegal, but
SELECT x AS a, x AS b FROM t ORDER BY a, b
would be legal.
Infobright is the only such dialect.
requiresGroupByAlias in interface DialectrequiresGroupByAlias in class JdbcDialectImplpublic boolean requiresUnionOrderByExprToBeInSelectClause()
DialectFor example,
SELECT x, y + z FROM t
is allowed but
UNION ALL
SELECT x, y + z FROM t
ORDER BY y + zSELECT x, y, z FROM t
UNION ALL
SELECT x, y, z FROM t
ORDER BY y + zSELECT x, y, z FROM t ORDER BY y + z
is not.
Access is an example of a dialect with this restriction.
requiresUnionOrderByExprToBeInSelectClause in interface DialectrequiresUnionOrderByExprToBeInSelectClause in class JdbcDialectImplpublic boolean requiresUnionOrderByOrdinal()
DialectFor example,
SELECT x, y + z FROM t
is allowed but
UNION ALL
SELECT x, y + z FROM t
ORDER BY 1, 2SELECT x, y, z FROM t
is not.
UNION ALL
SELECT x, y, z FROM t
ORDER BY x
Teradata is an example of a dialect with this restriction.
requiresUnionOrderByOrdinal in interface DialectrequiresUnionOrderByOrdinal in class JdbcDialectImplpublic 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 valuesprotected void quoteDateLiteral(StringBuilder buf, String value, Date date)
JdbcDialectImplJdbcDialectImpl.quoteDateLiteral(StringBuilder, String).quoteDateLiteral in class JdbcDialectImplbuf - Buffer to append tovalue - Value as stringdate - Value as dateprotected 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 allowsAs()
DialectallowsAs in interface DialectallowsAs in class JdbcDialectImplpublic boolean allowsJoinOn()
DialectFROM leftTable JOIN rightTable ON conditon.allowsJoinOn in interface DialectallowsJoinOn in class JdbcDialectImplpublic void quoteTimestampLiteral(StringBuilder buf, String value)
DialectFor example, in the default dialect,
quoteStringLiteral(buf, "1969-03-17 12:34:56")
appends TIMESTAMP '1969-03-17 12:34:56'.
quoteTimestampLiteral in interface DialectquoteTimestampLiteral in class JdbcDialectImplbuf - Buffer to append tovalue - LiteralCopyright © 2021 Hitachi Vantara. All rights reserved.