I wanted to know if there is some way to leverage the metadata information already present in the hdfs folder structure in spark. For example, I am using the following code to write data to hdfs,
val columns = Seq("country","state")
dataframe1.write.partitionBy(columns:_*).mode("overwrite").
save(path)
This generates similar looking directory structure,
path/country=xyz/state=1
path/country=xyz/state=2
path/country=xyz/state=3
path/country=abc/state=4
What i want to know is using spark, is there a way to infer all the partitions and sub partitions as a Map(String,List(String)) (without loading the entire file and using group by?), where the key is the partition and the value is a list of all the sub partitions within this partition.
The output of the above example would be similar to following
Map(xyz->List(1,2,3),abc->(4))