[SPARK-58742][SQL][TESTS] Add nanosecond-timestamp coverage for collect_set - #57965
Open
stevomitric wants to merge 1 commit into
Open
[SPARK-58742][SQL][TESTS] Add nanosecond-timestamp coverage for collect_set#57965stevomitric wants to merge 1 commit into
stevomitric wants to merge 1 commit into
Conversation
…ct_set `collect_set` deduplicates via a `HashSet` keyed on the physical `TimestampNanosVal`, whose `equals`/`hashCode` cover the full `(epochMicros, nanosWithinMicro)` pair, so sub-microsecond-distinct values are kept distinct; the result element type is exactly `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 collect_set deduplicates on the full nanosecond value: sub-microsecond-distinct values stay distinct at p=9 but collapse when floored below the grid at p in [7, 8]. Also add a deterministic golden SQL case (`sort_array(collect_set(...))`) 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
|
Looks good, 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 added coverage is internally consistent and exercises the intended precision-sensitive deduplication behavior.
Verification
I traced the new assertions through the precision-specific inputs and checked the generated SQL results: the precision-9 cases retain the two sub-microsecond-distinct values, while the focused Scala test expects the correctly floored single value at precisions 7 and 8. The contract scan also verified the comments against CollectSet, TimestampNanosVal equality/hash behavior, timestamp flooring, and sort_array.
PR metadata suggestions
- Explain the relationship between SPARK-58742 in the PR title and SPARK-56822 in the added test names/comments, or align the identifiers.
Member
|
@stevomitric Please fix lint issues. |
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 collect_set deduplicates on the full nanosecond value: sub-microsecond-distinct values stay distinct at p=9 but collapse when floored below the grid at p in [7, 8]. Also add a deterministic golden SQL case (sort_array(collect_set(...))) 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