How to add package com.databricks.spark.avro in spark?

+1 vote

Hi, I am trying to read avro file stored on hdfs, but getting error. I tried to add package. How to read avro file in webconsole spark2-shell
code:

val df = sqlContext.read.format("com.databricks.spark.avro").load("hdfs://ip-20-0-21-161.ec2.internal:8020/user/edureka_315701/blogspot/category/part-m-00000.avro")
Jul 10, 2019 in Apache Spark by Karuna
1,150 views

1 answer to this question.

+1 vote

Start spark shell using below line of command 

$ spark2-shell --packages com.databricks:spark-avro_2.11:4.0.0 

Now try using below line of code, change the path to exact path.

import com.databricks.spark.avro._

val df= spark.read.format("com.databricks.spark.avro").option("header","true").load("hdfs://nameservice1/user/edureka_315701/blogspot/category/part-m-00000.avro")  // Loading avro
answered Jul 10, 2019 by Jishnu

How do we know which version to specify? where we can get these details (2.11:4.0.0)? How do we form this:2.11:4.0.0

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

Related Questions In Apache Spark

0 votes
4 answers

How to change the spark Session configuration in Pyspark?

You can dynamically load properties. First create ...READ MORE

answered Dec 10, 2018 in Apache Spark by Vini
25,053 views
0 votes
1 answer

How to convert rdd object to dataframe in spark

SqlContext has a number of createDataFrame methods ...READ MORE

answered May 30, 2018 in Apache Spark by nitinrawat895
• 10,870 points
2,088 views
0 votes
7 answers

How to replace null values in Spark DataFrame?

in spark 2.x you can directly use ...READ MORE

answered 4 days ago in Apache Spark by gaurav
35,460 views
0 votes
1 answer
+1 vote
1 answer
+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
• 10,870 points
4,532 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
• 10,870 points
642 views
+1 vote
11 answers

hadoop fs -put command?

put syntax: put <localSrc> <dest> copy syntax: copyFr ...READ MORE

answered Dec 7, 2018 in Big Data Hadoop by Aditya
25,601 views
0 votes
1 answer

How to add package com.databricks.spark.avro in spark?

Start spark shell using below line of ...READ MORE

answered Jul 23, 2019 in Apache Spark by Ritu
689 views
0 votes
1 answer

How to check if a particular keyword exists in Apache Spark?

Hey, You can try this code to get ...READ MORE

answered Jul 22, 2019 in Apache Spark by Gitika
• 26,270 points
249 views