Add UnionScalar#8739
Conversation
Signed-off-by: "Connor Tsui" <connor.tsui20@gmail.com>
Merging this PR will not alter performance
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
7e619d3 to
243969b
Compare
| // Union nullability is part of its variant dtypes, so the generic nullability-only cast | ||
| // below is not valid for unions. Keep all non-identity union casts unsupported until their | ||
| // semantics are defined. | ||
| if matches!(self.dtype(), DType::Union(_)) || matches!(target_dtype, DType::Union(_)) { | ||
| vortex_bail!( | ||
| "non-identity union scalar cast from {} to {target_dtype} is not supported", | ||
| self.dtype() | ||
| ); | ||
| } |
There was a problem hiding this comment.
Interested in what people think about how we should deal with this
8bb8db6 to
7925944
Compare
| /// We implement `Hash` manually so top-level dtype nullability does not affect the hash. | ||
| impl Hash for Scalar { | ||
| fn hash<H: Hasher>(&self, state: &mut H) { | ||
| // TODO(connor): Recursively ignore dtype nullability to match Scalar equality (#8744). |
43d2fc9 to
9de7663
Compare
Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
9de7663 to
4893177
Compare
| dtype: &'a DType, | ||
| /// The variants of the union. | ||
| /// | ||
| /// We store this here as a convenience so that we do not need to unwrap the dtype every time. | ||
| variants: &'a UnionVariants, |
There was a problem hiding this comment.
Should we just store the nullability here so we don't need the DType at all?
Rationale for this change
Tracking Issue: #7882
UnionScalaris the row representation needed for scalar access and constant arrays before the canonicalUnionArray. Non-null values store the selected type ID and childScalarValue; null remains on the outerScalar, avoiding a second null layer.What changes are included in this PR?
UnionValue,UnionScalar, construction, downcasts, validation, display, equality, hashing, defaults, and sizingConstantArrayscalar access coverageTested with
cargo nextest run -p vortex-arrayandcargo clippy --all-targets --all-features.What APIs are changed? Are there any user-facing changes?
Adds
ScalarValue::Union,UnionValue,UnionScalar,Scalar::union, and the Union scalar downcasts.