Skip to content

Commit

Permalink
fix: ClickHouse JDBC warnings about Transaction support
Browse files Browse the repository at this point in the history
Транзакции пока не поддерживаются ClickHouse.

Ref: ClickHouse/clickhouse-java#975
Ref: ClickHouse/clickhouse-java#1008 (comment)
  • Loading branch information
mixayloff-dimaaylov committed Mar 25, 2023
1 parent a7448af commit 55b600a
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/main/scala/com/infocom/examples/spark/TecCalculationV2.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.infocom.examples.spark

import java.nio.file.{Files, Paths}
import java.util.UUID
import java.util.{Properties, UUID}

import org.apache.spark.sql._
import org.apache.spark.sql.avro._
Expand Down Expand Up @@ -87,18 +87,20 @@ object TecCalculationV2 extends Serializable {
.option("subscribe", topic)
}

// Ref: /~https://github.com/ClickHouse/clickhouse-java/issues/975
// Ref: /~https://github.com/ClickHouse/clickhouse-java/pull/1008#issuecomment-1303964814
val jdbcProps = new Properties()
jdbcProps.setProperty("isolationLevel", "NONE")
jdbcProps.setProperty("numPartitions", "1")
jdbcProps.setProperty("user", "default")
jdbcProps.setProperty("password", "")

def jdbcSink(stream: DataFrame, tableName: String) = {
stream
.writeStream
.foreachBatch((batchDF: DataFrame, batchId: Long) => {
batchDF.write
.format("jdbc")
.mode("append")
.option("url", jdbcUri)
.option("dbtable", tableName)
.option("user", "default")
.option("password", "")
.save()
batchDF.write.mode("append")
.jdbc(jdbcUri, tableName, jdbcProps)
()
})
}
Expand Down

0 comments on commit 55b600a

Please sign in to comment.