Class SnowflakeDialect

java.lang.Object
mondrian.spi.impl.JdbcDialectImpl
mondrian.spi.impl.SnowflakeDialect
All Implemented Interfaces:
Dialect

public class SnowflakeDialect extends JdbcDialectImpl
  • Field Details

  • Constructor Details

  • Method Details

    • getQuoteIdentifierString

      public String getQuoteIdentifierString()
      Description copied from interface: Dialect
      Returns the character which is used to quote identifiers, or null if quoting is not supported.
      Specified by:
      getQuoteIdentifierString in interface Dialect
      Overrides:
      getQuoteIdentifierString in class JdbcDialectImpl
      Returns:
      identifier quote
    • generateInline

      public String generateInline(List<String> columnNames, List<String> columnTypes, List<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
    • quoteStringLiteral

      public void quoteStringLiteral(StringBuilder buf, String s)
      Description copied from interface: Dialect
      Appends to a buffer a single-quoted SQL string.

      For example, in the default dialect, quoteStringLiteral(buf, "Can't") appends "'Can''t'" to buf.

      Specified by:
      quoteStringLiteral in interface Dialect
      Overrides:
      quoteStringLiteral in class JdbcDialectImpl
      Parameters:
      buf - Buffer to append to
      s - Literal
    • allowsOrderByAlias

      public boolean allowsOrderByAlias()
      Description copied from interface: Dialect
      Returns true if aliases defined in the SELECT clause can be used as expressions in the ORDER BY clause.

      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.

      Specified by:
      allowsOrderByAlias in interface Dialect
      Overrides:
      allowsOrderByAlias in class JdbcDialectImpl
      Returns:
      Whether aliases defined in the SELECT clause can be used as expressions in the ORDER BY clause.
    • allowsSelectNotInGroupBy

      public boolean allowsSelectNotInGroupBy()
      Description copied from interface: Dialect
      Returns whether the database currently permits queries to include in the SELECT clause expressions that are not listed in the GROUP BY clause. The SQL standard allows this if the database can deduce that the expression is functionally dependent on columns in the GROUP BY clause.

      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).

      Specified by:
      allowsSelectNotInGroupBy in interface Dialect
      Overrides:
      allowsSelectNotInGroupBy in class JdbcDialectImpl
      Returns:
      Whether this Dialect allows SELECT clauses to contain columns that are not in the GROUP BY clause
    • allowsRegularExpressionInWhereClause

      public boolean allowsRegularExpressionInWhereClause()
      Description copied from interface: Dialect
      Informs Mondrian if the dialect supports regular expressions when creating the 'where' or the 'having' clause.
      Specified by:
      allowsRegularExpressionInWhereClause in interface Dialect
      Overrides:
      allowsRegularExpressionInWhereClause in class JdbcDialectImpl
      Returns:
      True if regular expressions are supported.
    • getType

      public SqlStatement.Type getType(ResultSetMetaData metaData, int columnIndex) throws SQLException
      Description copied from interface: 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.

      Specified by:
      getType in interface Dialect
      Overrides:
      getType in class JdbcDialectImpl
      Parameters:
      metaData - Results set metadata
      columnIndex - Column ordinal (0-based)
      Returns:
      the most appropriate SqlStatement.Type for the column
      Throws:
      SQLException
    • generateRegularExpression

      public String generateRegularExpression(String source, String javaRegex)
      Description copied from interface: Dialect
      Must generate a String representing a regular expression match operation between a string literal and a Java regular expression. The string literal might be a column identifier or some other identifier, but the implementation must presume that it is already escaped and fit for use. The regular expression is not escaped and must be adapted to the proper dialect rules.

      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.

      Specified by:
      generateRegularExpression in interface Dialect
      Overrides:
      generateRegularExpression in class JdbcDialectImpl
      Parameters:
      source - A String identifying the column to match against.
      javaRegex - A Java regular expression to match against.
      Returns:
      A dialect specific matching operation, or null if the dialect cannot convert that particular regular expression into something that the database would support.