Skip to content

[Variant] Align cast logic for variant_get to cast kernel for numeric/bool types#9563

Open
klion26 wants to merge 3 commits intoapache:mainfrom
klion26:variant_cast_number_and_bool
Open

[Variant] Align cast logic for variant_get to cast kernel for numeric/bool types#9563
klion26 wants to merge 3 commits intoapache:mainfrom
klion26:variant_cast_number_and_bool

Conversation

@klion26
Copy link
Member

@klion26 klion26 commented Mar 16, 2026

Which issue does this PR close?

What changes are included in this PR?

Align tests with cast kernel

Are these changes tested?

Covered by the existing tests

Are there any user-facing changes?

No

@klion26 klion26 changed the title WIP [Variant] Align cast logic for variant_get to cast kernel for numeric/bool types Mar 16, 2026
@github-actions github-actions bot added arrow Changes to the arrow crate parquet-variant parquet-variant* crates labels Mar 16, 2026
Copy link
Member Author

@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.

@scovich This is what is in my mind to align cast logic for variant_get with cast kernel, current, only changed int/float/double/bool (no decimal for now).

Currently, this will change some behaviors (details in inline comments). Please help review this when you're in free, thanks.

Variant::Int64(i) if fits_precision::<11>(i) => Some(f16::from_f32(i as _)),
_ => None,
}
self.as_num::<f16>()
Copy link
Member Author

Choose a reason for hiding this comment

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

This will change the behavior from before. Now 65536 will return Some(inf) instead of None.

Variant::Int64(i) => num_cast::<i64, T>(i),
Variant::Float(f) => num_cast::<f32, T>(f),
Variant::Double(d) => num_cast::<f64, T>(d),
Variant::Decimal4(d) if d.scale() == 0 => num_cast::<_, T>(d.integer()),
Copy link
Member Author

Choose a reason for hiding this comment

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

from/to_decimal needs to be added in a following commit if the direction is right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrow Changes to the arrow crate parquet-variant parquet-variant* crates

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Variant] Align cast logic for variant_get to cast kernel for numeric/bool types

1 participant