You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Guillaume Massé (Jira)" <ji...@apache.org> on 2023/08/07 18:42:00 UTC

[jira] [Updated] (CALCITE-5902) Add DATE_TRUNC function consistent with Apache Spark

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

Guillaume Massé updated CALCITE-5902:
-------------------------------------
    Description: 
Add DATE_TRUNC function consistent with Apache Spark. Per the [specification|https://spark.apache.org/docs/3.4.0/api/sql/index.html#date_trunc], the syntax is as follows:

DATE_TRUNC(<format string>, <datetime | timestamp string>)
{noformat}
fmt - the format representing the unit to be truncated to
"YEAR", "YYYY", "YY" - truncate to the first date of the year that the ts falls in, the time part will be zero out
"QUARTER" - truncate to the first date of the quarter that the ts falls in, the time part will be zero out
"MONTH", "MM", "MON" - truncate to the first date of the month that the ts falls in, the time part will be zero out
"WEEK" - truncate to the Monday of the week that the ts falls in, the time part will be zero out
"DAY", "DD" - zero out the time part
"HOUR" - zero out the minute and second with the fraction part
"MINUTE"- zero out the second with the fraction part
"SECOND" - zero out the second fraction part
"MILLISECOND" - zero out the microseconds
"MICROSECOND" - everything remains
{noformat}

  was:
Add DATE_TRUNC function consistent with Apache Spark. Per the specification, the syntax is as follows:

DATE_TRUNC(<format string>, <datetime | timestamp string>)



{noformat}
fmt - the format representing the unit to be truncated to
"YEAR", "YYYY", "YY" - truncate to the first date of the year that the ts falls in, the time part will be zero out
"QUARTER" - truncate to the first date of the quarter that the ts falls in, the time part will be zero out
"MONTH", "MM", "MON" - truncate to the first date of the month that the ts falls in, the time part will be zero out
"WEEK" - truncate to the Monday of the week that the ts falls in, the time part will be zero out
"DAY", "DD" - zero out the time part
"HOUR" - zero out the minute and second with the fraction part
"MINUTE"- zero out the second with the fraction part
"SECOND" - zero out the second fraction part
"MILLISECOND" - zero out the microseconds
"MICROSECOND" - everything remains
{noformat}



> Add DATE_TRUNC function consistent with Apache Spark
> ----------------------------------------------------
>
>                 Key: CALCITE-5902
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5902
>             Project: Calcite
>          Issue Type: New Feature
>          Components: core
>    Affects Versions: 1.35.0
>            Reporter: Guillaume Massé
>            Priority: Minor
>
> Add DATE_TRUNC function consistent with Apache Spark. Per the [specification|https://spark.apache.org/docs/3.4.0/api/sql/index.html#date_trunc], the syntax is as follows:
> DATE_TRUNC(<format string>, <datetime | timestamp string>)
> {noformat}
> fmt - the format representing the unit to be truncated to
> "YEAR", "YYYY", "YY" - truncate to the first date of the year that the ts falls in, the time part will be zero out
> "QUARTER" - truncate to the first date of the quarter that the ts falls in, the time part will be zero out
> "MONTH", "MM", "MON" - truncate to the first date of the month that the ts falls in, the time part will be zero out
> "WEEK" - truncate to the Monday of the week that the ts falls in, the time part will be zero out
> "DAY", "DD" - zero out the time part
> "HOUR" - zero out the minute and second with the fraction part
> "MINUTE"- zero out the second with the fraction part
> "SECOND" - zero out the second fraction part
> "MILLISECOND" - zero out the microseconds
> "MICROSECOND" - everything remains
> {noformat}



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