Repository navigation
Match struct scalar casts by field name and add Hegel suites - #12340
lwwmanning wants to merge 9 commits into
Conversation
Signed-off-by: Will Manning <will@willmanning.io>
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
roborev: Combined Review (
|
Merging this PR will improve performance by 15.18%Warning vortex-data has exceeded the Hobby plan limit of 5 active contributors. Upgrade your plan or apply to the open source program by December 8, 2026 to keep using CodSpeed. 2 warnings
Performance Changes
Tip Curious why performance improved? Comment Comparing Footnotes
|
lwwmanning
left a comment
There was a problem hiding this comment.
Posted by Claude Opus 5.5 on Will's behalf.
The cast fix matches struct_cast_fields and is the right size. Cutting about 5,300 test lines in favor of Hegel suites is welcome, but a few gaps came with it.
- vortex-array/src/scalar/typed_view/struct_.rs line 220: the null-struct early return skips the schema check. A null {a: i32?} scalar cast to nullable {a: i32?, b: i32} returns a null, but StructArray::cast of a one-row all-null struct fails with "CAST for struct only supports added nullable fields". That is the scalar-versus-array mismatch this PR removes elsewhere. Please run the field check before the null return. Please also add a rename case with the same field count ({a, b} to {x, y}). Its result changes most, and Hegel never draws it because names are always f0 to fN.
- vortex-array/src/scalar/tests/hegel.rs lines 491 to 550: Constant's CastReduce returns scalar.cast whenever it succeeds, so the ConstantArray comparison checks Scalar::cast against itself. The Canonical oracle skips null scalars (line 526) and accepts a scalar Ok with an array Err (line 548). The case above falls through both gaps. Please run the oracle for nulls and fail on (Ok, Err), or list the known exceptions.
- The equality laws check reflexivity, symmetry and coherence, but not direction. An Eq that called every pair of non-null values equal would pass. The ordering-direction tests for list, FixedSizeList, extension, struct, decimal and float are gone. So are the hash tests for the ListScalar and ExtScalar impls and for nested nullability. One rstest per view with a known smaller and larger value would restore them.
- vortex-array/src/scalar/tests/casting.rs line 229: union_nullability_casts compares with Scalar ==, which ignores nullability. So the old checks that the cast child becomes nullable Utf8 and the other child stays non-nullable I32 no longer test anything. Asserting on dtype() would fix it. test_scalar_into_nullable has the same problem.
- Decimal and primitive exact values: the exact f64 cast became a relative tolerance of one part in 10^15 (decimal/tests.rs line 197). The I16 carry width check is gone, because DecimalValue == ignores width. From checks only the type (lines 229 to 241). Three error messages are now just is_err(). The f32 and f64 coerce-from-unsigned arms in pvalue.rs lines 610 to 640 and PValue::zero == 0 lost their tests.
- all_non_distinct: hegel_nullable_garbage_under_nulls_ignored (tests.rs line 182) has no List case, and nothing draws equal flattened elements with different list offsets on the non-zero-copy ListView path. Those were list_nullable_ignores_garbage and list_different_lengths.
- Proto: draw_variant_inner never nests a Variant inside a Variant, and draw_decimal_value always uses the canonical width. So the old nested-variant and non-canonical-width decimal roundtrips are lost.
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
|
Addressed all findings from the Claude Opus 5.5 review and roborev in 069c99c:
|
…ty checks Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
lwwmanning
left a comment
There was a problem hiding this comment.
Posted by Claude Opus 5.5 on Will's behalf.
Commits 069c99c and 05d00d3 resolve the earlier review. Null struct casts now check added fields. The rename, ordering, hash, union, decimal, list and proto gaps have tests. The Canonical oracle now fails when the scalar cast succeeds and the array cast fails.
One small gap remains. The check in check_struct_cast_added_fields in scalar/typed_view/struct_.rs line 330 checks only the top level. Take a null scalar of nullable struct {a: {b: i32}}, cast to nullable {a: {b: i32, c: i32}}. It passes the check and returns a null. But StructArray::cast fails on the child a, because c is a new non-nullable field.
The Hegel oracle comment at hegel.rs line 585 says it never ignores this error. The generator in draw_cast_target can draw this shape, so it is also a rare latent Hegel failure. Recursing into matched struct fields would fix it in a few lines.
05d00d3 also changes StructArray::cast to match repeated field names by occurrence. Please mention that behavior change in the description.
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
|
Addressed both items in 3bbd3b5: |
…stant::cast Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
There was a problem hiding this comment.
Posted by Claude Opus 5.5 on Will's behalf.
Commits 3bbd3b5 and 978fbea resolve my last review. check_struct_cast_added_fields now recurses into nested structs, lists and maps. Constant::cast now reports the error instead of falling back. The new test checks that the scalar cast, the constant cast and the canonical cast all fail with the same error. The description now names the change to repeated field names.
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
…tions Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
robert3005
left a comment
There was a problem hiding this comment.
The duplicate-name handling preserves occurrence order. I found a performance regression in the shared mapping used by the array cast.
— Codex (OpenAI)
Signed-off-by: Will Manning <will@spiraldb.com> Co-Authored-By: Will Manning <will@spiraldb.com>
Updates
StructScalar::castto match fields by name whenever source and target struct field names differ—reordering fields, dropping removed fields, filling added nullable fields with null, and rejecting added non-nullable fields (including recursively on null structs)—soScalar::castandConstantArray::castagree withStructArray::castinstead of silently mapping values positionally. Replaces redundant manual per-type boilerplate acrossvortex-array's scalar andall_non_distincttest suites with fast Hegel property tests covering nested proto roundtrips, scalar-vs-array casting,DecimalValuecross-width coherence, nullability laws, andall_non_distinctdifferential parity against the scalar baseline.Behaviour change: when field-name lists differ,
StructArray::cast,StructScalar::cast, and struct extension-cast validation now match repeated field names by occurrence rather than reusing the first matching source field; extra target occurrences beyond the source count are treated as added fields.Assisted by Antigravity.