I am using pyspark in azure databricks. And need to load thousands of files as a list of files. "Multi depth partitioning" is used, which makes difficult to use the base path to read the files.
Indeed, this multi-depth partitions results in nested directories which trigger this error :
AnalysisException: Unable to infer schema for CSV. It must be specified manually.;
Hence, we are reading everything as a list of files and I would like to know if the performance is the same when you read files using :
1.
spark.read.format('csv').load('/mnt/article/2021/08/09')
vs
2.
spark.read.format('csv').load([
'/mnt/article/2021/08/09/test.csv',
'/mnt/article/2021/08/09/test2.csv',
'/mnt/article/2021/08/09/test3.csv'
])
vs
3.
spark.read.format('csv').load(['/mnt/article/*/*/*/])
For some reasons, we don't want to use the third one : spark.read.format('csv').load(['/mnt/article/*/*/*/) but we might reconsider if the second one is really not efficient.
Many thanks in advance for any observations or suggestions!