yadavay-amzn opened a new pull request, #56931:
URL: https://github.com/apache/spark/pull/56931
### What changes were proposed in this pull request?
`EXTRACT(SECOND FROM t)` / `date_part('SECOND', t)` on a `TIME(p)` value
returned a hardcoded `DecimalType(8, 6)` regardless of the TIME precision. This
changes the result type to `DecimalType(2 + p, p)`, so the fractional-second
scale matches the value's precision (e.g. `TIME(0)` -> `decimal(2,0)`,
`TIME(6)` -> `decimal(8,6)`).
### Why are the changes needed?
The scale was always 6, so `EXTRACT(SECOND)` on e.g. `TIME(0)` reported an
incorrect `decimal(8,6)` type with spurious fractional digits. The scale should
reflect the value's declared precision.
### Does this PR introduce _any_ user-facing change?
Yes. `EXTRACT(SECOND FROM <TIME(p)>)` / `date_part('SECOND', <TIME(p)>)` now
returns `DecimalType(2 + p, p)` instead of always `DecimalType(8, 6)`.
TIMESTAMP behavior is unchanged.
### How was this patch tested?
Unit tests in `TimeExpressionsSuite` asserting both the result `DecimalType`
and the value across TIME precisions 0-6; the `time.sql` `SQLQueryTestSuite`
golden was updated accordingly.
### Was this patch authored or co-authored using generative AI tooling?
Authored with assistance by Claude Opus 4.8.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]