Spark写数据到Doris报错node and exceeded the max retry times

用spark dataframe向doris写数据时,报下面错误:

Failed to load data on BE: http://192.168.50.10:18040/api/mydb/dwd_virtual_table/_stream_load? node and exceeded the max retry times.

发现表没写入成功。刚开始很困惑,后来发现是 dataFrame中的字段和目标表不一致 。

这种提示很不友好,有没有更好方式提示,方法是有的,可以用jdbc写入,发现错误时可以看到具体的提示。代码参考如下:

复制代码
def writeByJDBC(dataframe: DataFrame, dorisTable: String): Unit = {
    dataframe.write.format("jdbc")
      .mode(SaveMode.Append)
      .option("driver", "com.mysql.jdbc.Driver")
      .option("url", "jdbc:mysql://" + DORIS_HOST + ":9030/" +DATABASE_NAME + "?rewriteBatchedStatements=false")
      .option("batchsize", "" + WRITE_BATCH_SIZE)
      .option("user", DORIS_USER)
      .option("password", DORIS_PASSWORD)
      .option("isolationLevel", "NONE")
      //  .option("doris.write.fields","case_id,defendant_name,finance_name,mediation_name,mediator_name,dt")
      .option("dbtable", dorisTable)
      .save()
  }

不过这种方式还是没有Spark Doris Connector的方式写效率高,可以用上面jdbc方式调试,没问题再切换 Spark Doris Connector 方式:

def writeByDoris(dataframe: DataFrame, dorisTable: String): Unit = {

dataframe.write.format("doris")

.option("doris.table.identifier", dorisTable)

.option("doris.fenodes", DORIS_HOST + ":" + DORIS_FE_HTTP_PORT)

.option("user", DORIS_USER)

.option("password", DORIS_PASSWORD)

.option("sink.batch.size", WRITE_BATCH_SIZE)

.option("sink.max-retries", 3)

.option("doris.request.retries", 6)

.option("doris.request.retries", 100)

.option("doris.request.connect.timeout.ms", 60000)

.save()

}

相关推荐
D愿你归来仍是少年2 天前
Apache Spark 第 3 章:核心概念 RDD / DataFrame
大数据·spark·apache
Hello.Reader2 天前
PySpark 安装保姆级教程pip、Conda、手动安装、Spark Connect 一次讲透(一)
python·spark·conda·pip
Light602 天前
SPARK Agent Protocol(SAP):AI Agent时代的前端开发革命指南
大数据·人工智能·spark
D愿你归来仍是少年2 天前
Apache Spark 第 4 章:Spark 整体架构
spark·apache
datablau国产数据库建模工具2 天前
【无标题】
大数据·数据挖掘·spark
yumgpkpm2 天前
Apache Spark 和 Flink,处理实时大数据流对比(Cloudera CDH、CDP)
flink·spark·apache
D愿你归来仍是少年3 天前
Apache Spark 从入门到精通:完整学习指南
大数据·spark
D愿你归来仍是少年3 天前
Apache Spark Real-Time Mode 深度解析:打破微批次壁垒,挑战 Flink 的实时王座
flink·spark·apache
jerryinwuhan3 天前
Spark 安装配置1
大数据·分布式·spark
sunxunyong4 天前
spark History Server 重启失败
大数据·分布式·spark