mondrian.spi.impl
Class TeradataDialect

java.lang.Object
  extended by mondrian.spi.impl.JdbcDialectImpl
      extended by mondrian.spi.impl.TeradataDialect
All Implemented Interfaces:
Dialect

public class TeradataDialect
extends JdbcDialectImpl

Implementation of Dialect for the Teradata database.

Since:
Nov 23, 2008
Version:
$Id: //open/mondrian/src/main/mondrian/spi/impl/TeradataDialect.java#4 $
Author:
jhyde

Nested Class Summary
 
Nested classes/interfaces inherited from interface mondrian.spi.Dialect
Dialect.DatabaseProduct, Dialect.Datatype, Dialect.NullCollation
 
Field Summary
static JdbcDialectFactory FACTORY
           
 
Fields inherited from class mondrian.spi.impl.JdbcDialectImpl
databaseProduct, permitsSelectNotInGroupBy, productVersion
 
Constructor Summary
TeradataDialect(java.sql.Connection connection)
          Creates a TeradataDialect.
 
Method Summary
 java.lang.String generateInline(java.util.List<java.lang.String> columnNames, java.util.List<java.lang.String> columnTypes, java.util.List<java.lang.String[]> valueList)
          Generates a SQL statement to represent an inline dataset.
 java.lang.String generateOrderItem(java.lang.String expr, boolean nullable, boolean ascending)
          Generates an item for an ORDER BY clause, sorting in the required direction, and ensuring that NULL values collate after all non-NULL values.
 Dialect.NullCollation getNullCollation()
          Returns the rule which determines whether NULL values appear first or last when sorted using ORDER BY.
 boolean requiresAliasForFromQuery()
          Returns whether this Dialect requires subqueries in the FROM clause to have an alias.
 boolean requiresUnionOrderByOrdinal()
          Returns true if this dialect allows only integers in the ORDER BY clause of a UNION (or other set operation) query.
 boolean supportsGroupingSets()
          Returns whether this Dialect allows the GROUPING SETS construct in the GROUP BY clause.
 
Methods inherited from class mondrian.spi.impl.JdbcDialectImpl
allowsAs, allowsCompoundCountDistinct, allowsCountDistinct, allowsDdl, allowsDialectSharing, allowsFromQuery, allowsMultipleCountDistinct, allowsMultipleDistinctSqlMeasures, allowsOrderByAlias, allowsSelectNotInGroupBy, appendHintsAfterFromClause, caseWhenElse, deduceIdentifierQuoteString, deduceMaxColumnNameLength, deduceProductName, deduceProductVersion, deduceReadOnly, deduceSupportedResultSetStyles, deduceSupportsSelectNotInGroupBy, generateInlineForAnsi, generateInlineGeneric, getDatabaseProduct, getMaxColumnNameLength, getProduct, getQuoteIdentifierString, needsExponent, quote, quoteBooleanLiteral, quoteDateLiteral, quoteDateLiteral, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteNumericLiteral, quoteStringLiteral, quoteTimeLiteral, quoteTimestampLiteral, requiresGroupByAlias, requiresOrderByAlias, requiresUnionOrderByExprToBeInSelectClause, supportsGroupByExpressions, supportsMultiValueInExpr, supportsOrderByNullsLast, supportsResultSetConcurrency, supportsUnlimitedValueList, toString, toUpper
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

FACTORY

public static final JdbcDialectFactory FACTORY
Constructor Detail

TeradataDialect

public TeradataDialect(java.sql.Connection connection)
                throws java.sql.SQLException
Creates a TeradataDialect.

Parameters:
connection - Connection
Throws:
java.sql.SQLException
Method Detail

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 interface Dialect
Overrides:
requiresAliasForFromQuery in class JdbcDialectImpl
Returns:
whether dialewct requires subqueries to have an alias
See Also:
Dialect.allowsFromQuery()

generateInline

public java.lang.String generateInline(java.util.List<java.lang.String> columnNames,
                                       java.util.List<java.lang.String> columnTypes,
                                       java.util.List<java.lang.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 interface Dialect
Overrides:
generateInline in class JdbcDialectImpl
Parameters:
columnNames - List of column names
columnTypes - List of column types ("String" or "Numeric")
valueList - List of rows values
Returns:
SQL string

supportsGroupingSets

public boolean supportsGroupingSets()
Description copied from interface: Dialect
Returns whether this Dialect allows the GROUPING SETS construct in the GROUP BY clause. Currently Oracle, DB2 and Teradata.

Specified by:
supportsGroupingSets in interface Dialect
Overrides:
supportsGroupingSets in class JdbcDialectImpl
Returns:
Whether this Dialect allows GROUPING SETS clause

getNullCollation

public Dialect.NullCollation getNullCollation()
Description copied from interface: Dialect
Returns the rule which determines whether NULL values appear first or last when sorted using ORDER BY.

According to the SQL standard, this is implementation-specific. The default behavior is Dialect.NullCollation.POSINF.

Specified by:
getNullCollation in interface Dialect
Overrides:
getNullCollation in class JdbcDialectImpl
Returns:
Rule which determines whether NULL values collate first or last

generateOrderItem

public java.lang.String generateOrderItem(java.lang.String expr,
                                          boolean nullable,
                                          boolean ascending)
Description copied from interface: Dialect
Generates an item for an ORDER BY clause, sorting in the required direction, and ensuring that NULL values collate after all non-NULL values.

By default, generateOrderItem(expr, true) generates "expr ASC" and generateOrderItem(expr, false) generates "expr DESC". But depending on Dialect.getNullCollation() and ascending, there may need to be additional code.

For example, on Oracle, where NULLs collate higher than all other values, generateOrderItem(expr, true) generates "expr ASC" and generateOrderItem(expr, false) generates "expr DESC NULLS LAST".

On MySQL, where NULLs collate lower than all other values, generateOrderItem(expr, true) generates "ISNULL(expr), expr ASC" and generateOrderItem(expr, false) generates "expr DESC".

Specified by:
generateOrderItem in interface Dialect
Overrides:
generateOrderItem in class JdbcDialectImpl
Parameters:
expr - Expression
nullable - Whether expression may have NULL values
ascending - Whether to sort expression ascending
Returns:
Expression modified so that NULL values collate last

requiresUnionOrderByOrdinal

public boolean requiresUnionOrderByOrdinal()
Description copied from interface: Dialect
Returns true if this dialect allows only integers in the ORDER BY clause of a UNION (or other set operation) query.

For example, SELECT x, y + z FROM t
UNION ALL
SELECT x, y + z FROM t
ORDER BY 1, 2
is allowed but SELECT x, y, z FROM t
UNION ALL
SELECT x, y, z FROM t
ORDER BY x
is not.

Teradata is an example of a dialect with this restriction.

Specified by:
requiresUnionOrderByOrdinal in interface Dialect
Overrides:
requiresUnionOrderByOrdinal in class JdbcDialectImpl
Returns:
whether this dialect allows only integers in the ORDER BY clause of a UNION (or other set operation) query

Get Mondrian at SourceForge.net. Fast, secure and free Open Source software downloads