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

Max Gekk updated SPARK-51554:
-----------------------------
    Description: 
The time_trunc() function returns time truncated to the unit specified in unit.

h4. Syntax

{code:sql}
time_trunc(unit, expr)
{code}

h4. Arguments
* unit: A STRING literal.
* expr: A TIME, or STRING with a valid time format.

h4. 
A TIME\(n\) with n matching that of expr.

h4. Notes
Valid units for unit are (case-insensitive):
* 'HOUR': zero out the minute and second with fraction part
* 'MINUTE': zero out the second with fraction part
* 'SECOND': zero out the second fraction part
* 'MILLISECOND': zero out the microseconds
* 'MICROSECOND': everything remains
If the unit is not well-formed the function returns NULL.

h4. Examples

{code:sql}
> SELECT time_trunc('HOUR', '09:32:05.359');
 09:00:00

> SELECT time_trunc('MILLISECOND', '09:32:05.123456');
 09:32:05.123

-- Not a recognised unit
> SELECT time_trunc('MS', '09:32:05.123456');
 NULL
{code}




  was:
The time_trunc() function returns time truncated to the unit specified in unit.

h4. Syntax

{code:sql}
time_trunc(unit, expr)
{code}

h4. Arguments
* unit: A STRING literal.
* expr: A TIME, or STRING with a valid time format.

h4. 
A TIME(n) with n matching that of expr.

h4. Notes
Valid units for unit are (case-insensitive):
* 'HOUR': zero out the minute and second with fraction part
* 'MINUTE': zero out the second with fraction part
* 'SECOND': zero out the second fraction part
* 'MILLISECOND': zero out the microseconds
* 'MICROSECOND': everything remains
If the unit is not well-formed the function returns NULL.

h4. Examples

{code:sql}
> SELECT time_trunc('HOUR', '09:32:05.359');
 09:00:00

> SELECT time_trunc('MILLISECOND', '09:32:05.123456');
 09:32:05.123

-- Not a recognised unit
> SELECT time_trunc('MS', '09:32:05.123456');
 NULL
{code}





> Add the time_trunc() function
> -----------------------------
>
>                 Key: SPARK-51554
>                 URL: https://issues.apache.org/jira/browse/SPARK-51554
>             Project: Spark
>          Issue Type: Sub-task
>          Components: SQL
>    Affects Versions: 4.1.0
>            Reporter: Max Gekk
>            Priority: Major
>
> The time_trunc() function returns time truncated to the unit specified in 
> unit.
> h4. Syntax
> {code:sql}
> time_trunc(unit, expr)
> {code}
> h4. Arguments
> * unit: A STRING literal.
> * expr: A TIME, or STRING with a valid time format.
> h4. 
> A TIME\(n\) with n matching that of expr.
> h4. Notes
> Valid units for unit are (case-insensitive):
> * 'HOUR': zero out the minute and second with fraction part
> * 'MINUTE': zero out the second with fraction part
> * 'SECOND': zero out the second fraction part
> * 'MILLISECOND': zero out the microseconds
> * 'MICROSECOND': everything remains
> If the unit is not well-formed the function returns NULL.
> h4. Examples
> {code:sql}
> > SELECT time_trunc('HOUR', '09:32:05.359');
>  09:00:00
> > SELECT time_trunc('MILLISECOND', '09:32:05.123456');
>  09:32:05.123
> -- Not a recognised unit
> > SELECT time_trunc('MS', '09:32:05.123456');
>  NULL
> {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