【发布时间】:2019-02-22 12:23:35
【问题描述】:
我正在尝试使用自定义架构导入镶木地板格式的数据,但它返回: TypeError: option() 缺少 1 个必需的位置参数:'value'
ProductCustomSchema = StructType([
StructField("id_sku", IntegerType(), True),
StructField("flag_piece", StringType(), True),
StructField("flag_weight", StringType(), True),
StructField("ds_sku", StringType(), True),
StructField("qty_pack", FloatType(), True)])
def read_parquet_(path, schema) :
return spark.read.format("parquet")\
.option(schema)\
.option("timestampFormat", "yyyy/MM/dd HH:mm:ss")\
.load(path)
product_nomenclature = 'C:/Users/alexa/Downloads/product_nomenc'
product_nom = read_parquet_(product_nomenclature, ProductCustomSchema)
【问题讨论】:
-
不确定它是否可行,但请尝试
.option(schema),而不是.schema(schema)。 -
return Py4JJavaError: 调用 o1259.showString 时出错。 :org.apache.spark.SparkException:作业因阶段失败而中止:阶段 50.0 中的任务 0 失败 1 次,最近一次失败:阶段 50.0 中丢失任务 0.0(TID 660,本地主机,执行程序驱动程序):org.apache.spark .sql.execution.QueryExecutionException:Parquet 列无法在文件 file:///C:/Users/alexa/Downloads/product_nomenc/lu_product_nomenclature%252Fpart-r-00002-8c115acd-057f-43a5-b7dd-0e7d0ef1eb9e.gz 中转换。镶木地板。列:[id_sku],预期:IntegerType,找到:BINARY
-
在spark.apache.org/docs/latest/api/scala/… 上查看有效签名(出于兴趣,为什么不使用 spark.read.parquet() 并推断架构?)
标签: apache-spark pyspark apache-spark-sql