Skip to content

Instantly share code, notes, and snippets.

@jacobtolar
Created May 17, 2019 22:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jacobtolar/c88d43ab4e8767227891e5cdc188ffad to your computer and use it in GitHub Desktop.
Save jacobtolar/c88d43ab4e8767227891e5cdc188ffad to your computer and use it in GitHub Desktop.
import org.apache.avro.Schema;
import org.apache.avro.io.ResolvingDecoder;
import java.io.File;
import java.io.IOException;
public class Avro19Test {
public static void main(String[] argc) throws IOException {
Schema reader = new Schema.Parser().parse(new File("reader"));
Schema writer = new Schema.Parser().parse(new File("writer"));
ResolvingDecoder.resolve(writer, reader);
}
}
{
"fields": [ {
"default": null,
"name": "r1",
"type": [ "null", {
"items": {
"fields": [ { "name": "num1", "type": "int" } ],
"name": "a1",
"namespace": "n1",
"type": "record"
},
"type": "array"
} ]
} ],
"name": "f1",
"type": "record"
}
checking 1.9.0
Exception in thread "main" java.lang.ClassCastException: org.apache.avro.Resolver$ReaderUnion cannot be cast to org.apache.avro.Resolver$Container
at org.apache.avro.io.parsing.ResolvingGrammarGenerator.generate(ResolvingGrammarGenerator.java:95)
at org.apache.avro.io.parsing.ResolvingGrammarGenerator.generate(ResolvingGrammarGenerator.java:110)
at org.apache.avro.io.parsing.ResolvingGrammarGenerator.generate(ResolvingGrammarGenerator.java:141)
at org.apache.avro.io.parsing.ResolvingGrammarGenerator.generate(ResolvingGrammarGenerator.java:65)
at org.apache.avro.io.ResolvingDecoder.resolve(ResolvingDecoder.java:85)
at Avro19Test.main(Avro19Test.java:11)
status=1
checking 1.8.2
status=0
#!/bin/bash
mkdir -p 1.8.2 1.9.0
wget --quiet 'https://repo1.maven.org/maven2/org/apache/avro/avro-tools/1.8.2/avro-tools-1.8.2.jar' -O 1.8.2/avro-tools.jar
wget --quiet 'https://repo1.maven.org/maven2/org/apache/avro/avro-tools/1.9.0/avro-tools-1.9.0.jar' -O 1.9.0/avro-tools.jar
echo checking 1.9.0
javac -cp 1.9.0/* Avro19Test.java
java -cp 1.9.0/*:. Avro19Test
echo status=$?
echo checking 1.8.2
javac -cp 1.8.2/* Avro19Test.java
java -cp 1.8.2/*:. Avro19Test
echo status=$?
{
"fields": [ {
"default": null,
"name": "r1",
"type": [ "null", {
"items": {
"fields": [ { "name": "num1", "type": "int" } ],
"name": "a1",
"namespace": "n2",
"type": "record"
},
"type": "array"
} ]
} ],
"name": "f1",
"type": "record"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment