GitHub user dongjoon-hyun opened a pull request:

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

    [SPARK-23774][SQL] `Cast` to CHAR/VARCHAR should truncate the values

    ## What changes were proposed in this pull request?
    
    This PR aims to fix the following `CAST` behavior on `CHAR/VARCHAR` types.
    
    **Spark (2.2.1 and 2.3.0)**
    ```scala
    scala> sql("SELECT CAST('123' AS CHAR(1)), CAST('123' AS VARCHAR(1))").show
    +-------------------+-------------------+
    |CAST(123 AS STRING)|CAST(123 AS STRING)|
    +-------------------+-------------------+
    |                123|                123|
    +-------------------+-------------------+
    ```
    
    **Hive (1.2.1 ~ 2.3.2)**
    ```
    hive> SELECT CAST('123' AS CHAR(1)), CAST('123' AS VARCHAR(1));
    OK
    1   1
    ```
    
    ## How was this patch tested?
    
    Pass the Jenkins with newly added test cases and existing one

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

    $ git pull https://github.com/dongjoon-hyun/spark SPARK-23774

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

    https://github.com/apache/spark/pull/20887.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 #20887
    
----
commit 78cf26a6c5ba4a68bb9a09db2f6ebb9edc6c92ef
Author: Dongjoon Hyun <dongjoon@...>
Date:   2018-03-22T21:37:22Z

    [SPARK-23774][SQL] `Cast` to CHAR/VARCHAR should truncate the values

----


---

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

Reply via email to