I have to read certain files from S3, so I created a CSV containing path of those files on S3. I am reading created CSV file using below code:
val listofFilesRDD = sparkSession.read.textFile("s3://"+ file)
This is working fine. Then I am trying to read each of those paths and create dataframe like:
listofFilesRDD.foreach(iter => {
val pathDF = sparkSession.read
.schema(testSchema)
.option("headers", true)
.csv("s3://"+iter)
pathDF.printSchema()
})
but, the above code gives NullPointerException.
So, How can I fix the above code?