You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Uroš Bojanić (Jira)" <ji...@apache.org> on 2025/12/08 12:26:00 UTC
[jira] [Commented] (SPARK-54442) Add numeric conversion functions for TIME type
[ https://issues.apache.org/jira/browse/SPARK-54442?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18043549#comment-18043549 ]
Uroš Bojanić commented on SPARK-54442:
--------------------------------------
[~dongjoon] Please move this ticket back to https://issues.apache.org/jira/browse/SPARK-51162 (Time SPIP umbrella).
> 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: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org