PARQUET-651: Improve Avro's isElementType check. - #352
Closed
rdblue wants to merge 2 commits into
Closed
Conversation
The Avro implementation needs to check whether the read schema that is passed by the user (or automatically converted from the file schema) expects an extra 1-field layer to be returned, which matches the previous behavior of Avro when reading a 3-level list. Before this commit, the check was done by testing the structure of the expected list element type against the repeated group's schema. If they matched, then Avro assumed that the user expected an extra layer. However, for records that happened to match (1-field records with a field named "element") the check could be wrong and would cause exceptions later. This commit updates the check to convert the file's element schema to Avro and compare the compatibility of that schema with what was passed by the user. This checks the entire tree from the element down and gets the answer right based on the element and its children, not just the field names on the element.
Contributor
Author
|
@liancheng, could you take a look at this? It's based on your solution to SPARK-16344. Thanks! |
| // 2-level and 3-level can't be mixed. | ||
| private static final AvroSchemaConverter CONVERTER = | ||
| new AvroSchemaConverter(true); | ||
|
|
Contributor
There was a problem hiding this comment.
Instead of always set AvroScehmaConverter.assumeRepeatedIsListElement to true, shall we pass the properly constructed AvroScehmaConverter from AvroReadSupport to AvroRecordMaterializer, and then here?
Contributor
There was a problem hiding this comment.
Oh I see your point, there's no need to do so.
Contributor
|
+1! |
rdblue
added a commit
to rdblue/parquet-mr
that referenced
this pull request
Jan 6, 2017
The Avro implementation needs to check whether the read schema that is passed by the user (or automatically converted from the file schema) expects an extra 1-field layer to be returned, which matches the previous behavior of Avro when reading a 3-level list. Before this commit, the check was done by testing the structure of the expected list element type against the repeated group's schema. If they matched, then Avro assumed that the user expected an extra layer. However, for records that happened to match (1-field records with a field named "element") the check could be wrong and would cause exceptions later. This commit updates the check to convert the file's element schema to Avro and compare the compatibility of that schema with what was passed by the user. This checks the entire tree from the element down and gets the answer right based on the element and its children, not just the field names on the element. Author: Ryan Blue <blue@apache.org> Closes apache#352 from rdblue/PARQUET-651-improve-is-element-type-check and squashes the following commits: ad9c1ee [Ryan Blue] PARQUET-651: Undo accidental default setting change. 1efa248 [Ryan Blue] PARQUET-651: Improve Avro's isElementType check. Conflicts: parquet-avro/src/main/java/org/apache/parquet/avro/AvroRecordConverter.java parquet-avro/src/test/java/org/apache/parquet/avro/TestArrayCompatibility.java Resolution: No actual conflicts, just adjacent code changes.
rdblue
added a commit
to rdblue/parquet-mr
that referenced
this pull request
Jan 10, 2017
The Avro implementation needs to check whether the read schema that is passed by the user (or automatically converted from the file schema) expects an extra 1-field layer to be returned, which matches the previous behavior of Avro when reading a 3-level list. Before this commit, the check was done by testing the structure of the expected list element type against the repeated group's schema. If they matched, then Avro assumed that the user expected an extra layer. However, for records that happened to match (1-field records with a field named "element") the check could be wrong and would cause exceptions later. This commit updates the check to convert the file's element schema to Avro and compare the compatibility of that schema with what was passed by the user. This checks the entire tree from the element down and gets the answer right based on the element and its children, not just the field names on the element. Author: Ryan Blue <blue@apache.org> Closes apache#352 from rdblue/PARQUET-651-improve-is-element-type-check and squashes the following commits: ad9c1ee [Ryan Blue] PARQUET-651: Undo accidental default setting change. 1efa248 [Ryan Blue] PARQUET-651: Improve Avro's isElementType check. Conflicts: parquet-avro/src/main/java/org/apache/parquet/avro/AvroRecordConverter.java parquet-avro/src/test/java/org/apache/parquet/avro/TestArrayCompatibility.java Resolution: No actual conflicts, just adjacent code changes.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Avro implementation needs to check whether the read schema that is
passed by the user (or automatically converted from the file schema)
expects an extra 1-field layer to be returned, which matches the
previous behavior of Avro when reading a 3-level list. Before this
commit, the check was done by testing the structure of the expected list
element type against the repeated group's schema. If they matched, then
Avro assumed that the user expected an extra layer. However, for records
that happened to match (1-field records with a field named "element")
the check could be wrong and would cause exceptions later.
This commit updates the check to convert the file's element schema to
Avro and compare the compatibility of that schema with what was passed
by the user. This checks the entire tree from the element down and gets
the answer right based on the element and its children, not just the
field names on the element.