-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3d56c4e
Showing
3 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name := "avro5" | ||
|
||
version := "0.1" | ||
|
||
scalaVersion := "2.11.8" | ||
|
||
libraryDependencies += "com.databricks" %% "spark-avro" % "4.0.0" | ||
|
||
libraryDependencies += "org.scala-lang" % "scala-library" % "2.11.8" | ||
|
||
libraryDependencies += "org.apache.spark" %% "spark-sql" % "2.4.4" | ||
|
||
libraryDependencies += "org.apache.spark" %% "spark-avro" % "2.4.4" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"id": 1, | ||
"name": "ASK", | ||
|
||
"id": 5, | ||
"name": "Amulya Singh Rajput", | ||
|
||
"id":6, | ||
"name":"ASK ROX" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import org.apache.spark.sql.SparkSession | ||
|
||
object avro5 { | ||
def main(args: Array[String]) = { | ||
val spark = SparkSession.builder() | ||
.master("local") | ||
.appName("Making Avro File") | ||
.getOrCreate() | ||
|
||
|
||
val df = spark.createDataFrame(Seq( | ||
(2012, 8, "Batman", 9.8), | ||
(2012, 8, "Hero", 8.7), | ||
(2012, 7, "Robot", 5.5), | ||
(2011, 7, "Git", 2.0)) | ||
).toDF("year", "month", "title", "rating") | ||
|
||
|
||
import com.databricks.spark.avro._ | ||
df.write.format("avro").save("/home/amulya/Desktop/ask5.avro") | ||
} | ||
} | ||
// 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".; |