Last active
August 29, 2015 13:56
-
-
Save rdblue/9193726 to your computer and use it in GitHub Desktop.
Test to catch parquet-mr #12
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
@Test | |
public void testArrayOfRecords() throws Exception { | |
Schema innerRecord = Schema.createRecord("InnerRecord", null, null, false); | |
Schema optionalString = optional(Schema.create(Schema.Type.STRING)); | |
innerRecord.setFields(Lists.newArrayList( | |
new Schema.Field("s1", optionalString, null, NullNode.getInstance()), | |
new Schema.Field("s2", optionalString, null, NullNode.getInstance()) | |
)); | |
Schema schema = Schema.createRecord("HasArray", null, null, false); | |
schema.setFields(Lists.newArrayList( | |
new Schema.Field("myarray", Schema.createArray(optional(innerRecord)), | |
null, NullNode.getInstance()) | |
)); | |
System.err.println("Avro schema: " + schema.toString(true)); | |
testConversion(schema, "message HasArray {\n" + | |
" optional group myarray (LIST) {\n" + | |
" repeated group array {\n" + | |
" optional binary s1 (UTF8);\n" + | |
" optional binary s2 (UTF8);\n" + | |
" }\n" + | |
" }\n" + | |
"}\n"); | |
} | |
public static Schema optional(Schema original) { | |
return Schema.createUnion(Lists.newArrayList(original, | |
Schema.create(Schema.Type.NULL))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment