pyspark.sql.utils.AnalysisException:您无法推断 Parquet 的架构。必须手动指定。;'

pyspark.sql.utils.AnalysisException: u'Unable to infer schema for Parquet. It must be specified manually.;'

这与上面 post 给出的答案不同

我收到一条错误消息

pyspark.sql.utils.AnalysisException: u'Unable to infer schema for Parquet. It must be specified manually.;'

当我尝试使用 Spark 2.1.0 读取这样的 parquet 文件时

data = spark.read.parquet('/myhdfs/location/')

我已经通过 Hue WebPortal 查看 impala table 并检查 file/table 不为空。此外,我存储在类似目录中的其他文件读起来绝对没问题。作为记录,文件名包含连字符但没有下划线或 full-stops/periods.

因此,以下 post 中的 none 个答案适用 Unable to infer schema when loading Parquet file

有什么想法吗?

原来我收到这个错误是因为目录结构还有另一层。以下是我需要的;

data = spark.read.parquet('/myhdfs/location/anotherlevel/')

我遇到了同样的问题,但是 none 我在网上找到的答案对我有用。原来我是这样写代码的:

data = spark.read.parquet("/myhdfs/location/anotherlevel/")

所以,使用双 " 。当我切换到使用单 ' 时,我的问题就解决了。

data = spark.read.parquet('/myhdfs/location/anotherlevel/')

分享以防对大家有帮助