Use case is to read a file and create a dataframe on top of it.After that get the schema of that file and store into a DB table.
For example purpose I am just creating a
Try this -
//-- For local file
val rdd = spark.read.option("wholeFile", true).option("delimiter",",").csv(s"file:///file/path/file.csv").rdd
val schema = StructType(Seq(StructField("Name", StringType, true),
StructField("Age", IntegerType, true),
StructField("Designation", StringType, true),
StructField("Salary", IntegerType, true),
StructField("ZipCode", IntegerType, true)))
val df = spark.createDataFrame(rdd,schema)