如何使用 PySpark 读取目录下的 Parquet 文件?
How to read Parquet files under a directory using PySpark?
我在网上搜索过,网上提供的解决方案都没有解决我的问题。我正在尝试读取分层目录下的镶木地板文件。我收到以下错误。
'Unable to infer schema for Parquet. It must be specified manually.;'
我的目录结构如下:
数据库文件系统:/mnt/sales/region/country/2020/08/04
year文件夹下会有多个子目录,month下会有days的后续子目录。
我只想在销售级别阅读它们,这应该为我提供所有地区的信息,我已经尝试了以下两种代码,但都没有用。请帮我解决这个问题。
spark.read.parquet("dbfs:/mnt/sales/*")
或
spark.read.parquet("dbfs:/mnt/sales/")
你能试试这个选项吗?
df = spark.read.option("header","true").option("recursiveFileLookup","true").parquet("/path/to/root/")
path = '/mnt/container_name/root_dir/folder_name'
df = spark.read.format('parquet').options(header=True,inferSchema=True).load(path)
我在网上搜索过,网上提供的解决方案都没有解决我的问题。我正在尝试读取分层目录下的镶木地板文件。我收到以下错误。
'Unable to infer schema for Parquet. It must be specified manually.;'
我的目录结构如下: 数据库文件系统:/mnt/sales/region/country/2020/08/04
year文件夹下会有多个子目录,month下会有days的后续子目录。
我只想在销售级别阅读它们,这应该为我提供所有地区的信息,我已经尝试了以下两种代码,但都没有用。请帮我解决这个问题。
spark.read.parquet("dbfs:/mnt/sales/*")
或
spark.read.parquet("dbfs:/mnt/sales/")
你能试试这个选项吗?
df = spark.read.option("header","true").option("recursiveFileLookup","true").parquet("/path/to/root/")
path = '/mnt/container_name/root_dir/folder_name'
df = spark.read.format('parquet').options(header=True,inferSchema=True).load(path)