stevomitric opened a new pull request, #57697:
URL: https://github.com/apache/spark/pull/57697

   ### What changes were proposed in this pull request?
   
   This PR adds an optional fractional-seconds precision argument `p` to 
`current_timestamp(p)` / `now(p)` and `localtimestamp(p)`, mirroring the 
existing `current_time(p)`. It is part of the umbrella SPARK-56822 (timestamps 
with nanosecond precision).
   
   - `p == 6` (and the no-argument forms) keep the historical microsecond 
`TIMESTAMP` / `TIMESTAMP_NTZ` types unchanged.
   - `p` in `[7, 9]` returns a nanosecond `TIMESTAMP_LTZ(p)` / 
`TIMESTAMP_NTZ(p)`, gated behind `spark.sql.timestampNanosTypes.enabled`.
   - Any other precision is rejected with `INVALID_TIMESTAMP_PRECISION`, 
matching the `TIMESTAMP(p)` type parser (the range check runs before the 
feature-flag check).
   
   The micro leaf expressions `CurrentTimestamp` / `Now` / `LocalTimestamp` are 
kept as-is to preserve their rendering and pattern matching; two new 
placeholder expressions `CurrentTimestampNanos` / `LocalTimestampNanos` carry 
the precision, and `CurrentTimestampExpressionBuilder` / 
`LocalTimestampExpressionBuilder` dispatch on the argument count. 
`ComputeCurrentTime` constant-folds the new expressions into query-stable 
nanosecond literals, just like the microsecond variants.
   
   ### Why are the changes needed?
   
   ANSI SQL / Foundation defines an optional `<timestamp precision>` on 
`CURRENT_TIMESTAMP` and `LOCALTIMESTAMP` (Feature F555). This lets users obtain 
the current time at nanosecond precision when the nanosecond timestamp types 
are enabled.
   
   ### Does this PR introduce any user-facing change?
   
   Yes. `current_timestamp(p)` / `now(p)` / `localtimestamp(p)` now accept a 
precision argument. The no-argument forms are unchanged.
   
   ### How was this patch tested?
   
   - Catalyst unit tests: `ComputeCurrentTimeSuite` (folding, query-stability, 
precision flooring, time flow) and `DateExpressionsSuite` (the two expression 
builders, including the error paths).
   - End-to-end tests in `TimestampNanosFunctionsSuiteBase` (ANSI on and off): 
result types, precision flooring, query-stable self-equality, out-of-range 
precision, and the disabled-flag error.
   - New golden cases in `timestamp-ltz-nanos.sql` / `timestamp-ntz-nanos.sql`; 
regenerated `sql-expression-schema.md`.
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Co-authored: Claude Code (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]

Reply via email to