-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
ARROW-10996: [Rust] [Parquet] change return value type of get_arrow_schema_from_metadata() #9058
Conversation
get_arrow_schema_from_metadata
The full set of Rust CI tests did not run on this PR :( Can you please rebase this PR against apache/master to pick up the changes in #9056 so that they do? I apologize for the inconvenience. |
beceee3
to
2254cb5
Compare
@alamb thanks |
2254cb5
to
c904ee9
Compare
Codecov Report
@@ Coverage Diff @@
## master #9058 +/- ##
=======================================
Coverage 82.61% 82.62%
=======================================
Files 202 202
Lines 50048 50055 +7
=======================================
+ Hits 41347 41356 +9
+ Misses 8701 8699 -2
Continue to review full report at Codecov.
|
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. Thanks a lot @mqy for taking this on. I always hit those prints when searching for my own prints in the code 😆
rust/parquet/src/arrow/schema.rs
Outdated
.remove(super::ARROW_SCHEMA_META_KEY) | ||
.map(|encoded| get_arrow_schema_from_metadata(&encoded)); | ||
|
||
let arrow_schema_metadata = match maybe_schema { |
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.
There may be an idiom for this in rust (that I do not know).
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.
@jorgecarleitao thank you for the tip!
The codes were updated to use map_or
for flipping Option<Result>
to Result<Option>
.
BTW, I found some similar usage of map_or
in parquet/src/column/writer.rs
🥇
rust/parquet/src/arrow/schema.rs
Outdated
_ => None, | ||
}; | ||
.map(|encoded| get_arrow_schema_from_metadata(&encoded)) | ||
.map_or(Ok(None), |v| v.map(Some))?; |
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.
I think this can use unwrap_or, as both of the cases map to Ok?
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.
@Dandandan thanks a lot! The code looks more concise!
@@ -123,7 +119,7 @@ where | |||
let arrow_schema_metadata = metadata | |||
.remove(super::ARROW_SCHEMA_META_KEY) | |||
.map(|encoded| get_arrow_schema_from_metadata(&encoded)) | |||
.unwrap_or_default(); | |||
.map_or(Ok(None), |v| v.map(Some))?; |
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.
I think you can use it here to
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.
Thanks, let me try
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.
Looks good to me -- thanks @mqy
I think @Dandandan has one more suggested cleanup https://github.com/apache/arrow/pull/9058/files#r550758655 -- but I also think this PR is fine to merge as is.
Let me know if you want to make any more changes -- once you are finished we'll merge it.
Thanks again
@Dandandan @alamb Sorry, I failed to apply |
@mqy no problem, is a rather small style improvement anyway. |
Thanks a lot for helping out in the reviews, @Dandandan , much appreciated 💯 |
…chema_from_metadata() apache#8936 updated crate `flatbuffers` to 0.8.0 , but function `get_arrow_schema_from_metadata` still returning `Option` rather than `Result`. This PR fixes this issue. Closes apache#9058 from mqy/get_arrow_schema_from_metadata Authored-by: mqy <meng.qingyou@gmail.com> Signed-off-by: Jorge C. Leitao <jorgecarleitao@gmail.com>
#8936 updated crate
flatbuffers
to 0.8.0 , but functionget_arrow_schema_from_metadata
still returningOption
rather thanResult
. This PR fixes this issue.