【发布时间】:2017-03-11 08:56:30
【问题描述】:
我正在尝试在 Spark 中加载 Parquet 文件作为数据框-
val df= spark.read.parquet(path)
我得到-
org.apache.spark.SparkException: Job aborted due to stage failure: Task 0 in stage 5.0 failed 4 times, most recent failure: Lost task 0.3 in stage 5.0 (TID 12, 10.250.2.32): java.lang.UnsupportedOperationException: Complex types not supported.
在浏览代码时,我意识到在 spark VectorizedParquetRecordReader.java (initializeInternal)-
中有一个检查Type t = requestedSchema.getFields().get(i);
if (!t.isPrimitive() || t.isRepetition(Type.Repetition.REPEATED)) {
throw new UnsupportedOperationException("Complex types not supported.");
}
所以我认为它在 isRepetition 方法上失败了。 任何人都可以建议我解决问题的方法吗?
我的 Parquet 数据是这样的 -
Key1 = value1
Key2 = value1
Key3 = value1
Key4:
.list:
..element:
...key5:
....list:
.....element:
......certificateSerialNumber = dfsdfdsf45345
......issuerName = CN=Microsoft Windows Verification PCA, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
......subjectName = CN=Microsoft Windows, OU=MOPR, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
......thumbprintAlgorithm = Sha1
......thumbprintContent = sfdasf42dsfsdfsdfsd
......validFrom = 2009-12-07 21:57:44.000000
......validTo = 2011-03-07 21:57:44.000000
....list:
.....element:
......certificateSerialNumber = dsafdsafsdf435345
......issuerName = CN=Microsoft Root Certificate Authority, DC=microsoft, DC=com
......subjectName = CN=Microsoft Windows Verification PCA, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
......thumbprintAlgorithm = Sha1
......thumbprintContent = sdfsdfdsf43543
......validFrom = 2005-09-15 21:55:41.000000
......validTo = 2016-03-15 22:05:41.000000
我怀疑 key4 可能会因为嵌套而引发问题 树。输入数据是 Json 类型,所以可能是 parquet 不 将复杂级别理解为 Json
我在 Spark 中发现了一个错误 https://issues.apache.org/jira/browse/HIVE-13744
但它指出 Hive 复杂类型问题。不确定,这是否能解决镶木地板的问题?
更新 1 进一步探索镶木地板,我得出以下结论 -
我在 spark.write 时创建了 5 个镶木地板文件 在这 2 个镶木地板文件中是空的,因此应该是 ArrayType 的列的架构以 String 类型出现,当我尝试将其整体读取时,我看到了上述异常
【问题讨论】:
-
首先使用哪个工具来创建 Parquet 文件?
-
使用 Spark 数据帧写入 spark.write.parquet 命令
标签: apache-spark spark-dataframe parquet