Skip to content

Conversation

@alamb
Copy link
Contributor

@alamb alamb commented Nov 25, 2025

Which issue does this PR close?

Rationale for this change

In this comment here: #8887 (comment)

One of the tests intended to cover the behavior of CastOptions actually contains an invalid Shredded variant (the values could not have been shredded successfully because the integer values are out of range)

My understanding is that the test is intended to illustrate that casting fails when a non-shredded variant into a shredded variant. Thus, it would not have been possible to create the incorrect shredded variant in the first place (there would have been an error during shredding)

What changes are included in this PR?

  1. Update the test to provide a valid VariantArray, and update the error message

Are these changes tested?

Only tests

Are there any user-facing changes?

None -- this is a test only change

@github-actions github-actions bot added the parquet-variant parquet-variant* crates label Nov 25, 2025
@alamb alamb changed the title Update variant_get error test Update variant_get error test so it uses a valid VariantArray Nov 25, 2025
@alamb alamb changed the title Update variant_get error test so it uses a valid VariantArray Update test_variant_get_error_when_cast_failure... tests to uses a valid VariantArray Nov 25, 2025
let mut builder = VariantArrayBuilder::new(3);
// 86401000000 is invalid for Time64Microsecond (max is 86400000000)
Time64MicrosecondArray::from(vec![
Some(86401000000),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an invalid Time64MicrosecondArray and thus I would expect this array to be impossible to create with shred_variant (I would expect shred_variant to error)

err.to_string().contains(
"Cast error: Cast failed at index 0 (array type: Time64(µs)): Invalid microsecond from midnight: 86401000000"
)
"Cast error: Failed to extract primitive of type Time64(µs) from variant Int64(86401000000) at path VariantPath([])"
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 case still errors, but the message is different

@alamb alamb marked this pull request as ready for review November 25, 2025 17:45
Copy link
Contributor

@XiangpengHao XiangpengHao left a 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, thank you @alamb , once this is merged, I'll point #8887 to this

@alamb
Copy link
Contributor Author

alamb commented Nov 26, 2025

Copy link
Contributor

@friendlymatthew friendlymatthew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me

Copy link
Member

@klion26 klion26 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the improvement, LGTM

@alamb
Copy link
Contributor Author

alamb commented Dec 1, 2025

Thanks @klion26 and @XiangpengHao

@alamb alamb merged commit fe94a25 into apache:main Dec 1, 2025
19 checks passed
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.

4 participants