MaxGekk opened a new pull request #25388: [SPARK-28656][SQL] Support `millenium`, `century` and `decade` at `extract()` URL: https://github.com/apache/spark/pull/25388 ## What changes were proposed in this pull request? In the PR, I propose new expressions `Millennium`, `Century` and `Decade`, and support additional parameters of `extract()` for feature parity with PostgreSQL (https://www.postgresql.org/docs/11/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT): 1. `millennium` - the current millennium for given date (or a timestamp implicitly casted to a date). For example, years in the 1900s are in the second millennium. The third millennium started _January 1, 2001_. 2. `century` - the current millennium for given date (or timestamp). The first century starts at 0001-01-01 AD. 3. `decade` - the current decade for given date (or timestamp). Actually, this is the year field divided by 10. Here are examples: ```sql spark-sql> SELECT EXTRACT(MILLENNIUM FROM DATE '1981-01-19'); 2 spark-sql> SELECT EXTRACT(CENTURY FROM DATE '1981-01-19'); 20 spark-sql> SELECT EXTRACT(DECADE FROM DATE '1981-01-19'); 198 ``` Also the expressions are registered as functions - `millennium`, `century` and `decade`. For example: ```sql spark-sql> SELECT MILLENNIUM('2019-08-08'); 3 spark-sql> SELECT CENTURY('2019-08-08'); 21 spark-sql> SELECT DECADE('2019-08-08'); 201 ``` ## How was this patch tested? Added new tests to `DateExpressionsSuite`, `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]
