[英]How to write the Python result to synapse azure database?
I am trying to write the result obtained using the pyspark in the notebook as a table to the database using the following code:我正在尝试使用以下代码将使用笔记本中的 pyspark 获得的结果作为表写入数据库:
%%pyspark
sample=sample.head()
%%spark
spark.conf.set("spark.sql.execution.arrow.pyspark.enabled", "true")
park_df = spark.createDataFrame(sample)
park_df.write.mode("overwrite").saveAsTable("default.sample")
Unfortunately, I'm getting the following error:不幸的是,我收到以下错误:
Error : <console>:31: error: not found: value park_df
val $ires9 = park_df
^
<console>:29: error: not found: value park_df
park_df = spark.createDataFrame(sample)
You may try to below to code to write the python result to synapse azure database:您可以尝试在下面编写代码以将 python 结果写入突触 azure 数据库:
%%pyspark
sample = [('CA',22,45000),('WA',35,65000)]
spark.conf.set("spark.sql.execution.arrow.pyspark.enabled", "true")
park_df = spark.createDataFrame(sample, ['state','age','salary'])
park_df.write.mode("overwrite").saveAsTable("default.sample")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.