-
Notifications
You must be signed in to change notification settings - Fork 1k
[Variant] Refactor cast_to_variant
#8235
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
[Variant] Refactor cast_to_variant
#8235
Conversation
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc}; | ||
use parquet_variant::{ | ||
Variant, VariantBuilder, VariantDecimal16, VariantDecimal4, VariantDecimal8, | ||
}; | ||
|
||
fn convert_timestamp( |
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.
Move this helper function below cast_to_variant
so that the public function appears first, making this file easier to read and reason about.
fn convert_list<O: OffsetSizeTrait>( | ||
input: &dyn Array, | ||
builder: &mut VariantArrayBuilder, | ||
) -> Result<(), ArrowError> { |
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.
The logic for List
and LargeList
is the same, refactor them into this generic helper function
Ok(()) | ||
} | ||
|
||
fn convert_struct(input: &dyn Array, builder: &mut VariantArrayBuilder) -> Result<(), ArrowError> { |
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.
moved from the Struct
branch without any changes
// Add all values from the slice | ||
for j in start..end { | ||
list_builder.append_value(values_variant_array.value(j)); | ||
fn convert_map( |
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.
moved from the Map
branch without any changes
@@ -2243,7 +2131,7 @@ mod tests { | |||
} | |||
|
|||
#[test] | |||
fn test_cast_map_with_non_string_keys_to_variant_object() { | |||
fn test_cast_to_variant_map_with_non_string_keys() { |
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.
rename to match the naming convention in this file
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 but will conflict with
Should we be intentional about which one merges first? This one will be super conflict-prone, so we probably need to merge it first or risk getting on a treadmill.
Thanks for pointing out! I can go either way as that PR only touches the timestamp conversion, but it might be better to make this one go first |
@alamb -- I think this one is ready for your review+merge; two other PR are stacked on top waiting for it: |
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.
Thank you @liamzwbao and @scovich
Take care and we'll see you when you get back |
Which issue does this PR close?
cast_to_variant
#8234.Rationale for this change
What changes are included in this PR?
Are these changes tested?
Covered by existing tests
Are there any user-facing changes?
N/A