org.apache.avro.SchemaParseException: Undefined name

1/3/2019

My spark job is reading from kafka and decoding the message. my spark job is running well on my local spark cluster (https://archive.apache.org/dist/spark/spark-2.2.1/spark-2.2.1-bin-hadoop2.7.tgz) on MAC. but when run the job against spark (2.2.1-hadoop-2.7, from https://hub.docker.com/r/gettyimages/spark/tags) cluster on k8s and openstack, I got the following error:

Caused by: org.apache.avro.SchemaParseException: Undefined name: "my_items"
    at org.apache.avro.Schema.parse(Schema.java:1052)
    at org.apache.avro.Schema.parse(Schema.java:1164)
    at org.apache.avro.Schema.parse(Schema.java:1094)
    at org.apache.avro.Schema$Parser.parse(Schema.java:927)
    at org.apache.avro.Schema$Parser.parse(Schema.java:917)

I am pretty sure that in two cases, spark job is trying to parse the same schema. why spark job failed on my k8s spark cluster? I am really confused and have no idea how to debug for now. any hints welcomed. Thanks

-- BAE
apache-spark
avro
kubernetes
openstack-nova
scala

1 Answer

1/3/2019

It's likely different dependencies for Avro. 1.7.4 vs 1.7.7.

The container image:

$ find / | grep avro
/usr/spark-2.2.1/examples/src/main/python/avro_inputformat.py
/usr/spark-2.2.1/examples/src/main/resources/users.avro
/usr/spark-2.2.1/jars/avro-mapred-1.7.7-hadoop2.jar
/usr/hadoop-2.7.3/share/hadoop/kms/tomcat/webapps/kms/WEB-INF/lib/avro-1.7.4.jar
/usr/hadoop-2.7.3/share/hadoop/httpfs/tomcat/webapps/webhdfs/WEB-INF/lib/avro-1.7.4.jar
/usr/hadoop-2.7.3/share/hadoop/common/lib/avro-1.7.4.jar
/usr/hadoop-2.7.3/share/hadoop/tools/lib/avro-1.7.4.jar
/usr/hadoop-2.7.3/share/hadoop/mapreduce/lib/avro-1.7.4.jar

The spark-2.2.1-bin-hadoop2.7.tgz file:

$ find . | grep avro
./spark-2.2.1-bin-hadoop2.7/examples/src/main/python/avro_inputformat.py
./spark-2.2.1-bin-hadoop2.7/examples/src/main/resources/users.avro
./spark-2.2.1-bin-hadoop2.7/jars/avro-mapred-1.7.7-hadoop2.jar
./spark-2.2.1-bin-hadoop2.7/jars/avro-1.7.7.jar
./spark-2.2.1-bin-hadoop2.7/jars/avro-ipc-1.7.7.jar
# Hadoop Avro?
-- Rico
Source: StackOverflow