Class JdbcSQLQueryBuilder

Object
org.apache.spark.sql.jdbc.JdbcSQLQueryBuilder
Direct Known Subclasses:
DB2Dialect.DB2SQLQueryBuilder, MsSqlServerDialect.MsSqlServerSQLQueryBuilder, MySQLDialect.MySQLSQLQueryBuilder, OracleDialect.OracleSQLQueryBuilder

public class JdbcSQLQueryBuilder extends Object
The builder to build a single SELECT query.

Note: All the withXXX methods will be invoked at most once. The invocation order does not matter, as all these clauses follow the natural SQL order: sample the table first, then filter, then group by, then sort, then offset, then limit.

Since:
3.5.0
  • Constructor Details

    • JdbcSQLQueryBuilder

      public JdbcSQLQueryBuilder(JdbcDialect dialect, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options)
  • Method Details

    • build

      public String build()
      Build the final SQL query that following dialect's SQL syntax.
      Returns:
      (undocumented)
    • withColumns

      public JdbcSQLQueryBuilder withColumns(String[] columns)
      The columns names that following dialect's SQL syntax. e.g. The column name is the raw name or quoted name.
      Parameters:
      columns - (undocumented)
      Returns:
      (undocumented)
    • withGroupByColumns

      public JdbcSQLQueryBuilder withGroupByColumns(String[] groupByColumns)
      Constructs the GROUP BY clause that following dialect's SQL syntax.
      Parameters:
      groupByColumns - (undocumented)
      Returns:
      (undocumented)
    • withLimit

      public JdbcSQLQueryBuilder withLimit(int limit)
      Saves the limit value used to construct LIMIT clause.
      Parameters:
      limit - (undocumented)
      Returns:
      (undocumented)
    • withOffset

      public JdbcSQLQueryBuilder withOffset(int offset)
      Saves the offset value used to construct OFFSET clause.
      Parameters:
      offset - (undocumented)
      Returns:
      (undocumented)
    • withPredicates

      public JdbcSQLQueryBuilder withPredicates(Predicate[] predicates, org.apache.spark.sql.execution.datasources.jdbc.JDBCPartition part)
      Constructs the WHERE clause that following dialect's SQL syntax.
      Parameters:
      predicates - (undocumented)
      part - (undocumented)
      Returns:
      (undocumented)
    • withSortOrders

      public JdbcSQLQueryBuilder withSortOrders(String[] sortOrders)
      Constructs the ORDER BY clause that following dialect's SQL syntax.
      Parameters:
      sortOrders - (undocumented)
      Returns:
      (undocumented)
    • withTableSample

      public JdbcSQLQueryBuilder withTableSample(org.apache.spark.sql.execution.datasources.v2.TableSampleInfo sample)
      Constructs the table sample clause that following dialect's SQL syntax.
      Parameters:
      sample - (undocumented)
      Returns:
      (undocumented)