[SPARK-57587][SQL][TEST] Generate TIME values with the declared precision in RandomDataGenerator#56779
Open
MaxGekk wants to merge 1 commit into
Open
[SPARK-57587][SQL][TEST] Generate TIME values with the declared precision in RandomDataGenerator#56779MaxGekk wants to merge 1 commit into
MaxGekk wants to merge 1 commit into
Conversation
…sion in RandomDataGenerator ### What changes were proposed in this pull request? Make TIME test-data generation honor the declared `TimeType` precision: - `RandomDataGenerator`: in the `case t: TimeType =>` branch, truncate the special/interesting TIME values to `t.precision` (previously only the uniform random draw was truncated), so values like `23:59:59.999999999` are no longer emitted for low precisions such as `TimeType(0)`. - `DataTypeTestUtils.timeTypes`: add an intermediate `TimeType(3)` between `MIN_PRECISION` (0) and `MAX_PRECISION` (9) so suites looping over `ordered` / `atomicTypes` / `propertyCheckSupported` exercise a non-endpoint precision. `LiteralGenerator.timeLiteralGen` is already precision-aware (landed with SPARK-57551), so no change is needed there. ### Why are the changes needed? The precision dimension of `DataTypeTestUtils.timeTypes` was effectively not exercised: the interesting-value path produced non-conforming TIME values regardless of the declared precision, and only the two endpoints were covered. ### Does this PR introduce _any_ user-facing change? No. Test-only. ### How was this patch tested? Ran the affected TIME-covering suites: `RandomDataGeneratorSuite`, `PredicateSuite`, `ConditionalExpressionSuite`, `ArithmeticExpressionSuite`, `OrderingSuite`, `CastSuite`, `CastWithAnsiOnSuite`, `UnsafeRowSuite`, and `SortSuite`.
uros-b
approved these changes
Jun 25, 2026
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?
Make TIME test-data generation honor the declared
TimeTypeprecision:RandomDataGenerator: in thecase t: TimeType =>branch, truncate the special/interesting TIME values tot.precision. Previously only the uniform random draw was truncated, while the special values (00:00:00,23:59:59.999999,23:59:59.999999999) were emitted unmodified, so the interesting-value path produced non-conforming values such as23:59:59.999999999even for low precisions likeTimeType(0).DataTypeTestUtils.timeTypes: add an intermediateTimeType(3)betweenMIN_PRECISION(0) andMAX_PRECISION(9), so the suites looping overordered/atomicTypes/propertyCheckSupportedactually exercise a non-endpoint precision.LiteralGenerator.timeLiteralGenis already precision-aware (landed with SPARK-57551), so no change is needed there.This is the precision-conformance follow-up to SPARK-51403 (TIME as ordered/atomic type) and SPARK-51669 (random TIME values in tests). SPARK-57551 raised
TimeType.MAX_PRECISIONfrom 6 to 9, widening the gap the generators must cover.Why are the changes needed?
The precision dimension of
DataTypeTestUtils.timeTypeswas effectively not exercised: the interesting-value path produced TIME values that do not conform to the declared precision, and only the two endpoints (0 and 9) were covered. Suites that loop overordered/atomicTypes/propertyCheckSupported(e.g.PredicateSuite,ConditionalExpressionSuite,ArithmeticExpressionSuite,OrderingSuite,SortSuite,CastSuite,RandomDataGeneratorSuite) therefore silently tested a single precision.Does this PR introduce any user-facing change?
No. This only fixes test data generation; there is no production code or versioning change.
How was this patch tested?
By running the affected TIME-covering suites and confirming they pass:
RandomDataGeneratorSuite,PredicateSuite,ConditionalExpressionSuite,ArithmeticExpressionSuite,OrderingSuite,CastSuite,CastWithAnsiOnSuite,UnsafeRowSuite, andSortSuite.Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor (Claude Opus 4.8)