Dear Vishal,

Greetings!

Please find below details

Please start spark shell by below version of Avro.

spark2-shell --packages com.databricks:spark-avro_2.11:3.0.0

Now the file should have proper extension, I tried with episodes.avro and it worked fine but only the name of avrofile without extension didn't work.

Please refer the following screenshot.

image


Spark XML

Please find attached - books.xml file

Start Spark shell using below command and follow the code 

spark-shell --packages com.databricks:spark-xml_2.10:0.4.1

val df = sqlContext.read.format("com.databricks.spark.xml").option("rowTag","book").load("file:///home/edureka/Desktop/books.xml")   // loading the file - provide correct path for the xml file
 
df.printSchema // for getting the schema
 
 
 
image


df.select("_id","author","title").registerTempTable("books") // taking 3 fields and registering as temp table - books
 
val res = sqlContext.sql("select * from books") // using sql queries
 
res.show()  // printing output as given below


image

Please let us know if you are facing any issue.

We are eagerly waiting for your response.