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


##########
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:
   `Statement` is automatically committed by default, and it will be committed 
after executing a SQL statement. Therefore, there is no case where the commit 
of create table fails due to the exception of add comment. A single `Statement` 
is also used multiple times in `createSchema`, I don't think there is a problem



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