最近在用 spark 通过 jdbc 写入 clickhouse 的时候,遇到一些坑,这里分享下,造福人民群众。
一个 WARN
WARN JdbcUtils: Requested isolation level 1, but transactions are unsupported
这是因为 clickhouse 不支持事务造成的,解决方案,jdbc 加入 isolationLevel 等于 NONE 的选项,isolationLevel 详解
The transaction isolation level, which applies to current connection. It can be one of NONE, READ_COMMITTED, READ_UNCOMMITTED, REPEATABLE_READ, or SERIALIZABLE, corresponding to standard transaction isolation levels defined by JDBC’s Connection object, with default of READ_UNCOMMITTED. This option applies only to writing. Please refer the documentation in java.sql.Connection.
一个报错
merges are processing significantly slower than inserts
这是因为 spark 多个 partition 同时并发写引发的错误,解决方案 jdbc 加入 numPartitions 等于 1 的选项控制并发数,numPartitions 详解
The maximum number of partitions that