Skip to content

[SPARK-57587][SQL][TEST] Generate TIME values with the declared precision in RandomDataGenerator#56779

Open
MaxGekk wants to merge 1 commit into
apache:masterfrom
MaxGekk:time-fix-generators
Open

[SPARK-57587][SQL][TEST] Generate TIME values with the declared precision in RandomDataGenerator#56779
MaxGekk wants to merge 1 commit into
apache:masterfrom
MaxGekk:time-fix-generators

Conversation

@MaxGekk

@MaxGekk MaxGekk commented Jun 25, 2026

Copy link
Copy Markdown
Member

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, 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 as 23:59:59.999999999 even for low precisions like TimeType(0).
  • DataTypeTestUtils.timeTypes: add an intermediate TimeType(3) between MIN_PRECISION (0) and MAX_PRECISION (9), so the suites looping over ordered / atomicTypes / propertyCheckSupported actually exercise a non-endpoint precision.

LiteralGenerator.timeLiteralGen is 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_PRECISION from 6 to 9, widening the gap the generators must cover.

Why are the changes needed?

The precision dimension of DataTypeTestUtils.timeTypes was 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 over ordered / 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, and SortSuite.

Was this patch authored or co-authored using generative AI tooling?

Generated-by: Cursor (Claude Opus 4.8)

…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 uros-b left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @MaxGekk, LGTM!

@dongjoon-hyun dongjoon-hyun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1, LGTM.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants