Package org.apache.spark.sql.jdbc
Class JdbcSQLQueryBuilder
Object
org.apache.spark.sql.jdbc.JdbcSQLQueryBuilder
- Direct Known Subclasses:
DB2Dialect.DB2SQLQueryBuilder
,MsSqlServerDialect.MsSqlServerSQLQueryBuilder
,MySQLDialect.MySQLSQLQueryBuilder
,OracleDialect.OracleSQLQueryBuilder
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 Summary
ConstructorsConstructorDescriptionJdbcSQLQueryBuilder
(JdbcDialect dialect, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options) -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build the final SQL query that following dialect's SQL syntax.withAliasedColumns
(String[] columns, scala.Option<String>[] aliases) withColumns
(String[] columns) The columns names that following dialect's SQL syntax.withGroupByColumns
(String[] groupByColumns) Constructs the GROUP BY clause that following dialect's SQL syntax.withJoin
(JdbcSQLQueryBuilder left, JdbcSQLQueryBuilder right, String leftSideQualifier, String rightSideQualifier, String[] columns, String joinType, String joinCondition) withLimit
(int limit) Saves the limit value used to construct LIMIT clause.withOffset
(int offset) Saves the offset value used to construct OFFSET clause.withPredicates
(Predicate[] predicates, org.apache.spark.sql.execution.datasources.jdbc.JDBCPartition part) Constructs the WHERE clause that following dialect's SQL syntax.withSortOrders
(String[] sortOrders) Constructs the ORDER BY clause that following dialect's SQL syntax.withTableSample
(org.apache.spark.sql.execution.datasources.v2.TableSampleInfo sample) Constructs the table sample clause that following dialect's SQL syntax.
-
Constructor Details
-
JdbcSQLQueryBuilder
public JdbcSQLQueryBuilder(JdbcDialect dialect, org.apache.spark.sql.execution.datasources.jdbc.JDBCOptions options)
-
-
Method Details
-
build
Build the final SQL query that following dialect's SQL syntax.- Returns:
- (undocumented)
-
withAliasedColumns
-
withColumns
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
Constructs the GROUP BY clause that following dialect's SQL syntax.- Parameters:
groupByColumns
- (undocumented)- Returns:
- (undocumented)
-
withJoin
public JdbcSQLQueryBuilder withJoin(JdbcSQLQueryBuilder left, JdbcSQLQueryBuilder right, String leftSideQualifier, String rightSideQualifier, String[] columns, String joinType, String joinCondition) -
withLimit
Saves the limit value used to construct LIMIT clause.- Parameters:
limit
- (undocumented)- Returns:
- (undocumented)
-
withOffset
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
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)
-