I have a persisted dataframe on AWS S3 with the following structure:
s3://bucket/df/
|__ date=2020-02-19/
|__ FILENAME01.json
|__ FILENAME02.json
|__ FILENAME03
|__ ...
|__ date=2020-02-20/
|__ FILENAME04.json
|__ FILENAME05
|__ ...
|__ ...
If I read this dataframe using the following syntax:
df = spark.read.json("s3://bucket/df)"
The file that doesn't have extensions will be part of my dataframe and this is not desirable. So, I would like to only consider the files with .json extension.
So I decided to read this dataframe filtering the files with suffix *.json. In a practical way, I tried the following:
df = spark.read.json("s3://bucket/df/date=*/*.json")
The spark.read.json worked, but the column date used to partition my dataframe wasn't present. Is there any way to retrieve only files that match to a specific suffix inside partition folders, without losing the partition column?