我試圖在出現故障情況時執行兩個操作。
- 將表的結果寫入 parquet 中的單個檔案。
- 退出筆記本。
根據結果??采取行動
if validation_result["success"]:
print("Successful")
else:
(
spark.sql("Select * from notify_error")
.coalesce(1)
.write.format("delta")
.mode("overwrite")
.save(lakePath)
)
從上面可以看出,我正在嘗試使用coalesce(1). 要在 Synapse 中退出筆記本,我相信代碼是:
mssparkutils.notebook.exit(returnValue)
但是我不是在上面的代碼中放置代碼的地方。
有什么想法嗎?
uj5u.com熱心網友回復:
你可以做raise用ValueError,如
%%pyspark
notebookName = mssparkutils.runtime.context.get('notebookname')
errorString = f"error in notebook '{notebookName}'"
raiseError = True
if raiseError:
raise ValueError(errorString)
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/360765.html
