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

}

相关推荐
武子康1 天前
大数据-277 Spark MLib-梯度提升树(GBDT)算法原理与工程实现指南
大数据·后端·spark
jerryinwuhan1 天前
Spark SQL 详细讲义
大数据·sql·spark
武子康2 天前
大数据-276 Spark MLib-深入理解Bagging与Boosting:集成学习核心算法对比与GBDT实战
大数据·后端·spark
weixin_307779132 天前
SparkPySetup:基于Python的Windows 11 PySpark环境自动化搭建工具
大数据·开发语言·python·spark
曾阿伦3 天前
Spark flatMapToPair算子卡顿优化
大数据·分布式·spark
阿里云大数据AI技术3 天前
阿里云 EMR Serverless Spark 发布 Agent Skill:让自然语言驱动 Spark 任务与资源管理
spark·agent
亚林瓜子3 天前
AWS Glue PySpark中日志设置
python·spark·日志·aws·pyspark·log·glue
武子康3 天前
大数据-275 Spark MLib-集成学习:从Bagging到Boosting的群体智慧
大数据·后端·spark
阿里云大数据AI技术4 天前
EMR Serverless Spark 推出 Spark 4.0,加速湖仓架构下的数据处理升级
大数据·人工智能·spark