GitHub user HyukjinKwon opened a pull request:

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

    [SPARK-17212][SQL] TypeCoercion supports widening conversion between 
DateType and TimestampType

    ## What changes were proposed in this pull request?
    
    Currently, type-widening does not work between `TimestampType` and 
`DateType`.
    
    This applies to `SetOperation`, `Union`, `In`, `CaseWhen`, `Greatest`,  
`Leatest`, `CreateArray`, `CreateMap` and `Coalesce`.
    
    For a simple example, 
    
    ```
    Seq(Tuple2(new Timestamp(0), new Date(0))).toDF("a", 
"b").selectExpr("greatest(a, b)").show()
    ```
    
    shows below:
    
    ```
    cannot resolve 'greatest(`a`, `b`)' due to data type mismatch: The 
expressions should all have the same type, got GREATEST(timestamp, date)
    ```
    
    or union as below:
    
    ```scala
    val a = Seq(Tuple1(new Timestamp(0))).toDF()
    val b = Seq(Tuple1(new Date(0))).toDF()
    a.union(b).show()
    ```
    
    shows below:
    
    ```
    Union can only be performed on tables with the compatible column types. 
DateType <> TimestampType at the first column of the second table;
    ```
    
    This PR adds the support for widening `DateType` to `TimestampType`.
    
    ## How was this patch tested?
    
    Unit tests in `TypeCoercionSuite`.

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

    $ git pull https://github.com/HyukjinKwon/spark SPARK-17212

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

    https://github.com/apache/spark/pull/14786.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 #14786
    
----
commit d49fbdbacd6b3ced5801ff62afc7ec12a8831028
Author: hyukjinkwon <gurwls...@gmail.com>
Date:   2016-08-24T10:52:20Z

    TypeCoercion supports widening conversion between DateType and TimestampType

----


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to