Skip to content

Conversation

liamzwbao
Copy link
Contributor

Which issue does this PR close?

Rationale for this change

What changes are included in this PR?

  • Grouping related data types together (e.g., numeric types, temporal types).
  • Extracting large code snippets from match branches into helper functions.
  • Reordering tests to align with the data type order.

Are these changes tested?

Covered by existing tests

Are there any user-facing changes?

N/A

@github-actions github-actions bot added the parquet-variant parquet-variant* crates label Aug 28, 2025
use chrono::{DateTime, NaiveDate, NaiveDateTime, NaiveTime, TimeZone, Utc};
use parquet_variant::{
Variant, VariantBuilder, VariantDecimal16, VariantDecimal4, VariantDecimal8,
};

fn convert_timestamp(
Copy link
Contributor Author

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> {
Copy link
Contributor Author

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> {
Copy link
Contributor Author

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(
Copy link
Contributor Author

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() {
Copy link
Contributor Author

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

@liamzwbao liamzwbao marked this pull request as ready for review August 28, 2025 00:22
Copy link
Contributor

@scovich scovich left a 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.

@liamzwbao
Copy link
Contributor Author

liamzwbao commented Aug 28, 2025

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

@scovich
Copy link
Contributor

scovich commented Sep 5, 2025

@alamb -- I think this one is ready for your review+merge; two other PR are stacked on top waiting for it:

Copy link
Contributor

@alamb alamb left a 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

@alamb alamb merged commit 2a8b183 into apache:main Sep 5, 2025
12 checks passed
@liamzwbao
Copy link
Contributor Author

Thank you, @scovich @alamb! I will be out for 2 weeks, will resolve the conflicts of the 2 following PRs when I come back

@alamb
Copy link
Contributor

alamb commented Sep 8, 2025

Take care and we'll see you when you get back

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
parquet-variant parquet-variant* crates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Variant] Refactor cast_to_variant
3 participants