MaxGekk opened a new pull request #25336: [SPARK-28017][SQL] Support additional 
levels by DATE_TRUNC/TRUNC
URL: https://github.com/apache/spark/pull/25336
 
 
   ## What changes were proposed in this pull request?
   
   I propose new levels of truncations for the `date_trunc()` and `trunc()` 
functions: 
   1. `MICROSECOND` and `MILLISECOND` truncate values of the `TIMESTAMP` type 
to microsecond and millisecond precision.
   2. `DECADE`, `CENTURY` and `MILLENNIUM` truncate dates/timestamps to lowest 
date of current decade/century/millennium.
   
   The function is implemented similarly to `date_trunc` in PostgreSQL: 
https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-TRUNC
 to maintain feature parity with it.   
   
   Here are examples of `TRUNC`:
   ```sql
   spark-sql> SELECT TRUNC('2015-10-27', 'DECADE');
   2010-01-01
   spark-sql> set spark.sql.datetime.java8API.enabled=true;
   spark.sql.datetime.java8API.enabled  true
   spark-sql> SELECT TRUNC('1999-10-27', 'millennium');
   1001-01-01
   ```
   Examples of `DATE_TRUNC`:
   ```sql
   spark-sql> SELECT DATE_TRUNC('CENTURY', '2015-03-05T09:32:05.123456');
   2001-01-01T00:00:00Z
   ```
   
   ## How was this patch tested?
   
   Added new tests to `DateExpressionsSuite` and `DateFunctionsSuite`, and 
uncommented existing tests in `pgSQL/date.sql`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to