SQL: Add alias DATETRUNC to DATE_TRUNC function (#47173)

To be on the safe side in terms of use cases also add the alias
DATETRUNC to the DATE_TRUNC function.

Follows: #46473

(cherry picked from commit 9ac223cb1fc66486f86e218fa785a32b61e9bacc)
This commit is contained in:
Marios Trivyzas 2019-09-27 15:38:03 +03:00
parent 4c909438dd
commit 01623f9f1c
No known key found for this signature in database
GPG Key ID: 8817B46B0CF36A3F
4 changed files with 7 additions and 5 deletions

View File

@ -249,7 +249,7 @@ Currently, using a _precision_ greater than 3 doesn't make any difference to the
function as the maximum number of second fractional digits returned is 3 (milliseconds). function as the maximum number of second fractional digits returned is 3 (milliseconds).
[[sql-functions-datetime-trunc]] [[sql-functions-datetime-trunc]]
==== `DATE_TRUNC` ==== `DATE_TRUNC/DATETRUNC`
.Synopsis: .Synopsis:
[source, sql] [source, sql]
@ -269,7 +269,7 @@ DATE_TRUNC(
.Description: .Description:
Truncate the date/datetime to the specified unit by setting all fields that are less significant than the specified Truncate the date/datetime to the specified unit by setting all fields that are less significant than the specified
one to zero (or one, for day, day of week and month). one to zero (or one, for day, day of week and month). If any of the two arguments is `null` a `null` is returned.
[cols="^,^"] [cols="^,^"]
|=== |===

View File

@ -39,6 +39,7 @@ CURRENT_DATE |SCALAR
CURRENT_TIME |SCALAR CURRENT_TIME |SCALAR
CURRENT_TIMESTAMP|SCALAR CURRENT_TIMESTAMP|SCALAR
CURTIME |SCALAR CURTIME |SCALAR
DATETRUNC |SCALAR
DATE_TRUNC |SCALAR DATE_TRUNC |SCALAR
DAY |SCALAR DAY |SCALAR
DAYNAME |SCALAR DAYNAME |SCALAR

View File

@ -235,6 +235,7 @@ CURRENT_DATE |SCALAR
CURRENT_TIME |SCALAR CURRENT_TIME |SCALAR
CURRENT_TIMESTAMP|SCALAR CURRENT_TIMESTAMP|SCALAR
CURTIME |SCALAR CURTIME |SCALAR
DATETRUNC |SCALAR
DATE_TRUNC |SCALAR DATE_TRUNC |SCALAR
DAY |SCALAR DAY |SCALAR
DAYNAME |SCALAR DAYNAME |SCALAR
@ -2424,7 +2425,7 @@ SELECT DATE_TRUNC('millennium', '2019-09-04T11:22:33.123Z'::datetime) AS millenn
truncateDateTimeWeek truncateDateTimeWeek
// tag::truncateDateTimeWeek // tag::truncateDateTimeWeek
SELECT DATE_TRUNC('week', '2019-08-24T11:22:33.123Z'::datetime) AS week; SELECT DATETRUNC('week', '2019-08-24T11:22:33.123Z'::datetime) AS week;
week week
------------------------ ------------------------
@ -2456,7 +2457,7 @@ SELECT DATE_TRUNC('decade', CAST('2019-09-04' AS DATE)) AS decades;
truncateDateQuarter truncateDateQuarter
schema::quarter:ts schema::quarter:ts
// tag::truncateDateQuarter // tag::truncateDateQuarter
SELECT DATE_TRUNC('quarters', CAST('2019-09-04' AS DATE)) AS quarter; SELECT DATETRUNC('quarters', CAST('2019-09-04' AS DATE)) AS quarter;
quarter quarter
------------------------ ------------------------

View File

@ -194,7 +194,7 @@ public class FunctionRegistry {
def(DayOfMonth.class, DayOfMonth::new, "DAY_OF_MONTH", "DAYOFMONTH", "DAY", "DOM"), def(DayOfMonth.class, DayOfMonth::new, "DAY_OF_MONTH", "DAYOFMONTH", "DAY", "DOM"),
def(DayOfWeek.class, DayOfWeek::new, "DAY_OF_WEEK", "DAYOFWEEK", "DOW"), def(DayOfWeek.class, DayOfWeek::new, "DAY_OF_WEEK", "DAYOFWEEK", "DOW"),
def(DayOfYear.class, DayOfYear::new, "DAY_OF_YEAR", "DAYOFYEAR", "DOY"), def(DayOfYear.class, DayOfYear::new, "DAY_OF_YEAR", "DAYOFYEAR", "DOY"),
def(DateTrunc.class, DateTrunc::new, "DATE_TRUNC"), def(DateTrunc.class, DateTrunc::new, "DATETRUNC", "DATE_TRUNC"),
def(HourOfDay.class, HourOfDay::new, "HOUR_OF_DAY", "HOUR"), def(HourOfDay.class, HourOfDay::new, "HOUR_OF_DAY", "HOUR"),
def(IsoDayOfWeek.class, IsoDayOfWeek::new, "ISO_DAY_OF_WEEK", "ISODAYOFWEEK", "ISODOW", "IDOW"), def(IsoDayOfWeek.class, IsoDayOfWeek::new, "ISO_DAY_OF_WEEK", "ISODAYOFWEEK", "ISODOW", "IDOW"),
def(IsoWeekOfYear.class, IsoWeekOfYear::new, "ISO_WEEK_OF_YEAR", "ISOWEEKOFYEAR", "ISOWEEK", "IWOY", "IW"), def(IsoWeekOfYear.class, IsoWeekOfYear::new, "ISO_WEEK_OF_YEAR", "ISOWEEKOFYEAR", "ISOWEEK", "IWOY", "IW"),