Conversation
…examples Adds comprehensive tests verifying that schema hashing and data hashing are fully recursive and field-order independent for nested structures. Order-independence tests (arrow_digester.rs): - deeply_nested_struct_schema_hash_is_field_order_independent: 3-level struct schema hash unchanged regardless of inner-field insertion order - deeply_nested_struct_record_batch_hash_is_field_order_independent: same guarantee for record-batch data hashing - hash_array_nested_struct_is_field_order_independent: hash_array API with a struct containing a nested struct - list_of_struct_schema_hash_is_field_order_independent: List<Struct> schema hash is independent of inner struct field order - list_of_struct_record_batch_hash_is_field_order_independent: same for actual record-batch data Byte-exact conformance tests (digest_bytes.rs): - example_o_nested_struct_record_batch: pins the exact canonical JSON and leaf-path byte layout for a two-level struct column, confirming paths "s/a", "s/nested/p", "s/nested/q" with correct i32 LE bytes - example_p_nested_struct_field_order_independence: pins the expected canonical JSON for a schema whose struct fields are defined out of alphabetical order at both nesting levels, confirming recursive alphabetical sorting produces a stable hash Closes PLT-840 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Add five order-independence tests for deeply nested structs, list-of-struct, and hash_array in tests/arrow_digester.rs (issue PLT-840) - Add byte-exact conformance tests for Examples O, P, Q in tests/digest_bytes.rs, covering nested-struct record batch, field-order independence, and hash_array - Document Examples O, P, Q in docs/byte-layout-spec.md with full byte-level computation steps matching the test implementations Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ests Add #[expect(clippy::similar_names)] on example_o, example_q, and deeply_nested_struct_schema_hash tests where variable names intentionally mirror the spec's path notation (snp/snq, x/y, z_first/a_first). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds regression tests and specification examples to lock in Starfix’s recursive struct field-order normalization (schema/type hashing and record-batch/array data hashing) so that nested struct insertion order cannot affect digests.
Changes:
- Add order-independence tests for deeply-nested structs and list-of-struct shapes across
hash_schema,hash_record_batch,hash_array, and streamingupdate(). - Add byte-exact conformance tests for nested structs (record batch +
hash_array) and a pinned canonical JSON example for nested struct ordering. - Extend the byte-layout spec with new Examples O–Q documenting canonical JSON, leaf paths, and byte-level hashing steps.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| tests/digest_bytes.rs | Adds byte-exact examples O–Q for nested structs, including pinned canonical JSON and leaf-path hashing. |
| tests/arrow_digester.rs | Adds order-independence tests for nested structs (schema, record batches, hash_array, streaming update) and list-of-struct cases. |
| docs/byte-layout-spec.md | Documents Examples O–Q to match/anchor the new conformance tests and recursive ordering behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes PLT-840: Change schema hashing to be recursively ordered.
The existing implementation already performs recursive alphabetical ordering of struct fields at every nesting level (via
data_type_to_valuefor schema hashing andBTreeMap-keyed paths for data hashing). This PR adds the missing test coverage to document, verify, and lock in that behaviour across all relevant nesting shapes.New tests — order independence (
tests/arrow_digester.rs)deeply_nested_struct_schema_hash_is_field_order_independentStruct<Struct<fields>>— inner-field insertion order must not affecthash_schemadeeply_nested_struct_record_batch_hash_is_field_order_independenthash_array_nested_struct_is_field_order_independenthash_arrayAPI with a struct containing a nested structlist_of_struct_schema_hash_is_field_order_independentList<Struct<fields>>schema hash independent of inner struct field orderlist_of_struct_record_batch_hash_is_field_order_independentNew tests — byte-exact conformance (
tests/digest_bytes.rs)s/a,s/nested/p,s/nested/q) for a two-level struct column; verifies each leaf is hashed with the correct little-endian bytesTest plan
cargo test)cargo fmtapplied, no formatting changesCloses PLT-840