cloud-fan commented on code in PR #39667:
URL: https://github.com/apache/spark/pull/39667#discussion_r1097263210


##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcSQLQueryBuilder.scala:
##########
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.jdbc
+
+import org.apache.spark.sql.connector.expressions.filter.Predicate
+import org.apache.spark.sql.execution.datasources.jdbc.{JDBCOptions, 
JDBCPartition}
+import org.apache.spark.sql.execution.datasources.v2.TableSampleInfo
+
+/**
+ * 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.4.0
+ */
+class JdbcSQLQueryBuilder(dialect: JdbcDialect, options: JDBCOptions) {
+
+  /**
+   * `columns`, but as a String suitable for injection into a SQL query.
+   */
+  protected var columnList: String = "1"
+
+  /**
+   * A WHERE clause representing both `filters`, if any, and the current 
partition.
+   */
+  protected var whereClause: String = ""
+
+  /**
+   * A GROUP BY clause representing pushed-down grouping columns.
+   */
+  protected var groupByClause: String = ""
+
+  /**
+   * A ORDER BY clause representing pushed-down sort of top n.
+   */
+  protected var orderByClause: String = ""
+
+  /**
+   * A LIMIT value representing pushed-down limit.
+   */
+  protected var limit: Int = -1
+
+  /**
+   * A OFFSET value representing pushed-down offset.
+   */
+  protected var offset: Int = -1
+
+  /**
+   * A table sample clause representing pushed-down table sample.
+   */
+  protected var tableSampleClause: String = ""
+
+  def withColumns(columns: Array[String]): JdbcSQLQueryBuilder = {

Review Comment:
   can we add api doc for each with method?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to