Skip to content

PARQUET-651: Improve Avro's isElementType check. - #352

Closed
rdblue wants to merge 2 commits into
apache:masterfrom
rdblue:PARQUET-651-improve-is-element-type-check
Closed

PARQUET-651: Improve Avro's isElementType check.#352
rdblue wants to merge 2 commits into
apache:masterfrom
rdblue:PARQUET-651-improve-is-element-type-check

Conversation

@rdblue

@rdblue rdblue commented Jul 11, 2016

Copy link
Copy Markdown
Contributor

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.

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.
@rdblue

rdblue commented Jul 11, 2016

Copy link
Copy Markdown
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of always set AvroScehmaConverter.assumeRepeatedIsListElement to true, shall we pass the properly constructed AvroScehmaConverter from AvroReadSupport to AvroRecordMaterializer, and then here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh I see your point, there's no need to do so.

@liancheng

Copy link
Copy Markdown
Contributor

+1!

@asfgit asfgit closed this in 626014e Jul 17, 2016
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants