How to convert JSON file to AVRO file and vise versa

+1 vote

Hi All,

I want to convert my json file to avro and vice versa but facing some difficulty. Can anyone please help me debugging this?

val df = spark.read.json(“path to the file”)
df.write.format(“com.databricks.spark.avro”).save(“destination location”)

But I am getting the below error:

org.apache.spark.sql.AnalysisException: Failed to find data source: com.databricks.spark.avro.
Aug 24, 2019 in Apache Spark by Prashant
3,576 views

1 answer to this question.

+1 vote

Try including the package while starting the spark-shell:

spark-shell --packages com.databricks:spark-avro_2.10:2.0.1

And then import:

import com.databricks.spark.avro._
answered Aug 26, 2019 by Karan

Related Questions In Apache Spark

+1 vote
1 answer
+1 vote
1 answer

How to write Spark DataFrame to Avro Data File?

Hi@akhtar, Since Avro library is external to Spark, ...READ MORE

answered Nov 4, 2020 in Apache Spark by MD
• 95,460 points
3,276 views
0 votes
1 answer

How to save and retrieve the Spark RDD from HDFS?

You can save the RDD using saveAsObjectFile and saveAsTextFile method. ...READ MORE

answered May 29, 2018 in Apache Spark by Shubham
• 13,490 points
13,545 views
+1 vote
2 answers
+1 vote
1 answer

Hadoop Mapreduce word count Program

Firstly you need to understand the concept ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 11,380 points
11,033 views
0 votes
1 answer

hadoop.mapred vs hadoop.mapreduce?

org.apache.hadoop.mapred is the Old API  org.apache.hadoop.mapreduce is the ...READ MORE

answered Mar 16, 2018 in Data Analytics by nitinrawat895
• 11,380 points
2,540 views
+2 votes
11 answers

hadoop fs -put command?

Hi, You can create one directory in HDFS ...READ MORE

answered Mar 16, 2018 in Big Data Hadoop by nitinrawat895
• 11,380 points
108,853 views
0 votes
1 answer

How to create dataframe for the comma delimited file?

 Refer to the below command used: val df ...READ MORE

answered Jul 5, 2019 in Apache Spark by karan
3,443 views
0 votes
1 answer

How to load data of .csv file in MySQL Database Table?

You can do it using a code ...READ MORE

answered Jul 22, 2019 in Apache Spark by Vishwa
1,903 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP