I recently read this article and tried out the example but when I run
val usersDF = spark.read.format("avro")
.load("examples/src/main/resources/users.avro")
But this gives me an error when I try to run it.
Exception in thread "main" org.apache.spark.sql.AnalysisException: Failed to find data source: avro. Avro is built-in but external data source module since Spark 2.4. Please deploy the application as per the deployment section of "Apache Avro Data Source Guide".; at org.apache.spark.sql.execution.datasources.DataSource$.lookupDataSource(DataSource.scala:647)
Upon reading up Apache Avro Data Source Guide, I figured build.sbt needs to be updated with a new dependency.
val sparkVersion = "2.4.0"
"org.apache.spark" %% "spark-avro" % sparkVersion
Everything worked fine after this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With