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

   ### What changes were proposed in this pull request?
   
   This PR enables standard implicit type coercion for the timestamp and origin 
arguments of
   `time_bucket`. In ANSI and legacy modes, Spark casts `DATE` and `STRING` 
inputs to `TIMESTAMP`.
   The bucket-size argument stays strict and accepts only the supported 
interval types.
   
   The PR also adds coercion tests for both modes and updates the SQL query 
tests and generated
   golden files.
   
   
   ### Why are the changes needed?
   
   `time_bucket` declares timestamp input requirements, but the expression 
bypasses Spark's normal
   implicit casting rules. It therefore rejects `DATE` and `STRING` values that 
Spark accepts for
   other timestamp inputs.
   
   This change makes `time_bucket` consistent with Spark's standard timestamp 
coercion behavior.
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `time_bucket` now accepts `DATE` and `STRING` values for its timestamp 
and origin arguments.
   For example:
   
   ```sql
   SELECT time_bucket(INTERVAL '15' MINUTE, DATE '2024-01-15');
   -- 2024-01-15 00:00:00
   
   SELECT time_bucket(INTERVAL '15' MINUTE, '2024-01-15 10:23:00');
   -- 2024-01-15 10:15:00
   ```
   
   
   ### How was this patch tested?
   
   The patch adds ANSI and legacy type-coercion tests. It also adds SQL query 
coverage for `DATE`
   and `STRING` timestamp and origin arguments.
   
   ```bash
   build/sbt 'catalyst/testOnly *TypeCoercionSuite -- -z "time_bucket"'
   build/sbt 'sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z 
"time-bucket.sql"'
   ```
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   
   Generated-by: OpenAI Codex (GPT-5)
   


-- 
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