Github user HyukjinKwon commented on the issue:

    https://github.com/apache/spark/pull/14788
  
    I took a look for MySQL and PostgreSQL. It seems they are not really 
consistent for `NEXT_DAY`, `LAST_DAY` and `TRUNC` but it seems the return types 
are fixed in general (whether it is `DateType` or `TimestampType` in terms of 
Spark).
    
    In more details, I skimmed through the function list here for MySQL 
http://www.tutorialspoint.com/mysql/mysql-date-time-functions.htm and for 
PostgreSQL https://www.postgresql.org/docs/9.1/static/functions-datetime.html, 
and then tried to apply some equivalent as below: 
    
    - PostgreSQL
    
     - `TRUNC` - Always returns `TimestampType` (in terms of Spark).
    
      ```sql
      postgres=# SELECT DATE_TRUNC('day', CAST('2015-10-10' AS DATE));
             date_trunc
      ------------------------
       2015-10-10 00:00:00+02
      (1 row)
      ```
    
      ```sql
      postgres=# SELECT DATE_TRUNC('day', CAST('2015-10-10 12:00:00' AS 
TIMESTAMP));
           date_trunc
      ---------------------
       2015-10-10 00:00:00
      (1 row)
      ```
    
    - MySQL
    
      - `LASY_DAY` - Always returns `DateType` (in terms of Spark).
    
      ```sql
      mysql> SELECT LAST_DAY(CAST("2015-10-10 12:00:00" AS DATETIME));
      +---------------------------------------------------+
      | LAST_DAY(CAST("2015-10-10 12:00:00" AS DATETIME)) |
      +---------------------------------------------------+
      | 2015-10-31                                        |
      +---------------------------------------------------+
      1 row in set (0.00 sec)
      ```
    



---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to