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

}

相关推荐
快手技术14 小时前
Blaze RangePartitioning 算子Native实现全解析
spark·naive
warrah20 小时前
flink-cdc同步数据到doris中
flink·doris
知初~1 天前
出行项目案例
hive·hadoop·redis·sql·mysql·spark·database
努力的小T2 天前
使用 Docker 部署 Apache Spark 集群教程
linux·运维·服务器·docker·容器·spark·云计算
Java资深爱好者2 天前
在Spark中,如何使用DataFrame进行高效的数据处理
大数据·分布式·spark
阿里云大数据AI技术2 天前
美的楼宇科技基于阿里云 EMR Serverless Spark 构建 LakeHouse 湖仓数据平台
大数据·阿里云·spark·serverless·emr
python资深爱好者2 天前
什么容错性以及Spark Streaming如何保证容错性
大数据·分布式·spark
猪猪果泡酒2 天前
spark
spark
weixin_307779133 天前
PySpark实现MERGE INTO的数据合并功能
大数据·python·spark
lucky_syq4 天前
Spark算子:大数据处理的魔法棒
大数据·分布式·spark