I have hundreds of thousands of smaller parquet files I'm attempting to read in with Spark on a regular basis. My application runs, but before the files are read in using the executor nodes, the driver node appears to be getting the status of each individual file. I read into it a bit and this is necessary to infer the schema and partitions. I tried providing them as so:
sparkSession.baseRelationToDataFrame(
DataSource
.apply(
sparkSession,
paths = paths, // List of thousands of parquet files in S3
partitionColumns = Seq("my_join_column"),
userSpecifiedSchema = Some(schema),
className = "parquet",
options = Seq().toMap
)
.resolveRelation(checkFilesExist = false)
)
But even when providing the schema and partition columns, it takes a while before hand. After looking into the resolveRelation code a bit, it looks like it still has to query the status of each file in order to build an InMemoryFileIndex.
Is there any way to get around this issue?
I'm using spark-sql 2.3.1.