public class PostgreSqlDialect extends JdbcDialectImpl
Dialect
for the PostgreSQL database.Dialect.DatabaseProduct, Dialect.Datatype
Modifier and Type | Field and Description |
---|---|
static JdbcDialectFactory |
FACTORY |
databaseProduct, permitsSelectNotInGroupBy, productVersion
Constructor and Description |
---|
PostgreSqlDialect(Connection connection)
Creates a PostgreSqlDialect.
|
Modifier and Type | Method and Description |
---|---|
boolean |
allowsRegularExpressionInWhereClause()
Informs Mondrian if the dialect supports regular expressions
when creating the 'where' or the 'having' clause.
|
protected String |
generateOrderByNulls(String expr,
boolean ascending,
boolean collateNullsLast)
Generates SQL to force null values to collate last.
|
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. |
SqlStatement.Type |
getType(ResultSetMetaData metaData,
int columnIndex)
Chooses the most appropriate type for accessing the values of a
column in a result set for a dialect.
|
boolean |
requiresAliasForFromQuery()
Returns whether this Dialect requires subqueries in the FROM clause
to have an alias.
|
allowsAs, allowsCompoundCountDistinct, allowsCountDistinct, allowsCountDistinctWithOtherAggs, allowsDdl, allowsDialectSharing, allowsFromQuery, allowsJoinOn, allowsMultipleCountDistinct, allowsMultipleDistinctSqlMeasures, allowsOrderByAlias, allowsSelectNotInGroupBy, appendHintsAfterFromClause, caseWhenElse, computeStatisticsProviders, deduceIdentifierQuoteString, deduceMaxColumnNameLength, deduceProductName, deduceProductVersion, deduceReadOnly, deduceSupportedResultSetStyles, deduceSupportsSelectNotInGroupBy, generateCountExpression, generateInline, generateInlineForAnsi, generateInlineGeneric, generateOrderByNullsAnsi, generateOrderItem, getMaxColumnNameLength, getProduct, getQuoteIdentifierString, getStatisticsProviders, isDatabase, needsExponent, quote, quoteBooleanLiteral, quoteDateLiteral, quoteDateLiteral, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteNumericLiteral, quoteStringLiteral, quoteTimeLiteral, quoteTimestampLiteral, quoteTimestampLiteral, requiresGroupByAlias, requiresHavingAlias, requiresOrderByAlias, requiresUnionOrderByExprToBeInSelectClause, requiresUnionOrderByOrdinal, supportsGroupByExpressions, supportsGroupingSets, supportsMultiValueInExpr, supportsResultSetConcurrency, supportsUnlimitedValueList, toString, toUpper
public static final JdbcDialectFactory FACTORY
public PostgreSqlDialect(Connection connection) throws SQLException
connection
- ConnectionSQLException
public boolean requiresAliasForFromQuery()
Dialect
requiresAliasForFromQuery
in interface Dialect
requiresAliasForFromQuery
in class JdbcDialectImpl
Dialect.allowsFromQuery()
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 JdbcDialectImpl
expr
- Expression.ascending
- Whether ascending.collateNullsLast
- Whether nulls should appear first or last.public Dialect.DatabaseProduct getDatabaseProduct()
Dialect
Dialect.DatabaseProduct.UNKNOWN
if the database is
not a common database.getDatabaseProduct
in interface Dialect
getDatabaseProduct
in class JdbcDialectImpl
public 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 SqlStatement.Type getType(ResultSetMetaData metaData, int columnIndex) throws SQLException
Dialect
Chooses the most appropriate type for accessing the values of a column in a result set for a dialect.
Dialect-specific nuances involving type representation should be encapsulated in implementing methods. For example, if a dialect has implicit rules involving scale or precision, they should be handled within this method so the client can simply retrieve the "best fit" SqlStatement.Type for the column.
getType
in interface Dialect
getType
in class JdbcDialectImpl
metaData
- Results set metadatacolumnIndex
- Column ordinal (0-based)SQLException
Copyright © 2020 Hitachi Vantara. All rights reserved.