-
Notifications
You must be signed in to change notification settings - Fork 3.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-43994: [C++][Parquet] Fix schema conversion from two-level encoding nested list #43995
base: main
Are you sure you want to change the base?
Conversation
@emkornfield @pitrou @mapleFU Would you mind taking a look? Thanks! |
https://github.com/apache/parquet-format/blob/master/LogicalTypes.md#lists Without legacy:
With backward capability: Some existing data does not include the inner element layer. For backward-compatibility, the type of elements in LIST-annotated structures should always be determined by the following rules:
So, seems this hit the (1)? |
Parquet schema is too tricky for me, I'd try to take a look at https://github.com/apache/parquet-java/blob/aec7bc64dffa373db678ab2fc8b46565b4c011a5/parquet-thrift/src/main/java/org/apache/parquet/thrift/ThriftSchemaConvertVisitor.java#L220 tomorrow... |
I've check Java related code: I'll dive into it this after noon |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Our ListToSchemaField
is like this part of the code https://github.com/apache/parquet-java/blob/aec7bc64dffa373db678ab2fc8b46565b4c011a5/parquet-avro/src/main/java/org/apache/parquet/avro/AvroSchemaConverter.java#L397-L421
Should we port the impl and testings in that?
IMO, the root cause is that the current code recognizes the schema above as a three-level encoding. However, the inner-most field can only be
It is obvious that
|
Yes. It's so tricky, I think we can just copying the Java code directly, lol |
I think we are just missing check of this line: https://github.com/apache/parquet-java/blob/aec7bc64dffa373db678ab2fc8b46565b4c011a5/parquet-avro/src/main/java/org/apache/parquet/avro/AvroSchemaConverter.java#L588 |
This fixing itself LGTM, but I just think should we test and align more... |
What is "array"? Do you mean "list"? Can you fix the PR description?
Where is this in the Parquet spec? I cannot find a similar example.
|
The wording of the spec is very ambigious:
I think this just following the rule(4): repeated field's type is the element type with the repeated field's repetition.
I think maybe a testfile would be better |
I‘m using Hive schema, so that's why it is
The parquet-cli prints the following metadata:
|
@wgtmac Would you mind check testing file and add one if not exists in |
I will try to use parquet-java to create a minimal file and add it to parquet-testing. The file created by Hudi is too large due to a file-level bloom filter embedded in the file footer. |
@@ -4093,6 +4093,62 @@ TEST(TestArrowReaderAdHoc, OldDataPageV2) { | |||
TryReadDataFile(path); | |||
} | |||
|
|||
TEST(TestArrowReaderAdHoc, LegacyTwoLevelList) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feature is supported by parquet-java via a writer flag parquet.avro.write-old-list-structure
: https://github.com/apache/parquet-java/blob/08a4e7e6279f8c3b8558bd294fee4489a96d0db1/parquet-avro/src/main/java/org/apache/parquet/avro/AvroWriteSupport.java#L69 so I don't think we need to add a test file to parquet-testing repo.
Instead, I added a roundtrip test to create the file by C++ Parquet writer and then read it via the C++ Arrow Parquet reader. Does it look good to you? @pitrou @mapleFU
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we can't invoke parquet-java from the C++ test suite, so that's a good reason for a file to reside in parquet-testing (also for other implementations). Is there any problem with that?
Gentle ping :) @emkornfield @pitrou @mapleFU |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Rationale for this change
The current C++ parquet implementation interprets following parquet schema as `array<struct<array:array>>, which is wrong:
What changes are included in this PR?
According to the parquet spec, the above schema should be inferred as
array<array<int>>
.Are these changes tested?
Yes, a test case has been added to verify the fix.
Are there any user-facing changes?
No.