Class GoogleBigQueryDialect

  • All Implemented Interfaces:
    Dialect

    public class GoogleBigQueryDialect
    extends JdbcDialectImpl
    This is the Mondrian dialect for Google BigQuery. It was tested against google-api-services-bigquery-v2-rev355-1.22.0 in Q1 2018.
    Author:
    lucboudreau
    • Method Detail

      • 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.
      • allowsAs

        public boolean allowsAs()
        Description copied from interface: Dialect
        Returns whether the SQL dialect allows "AS" in the FROM clause. If so, "SELECT * FROM t AS alias" is a valid query.
        Specified by:
        allowsAs in interface Dialect
        Overrides:
        allowsAs in class JdbcDialectImpl
        Returns:
        whether dialect allows AS in FROM clause
      • allowsDdl

        public boolean allowsDdl()
        Description copied from interface: Dialect
        Returns whether this dialect supports common SQL Data Definition Language (DDL) statements such as CREATE TABLE and DROP INDEX.

        Access seems to allow DDL iff the .mdb file is writeable.

        Specified by:
        allowsDdl in interface Dialect
        Overrides:
        allowsDdl in class JdbcDialectImpl
        Returns:
        whether this Dialect supports DDL
        See Also:
        DatabaseMetaData.isReadOnly()
      • 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
      • 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.