AttributeError:编写实木复合地板文件时,“ StructType”对象没有属性“ _get_object_id”

时间:2020-07-30 04:45:43

标签: apache-spark pyspark parquet

在pyspark中编写镶木地板文件时出现以下错误:

AttributeError:“ StructType”对象没有属性“ _get_object_id”

下面是我正在使用的命令:

df.write.format("parquet").option("schema",output_schema).save("test/parquet")

dataframe(df)是通过读取csv文件创建的,其架构如下:

StructType(List(StructField(ID,IntegerType,true),StructField(FIRST NAME,StringType,true)))

输出架构为

StructType(List(StructField(ID,IntegerType,true),StructField(FIRST_NAME,StringType,true)))

1 个答案:

答案 0 :(得分:0)

您无法在将数据帧作为拼写形式写入时指定架构,因为拼写本身包含架构信息。

直接保存df,您的架构将得到维护,

df.write.format("parquet").save("test/parquet")