[ 
https://issues.apache.org/jira/browse/SPARK-54442?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dongjoon Hyun resolved SPARK-54442.
-----------------------------------
    Fix Version/s: 4.2.0
       Resolution: Fixed

Issue resolved by pull request 53147
[https://github.com/apache/spark/pull/53147]

> Add numeric conversion functions for TIME type
> ----------------------------------------------
>
>                 Key: SPARK-54442
>                 URL: https://issues.apache.org/jira/browse/SPARK-54442
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 4.1.0
>            Reporter: Vinod KC
>            Assignee: Vinod KC
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 4.2.0
>
>
> Add numeric conversion functions for TIME type that are available for 
> TIMESTAMP. 
> eg : Existing numeric conversion for TIMESTAMP : 
> {code:java}
> SELECT timestamp_seconds(1230219000);-- Output: 2008-12-25 07:30:00
> SELECT timestamp_seconds(1230219000.123);  -- Supports fractional-- Output: 
> 2008-12-25 07:30:00.123
> SELECT timestamp_millis(1230219000123);-- Output: 2008-12-25 07:30:00.123
> SELECT timestamp_micros(1230219000123123);-- Output: 2008-12-25 
> 07:30:00.123123
> SELECT unix_seconds(timestamp'2020-12-01 14:30:08Z');-- Output: 1606833008
> SELECT unix_millis(timestamp'2020-12-01 14:30:08Z');-- Output: 1606833008000
> SELECT unix_micros(timestamp'2020-12-01 14:30:08Z');-- Output: 
> 1606833008000000
> {code}
>  
> Add similar functions for  *TIME* type, that will help to:
>  # Create TIME values from numeric representations 
> (seconds/milliseconds/microseconds since midnight)
>  # Extract numeric values from TIME for calculations or data exchange with 
> external systems
> *Proposal*
> Add six new SQL functions to support numeric conversions for TIME type:
>  * Constructor Functions (Numeric → TIME)
> {code:java}
> 1) time_from_seconds(seconds) - Create TIME from seconds since midnight 
> (supports fractional seconds via DECIMAL)
> 2) time_from_millis(millis) - Create TIME from milliseconds since midnight  
> 3) time_from_micros(micros) - Create TIME from microseconds since midnight 
> {code}
>  * Extractor Functions (TIME → Numeric)
> {code:java}
> 4) time_to_seconds(time) - Extract seconds since midnight as DECIMAL(14,6) to 
> preserve fractional seconds
> 5) time_to_millis(time) - Extract milliseconds since midnight as BIGINT
> 6) time_to_micros(time) - Extract microseconds since midnight as BIGINT {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to