public class SnowflakeDialect extends JdbcDialectImpl
Modifier and Type | Class and Description |
---|---|
static class |
SnowflakeDialect.RegexParameters |
Dialect.DatabaseProduct, Dialect.Datatype
Modifier and Type | Field and Description |
---|---|
static JdbcDialectFactory |
FACTORY |
databaseProduct, permitsSelectNotInGroupBy, productVersion
Constructor and Description |
---|
SnowflakeDialect(Connection connection) |
Modifier and Type | Method and Description |
---|---|
boolean |
allowsOrderByAlias()
Returns true if aliases defined in the SELECT clause can be used as
expressions in the ORDER BY clause.
|
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.
|
String |
generateInline(List<String> columnNames,
List<String> columnTypes,
List<String[]> valueList)
Generates a SQL statement to represent an inline dataset.
|
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.
|
String |
getQuoteIdentifierString()
Returns the character which is used to quote identifiers, or null
if quoting is not supported.
|
void |
quoteStringLiteral(StringBuilder buf,
String s)
Appends to a buffer a single-quoted SQL string.
|
boolean |
requiresOrderByAlias()
Requires order by alias, in some cases:
For example: a select query that lists all the columns used in the ORDER_BY expression will succeed
SELECT "store_id", "unit_sales" FROM "sales_fact_1997" ORDER BY "store_id" + "unit_sales";
while a query that only has some of the columns used in the ORDER_BY expression will not:
SELECT "unit_sales" FROM "sales_fact_1997" ORDER BY "store_id" + "unit_sales"; |
allowsAs, allowsCompoundCountDistinct, allowsCountDistinct, allowsCountDistinctWithOtherAggs, allowsDdl, allowsDialectSharing, allowsFromQuery, allowsJoinOn, allowsMultipleCountDistinct, allowsMultipleDistinctSqlMeasures, appendHintsAfterFromClause, caseWhenElse, computeStatisticsProviders, deduceIdentifierQuoteString, deduceMaxColumnNameLength, deduceProductName, deduceProductVersion, deduceReadOnly, deduceSupportedResultSetStyles, deduceSupportsSelectNotInGroupBy, generateCountExpression, generateInlineForAnsi, generateInlineGeneric, generateOrderByNulls, generateOrderByNullsAnsi, generateOrderItem, getDatabaseProduct, getMaxColumnNameLength, getProduct, getStatisticsProviders, getType, isDatabase, needsExponent, quote, quoteBooleanLiteral, quoteDateLiteral, quoteDateLiteral, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteIdentifier, quoteNumericLiteral, quoteTimeLiteral, quoteTimestampLiteral, quoteTimestampLiteral, requiresAliasForFromQuery, requiresGroupByAlias, requiresHavingAlias, requiresUnionOrderByExprToBeInSelectClause, requiresUnionOrderByOrdinal, supportsGroupByExpressions, supportsGroupingSets, supportsMultiValueInExpr, supportsResultSetConcurrency, supportsUnlimitedValueList, toString, toUpper
public static final JdbcDialectFactory FACTORY
public SnowflakeDialect(Connection connection) throws SQLException
SQLException
public String getQuoteIdentifierString()
Dialect
getQuoteIdentifierString
in interface Dialect
getQuoteIdentifierString
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 valuespublic void quoteStringLiteral(StringBuilder buf, String s)
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 tos
- Literalpublic 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 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 boolean requiresOrderByAlias()
SELECT "store_id", "unit_sales" FROM "sales_fact_1997" ORDER BY "store_id" + "unit_sales";
while a query that only has some of the columns used in the ORDER_BY expression will not:
SELECT "unit_sales" FROM "sales_fact_1997" ORDER BY "store_id" + "unit_sales";
requiresOrderByAlias
in interface Dialect
requiresOrderByAlias
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.Copyright © 2020 Hitachi Vantara. All rights reserved.