-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Nested arrays cause 'item-end when a 'x' was expected" error (#476)
* Address issue with nested arrays Some schemas with nested arrays ( e.g., NestedArray.avsc ) generate the following error when deserialized with fastserde: Attempt to process a item-end when a string was expected. This PR adds a test case and addresses the issue * Update test * Fix fastserdetest.avsc * Update fastserdetest.java * Remove code to verify test pipeline fails * Make name consistent * Fix FastDeserializerGeneratorBase * Use helper functions so test builds on all versions * Fix case of ItemName * Remove dependency of getSymbolPrintName * Remove unnecessary whitespace change * Add javadoc --------- Co-authored-by: Andy Sautins <[email protected]>
- Loading branch information
Showing
3 changed files
with
83 additions
and
0 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
fastserde/avro-fastserde-tests-common/src/test/avro/nestedArrayTest.avsc
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,26 @@ | ||
{ | ||
"namespace": "com.linkedin.avro.fastserde.generated.avro", | ||
"name": "NestedArrayTest", | ||
"type": "record", | ||
"fields": [ | ||
{ | ||
"name": "NestedArrayItems", | ||
"type": { | ||
"type": "array", | ||
"items": { | ||
"type": "array", | ||
"items": { | ||
"name": "NestedArrayItem", | ||
"type": "record", | ||
"fields": [ | ||
{ | ||
"name": "ItemName", | ||
"type": "string" | ||
} | ||
] | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} |
37 changes: 37 additions & 0 deletions
37
...fastserde-tests-common/src/test/java/com/linkedin/avro/fastserde/FastNestedArrayTest.java
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,37 @@ | ||
package com.linkedin.avro.fastserde; | ||
|
||
import com.linkedin.avro.fastserde.generated.avro.NestedArrayItem; | ||
import com.linkedin.avro.fastserde.generated.avro.NestedArrayTest; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import org.apache.avro.io.Decoder; | ||
import org.testng.Assert; | ||
import org.testng.annotations.Test; | ||
|
||
|
||
public class FastNestedArrayTest { | ||
|
||
@Test | ||
public void testExample() throws Exception { | ||
|
||
NestedArrayTest nestedArrayTest = new NestedArrayTest(); | ||
|
||
List<NestedArrayItem> items = new ArrayList<>(); | ||
NestedArrayItem item = new NestedArrayItem(); | ||
FastSerdeTestsSupport.setField(item, "ItemName", "itemName"); | ||
FastSerdeTestsSupport.setField(nestedArrayTest, "NestedArrayItems", Collections.singletonList(items)); | ||
|
||
Decoder decoder = FastSerdeTestsSupport.specificDataAsDecoder(nestedArrayTest, NestedArrayTest.SCHEMA$); | ||
|
||
FastSpecificDatumReader<NestedArrayTest> fastSpecificDatumReader = | ||
new FastSpecificDatumReader<>(NestedArrayTest.SCHEMA$); | ||
FastDeserializer<NestedArrayTest> fastDeserializer = | ||
fastSpecificDatumReader.getFastDeserializer().get(); | ||
|
||
NestedArrayTest actual = fastDeserializer.deserialize(decoder); | ||
|
||
Assert.assertEquals(actual, nestedArrayTest); | ||
} | ||
} |
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