Python笔记本输出窗体

2024-06-14 18:25:27 发布

您现在位置:Python中文网/ 问答频道 /正文

我对Databricks还很陌生,我在玩从一个笔记本到另一个笔记本的输出捕捉。你知道吗

这是我的密码:

笔记本1

%python
result = dbutils.notebook.run("/01.Mig/SM02. Project /02 Processing Staging/04 User Notebooks/Notebook1", 60)
print("Result: " + result )
if result == 0: dbutils.notebook.exit
else: dbutils.notebook.run("/01.Mig/SM02. Project/02 Processing Staging/04 User Notebooks/Output",60)

笔记本2

%python
resultValue = spark.sql("select count(1) from Notes_Final where record1 like 'GAB%'")
dbutils.notebook.exit(str(resultValue))

从Notebook2传回的结果是DataFrame[count(1): bigint]。我需要它从Notebook2中的SQL而不是数据类型传回计数的值。你知道吗

我错过了什么?你知道吗


Tags: runprojectcountexit笔记本resultnotebookstaging
1条回答
网友
1楼 · 发布于 2024-06-14 18:25:27

您需要将结果值收集回驱动程序,即使这样,在将其作为退出值传递给dbutils之前,也可能需要将该值作为字符串打印出来。你知道吗

您的代码实际上并没有执行计数—它只是创建一个DAG来生成结果。一旦对结果数据帧调用.collect(),它将执行DAG并给出计数。然后可以将此计数作为笔记本的退出值传递。就像我说的,你可能要把它作为一个字符串通过打印来传递。你知道吗

相关问题 更多 >