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, 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, toUpper
public static final JdbcDialectFactory FACTORY
public HiveDialect(Connection connection) throws SQLException
connection
- ConnectionSQLException
- on errorprotected String deduceIdentifierQuoteString(DatabaseMetaData databaseMetaData)
deduceIdentifierQuoteString
in class JdbcDialectImpl
protected Set<List<Integer>> deduceSupportedResultSetStyles(DatabaseMetaData databaseMetaData)
deduceSupportedResultSetStyles
in class JdbcDialectImpl
protected boolean deduceReadOnly(DatabaseMetaData databaseMetaData)
deduceReadOnly
in class JdbcDialectImpl
protected int deduceMaxColumnNameLength(DatabaseMetaData databaseMetaData)
deduceMaxColumnNameLength
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 JdbcDialectImpl
Dialect.allowsCountDistinct()
,
Dialect.allowsMultipleCountDistinct()
public boolean requiresAliasForFromQuery()
Dialect
requiresAliasForFromQuery
in interface Dialect
requiresAliasForFromQuery
in class JdbcDialectImpl
Dialect.allowsFromQuery()
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 allowsOrderByAlias()
Dialect
For 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 Dialect
allowsOrderByAlias
in class JdbcDialectImpl
public boolean requiresGroupByAlias()
Dialect
For 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 Dialect
requiresGroupByAlias
in class JdbcDialectImpl
public boolean requiresUnionOrderByExprToBeInSelectClause()
Dialect
For 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 Dialect
requiresUnionOrderByExprToBeInSelectClause
in class JdbcDialectImpl
public boolean requiresUnionOrderByOrdinal()
Dialect
For 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 Dialect
requiresUnionOrderByOrdinal
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 JdbcDialectImpl
columnNames
- List of column namescolumnTypes
- List of column types ("String" or "Numeric")valueList
- List of rows valuesprotected void quoteDateLiteral(StringBuilder buf, String value, Date date)
JdbcDialectImpl
JdbcDialectImpl.quoteDateLiteral(StringBuilder, String)
.quoteDateLiteral
in class JdbcDialectImpl
buf
- Buffer to append tovalue
- Value as stringdate
- Value as dateprotected 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 JdbcDialectImpl
expr
- Expression.ascending
- Whether ascending.collateNullsLast
- Whether nulls should appear first or last.public boolean allowsAs()
Dialect
allowsAs
in interface Dialect
allowsAs
in class JdbcDialectImpl
public boolean allowsJoinOn()
Dialect
FROM leftTable JOIN rightTable ON conditon
.allowsJoinOn
in interface Dialect
allowsJoinOn
in class JdbcDialectImpl
public void quoteTimestampLiteral(StringBuilder buf, String value)
Dialect
For example, in the default dialect,
quoteStringLiteral(buf, "1969-03-17 12:34:56")
appends TIMESTAMP '1969-03-17 12:34:56'
.
quoteTimestampLiteral
in interface Dialect
quoteTimestampLiteral
in class JdbcDialectImpl
buf
- Buffer to append tovalue
- LiteralCopyright © 2019 Hitachi Vantara. All rights reserved.