GitHub user techaddict opened a pull request:

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

    [SPARK-16323] [SQL] Add IntegerDivide to avoid unnecessary cast

    ## What changes were proposed in this pull request?
    Add IntegerDivide to avoid unnecessary cast
    
    Before:
    ```
    scala> spark.sql("select 6 div 3").explain(true)
    ...
    == Analyzed Logical Plan ==
    CAST((6 / 3) AS BIGINT): bigint
    Project [cast((cast(6 as double) / cast(3 as double)) as bigint) AS
    CAST((6 / 3) AS BIGINT)#5L]
    +- OneRowRelation$
    ...
    ```
    
    After:
    ```
    scala> spark.sql("select 6 div 3").explain(true)
    ...
    == Analyzed Logical Plan ==
    (6 / 3): int
    Project [(6 / 3) AS (6 / 3)#11]
    +- OneRowRelation$
    ...
    ```
    
    ## How was this patch tested?
    Existing Tests and added new ones

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

    $ git pull https://github.com/techaddict/spark SPARK-16323

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

    https://github.com/apache/spark/pull/14036.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 #14036
    
----
commit 067b788b05846e659615feef8613f8965573f150
Author: Sandeep Singh <sand...@techaddict.me>
Date:   2016-07-03T09:00:11Z

    [SPARK-16323] [SQL] Add IntegerDivide to avoid unnecessary cast
    
    Before:
    ```
    scala> spark.sql("select 6 div 3").explain(true)
    ...
    == Analyzed Logical Plan ==
    CAST((6 / 3) AS BIGINT): bigint
    Project [cast((cast(6 as double) / cast(3 as double)) as bigint) AS
    CAST((6 / 3) AS BIGINT)#5L]
    +- OneRowRelation$
    ...
    ```
    
    After:
    ```
    scala> spark.sql("select 6 div 3").explain(true)
    ...
    == Analyzed Logical Plan ==
    (6 / 3): int
    Project [(6 / 3) AS (6 / 3)#11]
    +- OneRowRelation$
    ...
    ```

commit e4e42c35b0236dff6aedf6468a7d94f80bc6023b
Author: Sandeep Singh <sand...@techaddict.me>
Date:   2016-07-03T09:00:59Z

    Merge branch 'master' into SPARK-16323

----


---
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