Allow to read parquet binary column as UTF8 type#6539
Merged
tustvold merged 2 commits intoapache:masterfrom Oct 10, 2024
Merged
Allow to read parquet binary column as UTF8 type#6539tustvold merged 2 commits intoapache:masterfrom
tustvold merged 2 commits intoapache:masterfrom
Conversation
tustvold
reviewed
Oct 10, 2024
| .build() | ||
| .expect("reader with schema"); | ||
|
|
||
| arrow_reader.next(); |
Contributor
There was a problem hiding this comment.
Suggested change
| arrow_reader.next(); | |
| arrow_reader.next().unwrap_err(); |
As this should error, given the data isn't actually UTF-8
tustvold
reviewed
Oct 10, 2024
Comment on lines
3132
to
3136
| .column(0) | ||
| .as_any() | ||
| .downcast_ref::<StringArray>() | ||
| .expect("downcast to string") | ||
| .iter() |
Contributor
There was a problem hiding this comment.
Suggested change
| .column(0) | |
| .as_any() | |
| .downcast_ref::<StringArray>() | |
| .expect("downcast to string") | |
| .iter() | |
| .column(0) | |
| .as_string::<i32>() | |
| .iter() |
And the same below
alamb
reviewed
Oct 10, 2024
| (DataType::Utf8, DataType::LargeUtf8) => hint, | ||
| (DataType::Binary, DataType::LargeBinary) => hint, | ||
|
|
||
| // Read as Utf8 |
alamb
reviewed
Oct 10, 2024
| } | ||
|
|
||
| #[test] | ||
| #[should_panic(expected = "Invalid UTF8 sequence at")] |
alamb
approved these changes
Oct 10, 2024
Contributor
alamb
left a comment
There was a problem hiding this comment.
Thank you @goldmedal and @tustvold -- this looks great to me
This was referenced Oct 10, 2024
Merged
Contributor
Author
3 tasks
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.
Which issue does this PR close?
No related issue.
Rationale for this change
While working on apache/datafusion#12788 (comment) in DataFusion, I found we can't read the parquet binary column as string types (Utf8, LargeUtf8, or Utf8View) through
ArrowReaderOptions::with_schema. I think it makes sense to read them as strings if the user ensures it's a string binary value.What changes are included in this PR?
I added some matching rules in
apply_hintinparquet/src/arrow/schema/primitive.rsto handle the binary-to-string cases.Are there any user-facing changes?
no
cc @alamb