【问题标题】:Is there a way to properly catch exception 'org.apache.spark.sql.delta.ConcurrentAppendException' on python?有没有办法在 python 上正确捕获异常'org.apache.spark.sql.delta.ConcurrentAppendException'?
【发布时间】:2021-10-26 19:47:30
【问题描述】:

有多个数据管道可能会导致并发追加异常尝试更新同一个增量表,我无法控制这些管道的并发性。我想捕获异常并重试增量表的更新,但似乎即使我添加了一个尝试并捕获异常也没有得到处理。欢迎提出任何建议。

try:
   # Update delta, retry in case of concurrency 
   curatedTable.alias("staged").merge(updateDF.alias("curated"),
     "staged.ExperienceId = curated.ExperienceId AND staged.ExperienceVersion = curated.ExperienceVersion") \
     .whenMatchedUpdate(set = { "staged.updated" : "True" } ).execute()
   break
except exception as e:
   if retry < 2:
     continue
   else:
     raise Exception("RETRY FAILED")  

我收到以下消息,而不是收到带有“重试失败”消息的异常

Operation on target Notebook Synapse failed: Py4JJavaError: An error occurred while calling o42198.save.
: org.apache.spark.sql.delta.ConcurrentAppendException: Files were added to the root of the table by a concurrent update. Please try the operation again.
Conflicting commit: ......

【问题讨论】:

    标签: apache-spark exception pyspark delta-lake


    【解决方案1】:

    您需要从 delta.exceptions 导出 ConcurrentAppendException,然后捕获此异常。非常适合我。

    【讨论】:

      猜你喜欢
      • 2018-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多