pan3793 commented on code in PR #7029:
URL: https://github.com/apache/kyuubi/pull/7029#discussion_r2062481435
##########
kyuubi-server/src/main/scala/org/apache/kyuubi/server/metadata/jdbc/JdbcDatabaseDialect.scala:
##########
@@ -19,14 +19,71 @@ package org.apache.kyuubi.server.metadata.jdbc
trait JdbcDatabaseDialect {
def limitClause(limit: Int, offset: Int): String
+ def insertOrReplace(
+ table: String,
+ cols: Seq[String],
+ keyCol: String,
+ keyVal: String): String
}
class GenericDatabaseDialect extends JdbcDatabaseDialect {
override def limitClause(limit: Int, offset: Int): String = {
s"LIMIT $limit OFFSET $offset"
}
+
+ override def insertOrReplace(
+ table: String,
+ cols: Seq[String],
+ keyCol: String,
+ keyVal: String): String = {
+ s"""
+ |INSERT INTO $table (${cols.mkString(",")})
+ |SELECT ${cols.map(_ => "?").mkString(",")}
+ |WHERE NOT EXISTS (
+ | SELECT 1 FROM $table WHERE $keyCol = '$keyVal')
+ |)
+ |""".stripMargin
Review Comment:
lgtm
--
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]