test(jni): assert the Java and Rust expression tag tables agree - #9454
Open
jackylee-ch wants to merge 1 commit into
Open
test(jni): assert the Java and Rust expression tag tables agree#9454jackylee-ch wants to merge 1 commit into
jackylee-ch wants to merge 1 commit into
Conversation
Expression hands four byte tags across the JNI boundary, and each one has its own reader on the Rust side: BinaryOp is read by parse_op, DuplicateHandling by parse_duplicate_handling, TimeUnit by TimeUnit::try_from, and DType by the table in literalNull. Three of the four javadocs state that the values must match the Rust table, but nothing enforced it, and drift compiles cleanly on both sides. The two drift shapes fail differently. A tag past the end of a table reaches the other => arm and throws at runtime. A tag that collides with a sibling decodes to the wrong operator or the wrong time unit and returns an expression that reads valid, so it surfaces later as a wrong scan result rather than an error. Pin each table twice: the constants against the bytes Rust matches, and every constant through the native call that consumes it. Both temporal types are exercised because between them they reject enough units to distinguish the five TimeUnit tags -- Timestamp accepts everything but Days, Date only Days and Milliseconds -- and Date names the unit it rejected. Signed-off-by: jackylee <qcsd2011@gmail.com>
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.
Rationale for this change
Expressionhands four byte tags to the native side, each with its own reader inexpression.rs:BinaryOp→parse_op,DuplicateHandling→parse_duplicate_handling,TimeUnit→TimeUnit::try_from,DType→ the table inliteralNull. Three of the four javadocs say the values must match the Rust table; nothing checked it. Drift compiles on both sides, and the two failure modes differ: a tag past the end of a table throws at runtime, but a tag that collides with a sibling decodes to the wrong operator or unit and returns an expression that reads valid.What changes are included in this PR?
Test only, one new file. Each table is pinned twice — the constants against the bytes Rust matches, and every constant through the native call that consumes it.
Both temporal types are covered because between them they reject enough units to tell the five
TimeUnittags apart: Timestamp takes everything butDAYS, Date onlyDAYSandMILLISECONDS.Verified non-vacuous: eight mutations of the Java tables, covering both off-the-end and colliding tags, each fail a targeted test.
:vortex-jni:testgoes from 32 to 46, no failures.What APIs are changed? Are there any user-facing changes?
None.
AI assistance
Prepared with agentic AI assistance. I read both sides of each table and confirmed the mutations fail.