GitHub user wangyum opened a pull request:

    https://github.com/apache/spark/pull/20067

    [SPARK-22894][SQL] DateTimeOperations should accept SQL like string type

    ## What changes were proposed in this pull request?
    
    `DateTimeOperations` accept 
[`StringType`](https://github.com/apache/spark/blob/ae998ec2b5548b7028d741da4813473dde1ad81e/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercion.scala#L669),
  but:
    
    ```
    spark-sql> SELECT '2017-12-24' + interval 2 months 2 seconds;
    Error in query: cannot resolve '(CAST('2017-12-24' AS DOUBLE) + interval 2 
months 2 seconds)' due to data type mismatch: differing types in 
'(CAST('2017-12-24' AS DOUBLE) + interval 2 months 2 seconds)' (double and 
calendarinterval).; line 1 pos 7;
    'Project [unresolvedalias((cast(2017-12-24 as double) + interval 2 months 2 
seconds), None)]
    +- OneRowRelation
    spark-sql> 
    ```
    
    After this PR:
    ```
    spark-sql> SELECT '2017-12-24' + interval 2 months 2 seconds;
    2018-02-24 00:00:02
    Time taken: 0.2 seconds, Fetched 1 row(s)
    
    ```
    
    ## How was this patch tested?
    
    unit tests
    
    Please review http://spark.apache.org/contributing.html before opening a 
pull request.


You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/wangyum/spark SPARK-22894

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/20067.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #20067
    
----
commit ae998ec2b5548b7028d741da4813473dde1ad81e
Author: Yuming Wang <wgyumg@...>
Date:   2017-12-23T19:45:31Z

    DateTimeOperations should accept SQL like string type

----


---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to