[SPARK-58743][SQL][TESTS] Add nanosecond-timestamp coverage for mode - #57966
Open
stevomitric wants to merge 2 commits into
Open
[SPARK-58743][SQL][TESTS] Add nanosecond-timestamp coverage for mode#57966stevomitric wants to merge 2 commits into
stevomitric wants to merge 2 commits into
Conversation
`mode` counts frequencies in an `OpenHashMap` keyed on the physical `TimestampNanosVal` (its `equals`/`hashCode` cover the full `(epochMicros, nanosWithinMicro)` pair) and returns `child.dataType`. It already works over the nanosecond timestamp types (`TIMESTAMP_NTZ(p)` / `TIMESTAMP_LTZ(p)`, p in [7, 9]) but had no dedicated test coverage. Add an end-to-end test to `TimestampNanosFunctionsSuiteBase` (run in both ANSI modes) asserting that mode returns the most-frequent value keyed on the full nanos value (the frequent and rare values differ only within the microsecond) and preserves the input precision and family (NTZ/LTZ). Also add a deterministic golden SQL case (`mode(...)` with a unique most-frequent value) to `timestamp-ntz-nanos.sql` / `timestamp-ltz-nanos.sql`. Test-only; no production change. Co-authored-by: Isaac
Contributor
Author
|
cc @uros-b, @cloud-fan PTAL when you get a chance. |
uros-b
approved these changes
Aug 12, 2026
Member
|
Nice, thank you @stevomitric! |
cloud-fan
approved these changes
Aug 12, 2026
cloud-fan
left a comment
Contributor
There was a problem hiding this comment.
0 blocking, 0 non-blocking, 0 nits.
The coverage is deterministic, exercises the intended full-nanosecond distinction, and is consistent across the Scala and SQL golden test surfaces.
Verification
I traced the added inputs through the existing Mode aggregate and TimestampNanosVal equality/hash behavior, checked that the hot and cold values remain distinct at every tested precision, and reconciled the generated analyzer schemas and outputs with the queries. I did not run the Spark test suites.
PR metadata suggestions
- Document: replace
Test only changein the testing section with the exact suites or commands run and their results.
Member
|
@stevomitric Please fix lint issues. |
Reflow an over-long comment line in TimestampNanosFunctionsSuiteBase to stay within the 100-character limit. Comment-only change. Co-authored-by: Isaac
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.
What changes were proposed in this pull request?
Add an end-to-end test to
TimestampNanosFunctionsSuiteBase(run in both ANSI modes) asserting that mode returns the most-frequent value keyed on the full nanos value (the frequent and rare values differ only within the microsecond) and preserves the input precision and family (NTZ/LTZ). Also add a deterministic golden SQL case (mode(...)with a unique most-frequent value) totimestamp-ntz-nanos.sql/timestamp-ltz-nanos.sql.Why are the changes needed?
Extend test coverage for timestamp nanosecond precision datatype.
Does this PR introduce any user-facing change?
No, test only change.
How was this patch tested?
Test only change.
Was this patch authored or co-authored using generative AI tooling?
Co-Authored-By: Claude Code 4.8