Class SparkSqlDialect

java.lang.Object
org.apache.calcite.sql.SqlDialect
org.apache.calcite.sql.dialect.SparkSqlDialect

public class SparkSqlDialect extends SqlDialect
A SqlDialect implementation for the APACHE SPARK database.
  • Field Details

  • Constructor Details

    • SparkSqlDialect

      public SparkSqlDialect(SqlDialect.Context context)
      Creates a SparkSqlDialect.
  • Method Details

    • allowsAs

      protected boolean allowsAs()
      Overrides:
      allowsAs in class SqlDialect
    • supportsCharSet

      public boolean supportsCharSet()
      Description copied from class: SqlDialect
      Returns whether the dialect supports character set names as part of a data type, for instance VARCHAR(30) CHARACTER SET `ISO-8859-1`.
      Overrides:
      supportsCharSet in class SqlDialect
    • emulateJoinTypeForCrossJoin

      public JoinType emulateJoinTypeForCrossJoin()
      Overrides:
      emulateJoinTypeForCrossJoin in class SqlDialect
    • supportsGroupByWithRollup

      public boolean supportsGroupByWithRollup()
      Description copied from class: SqlDialect
      Returns whether this dialect supports "WITH ROLLUP" in the "GROUP BY" clause.

      For instance, in MySQL version 5,

      SELECT deptno, job, COUNT(*) AS c FROM emp GROUP BY deptno, job WITH ROLLUP

      is equivalent to standard SQL

      SELECT deptno, job, COUNT(*) AS c FROM emp GROUP BY ROLLUP(deptno, job) ORDER BY deptno, job

      The "WITH ROLLUP" clause was introduced in MySQL and is not standard SQL.

      See also SqlDialect.supportsAggregateFunction(SqlKind) applied to SqlKind.ROLLUP, which returns true in MySQL 8 and higher.

      Overrides:
      supportsGroupByWithRollup in class SqlDialect
    • supportsNestedAggregations

      public boolean supportsNestedAggregations()
      Description copied from class: SqlDialect
      Returns whether the dialect supports nested aggregations, for instance SELECT SUM(SUM(1)) .
      Overrides:
      supportsNestedAggregations in class SqlDialect
    • supportsAggregateFunction

      public boolean supportsAggregateFunction(SqlKind kind)
      Overrides:
      supportsAggregateFunction in class SqlDialect
    • supportsApproxCountDistinct

      public boolean supportsApproxCountDistinct()
      Description copied from class: SqlDialect
      Returns whether this dialect supports APPROX_COUNT_DISTINCT functions.
      Overrides:
      supportsApproxCountDistinct in class SqlDialect
    • supportsGroupByWithCube

      public boolean supportsGroupByWithCube()
      Description copied from class: SqlDialect
      Returns whether this dialect supports "WITH CUBE" in "GROUP BY" clause.
      Overrides:
      supportsGroupByWithCube in class SqlDialect
    • supportsTimestampPrecision

      public boolean supportsTimestampPrecision()
      Description copied from class: SqlDialect
      Returns whether this dialect supports TIMESTAMP with precision.
      Overrides:
      supportsTimestampPrecision in class SqlDialect
    • unparseOffsetFetch

      public void unparseOffsetFetch(SqlWriter writer, @Nullable SqlNode offset, @Nullable SqlNode fetch)
      Description copied from class: SqlDialect
      Converts an offset and fetch into SQL.

      At least one of offset and fetch must be provided.

      Common options:

      • OFFSET offset ROWS FETCH NEXT fetch ROWS ONLY (ANSI standard SQL, Oracle, PostgreSQL, and the default)
      • LIMIT fetch OFFSET offset (Apache Hive, MySQL, Redshift)
      Overrides:
      unparseOffsetFetch in class SqlDialect
      Parameters:
      writer - Writer
      offset - Number of rows to skip before emitting, or null
      fetch - Number of rows to fetch, or null
      See Also:
    • unparseCall

      public void unparseCall(SqlWriter writer, SqlCall call, int leftPrec, int rightPrec)
      Overrides:
      unparseCall in class SqlDialect
    • getCastSpec

      public @Nullable SqlNode getCastSpec(RelDataType type)
      Description copied from class: SqlDialect
      Returns SqlNode for type in "cast(column as type)", which might be different between databases by type name, precision etc.

      If this method returns null, the cast will be omitted. In the default implementation, this is the case for the NULL type, and therefore CAST(NULL AS <nulltype>) is rendered as NULL.

      Overrides:
      getCastSpec in class SqlDialect