huangxiaopingRD commented on code in PR #39062:
URL: https://github.com/apache/spark/pull/39062#discussion_r1113802679


##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala:
##########
@@ -135,6 +135,34 @@ abstract class JdbcDialect extends Serializable with 
Logging {
     s""""$colName""""
   }
 
+  /**
+   * Create the table if the table does not exist.
+   * To allow certain options to append when create a new table, which can be
+   * table_options or partition_options.
+   * E.g., "CREATE TABLE t (name string) ENGINE=InnoDB DEFAULT CHARSET=utf8"
+   * @param statement
+   * @param tableName
+   * @param strSchema
+   * @param options
+   */
+  def createTable(
+      statement: Statement,
+      tableName: String,
+      strSchema: String,
+      options: JdbcOptionsInWrite): Unit = {
+    val createTableOptions = options.createTableOptions
+    statement.executeUpdate(s"CREATE TABLE $tableName ($strSchema) 
$createTableOptions")
+    if (options.tableComment.nonEmpty) {
+      try {
+        val tableCommentQuery = getTableCommentQuery(tableName, 
options.tableComment)
+        statement.executeUpdate(tableCommentQuery)

Review Comment:
   In the `createTable` of `JdbcUtils`, there is a finally code block to close 
the `Statement`



-- 
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