GitHub user clockfly opened a pull request:

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

    [SPARK-15776][SQL] Divide Expression inside Aggregation function is casted 
to wrong type

    ## What changes were proposed in this pull request?
    
    This PR fixes the problem that Divide Expression inside Aggregation 
function is casted to wrong type. After the fix, the behavior is consistent 
with Hive.
    
    **Before the change:**
    
    ```
    scala> sql("select sum(1 / 2) as a").schema
    res4: org.apache.spark.sql.types.StructType = 
StructType(StructField(a,LongType,true))
    
    scala> sql("select sum(1 / 2) as a").show()
    +---+
    |  a|
    +---+
    |0  |
    +---+
    ```
    
    **After the change:**
    
    ```
    scala> sql("select sum(1 / 2) as a").schema
    res4: org.apache.spark.sql.types.StructType = 
StructType(StructField(a,DoubleType,true))
    
    scala> sql("select sum(1 / 2) as a").show()
    +---+
    |  a|
    +---+
    |0.5|
    +---+
    ```
    
    ## How was this patch tested?
    
    Unit test.
    
    This PR is based on https://github.com/apache/spark/pull/13524 by 
@Sephiroth-Lin

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

    $ git pull https://github.com/clockfly/spark SPARK-15776

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

    https://github.com/apache/spark/pull/13651.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 #13651
    
----
commit df08eeacd85187ca5a71463fc5d25f63426ebe84
Author: Sean Zhong <seanzh...@databricks.com>
Date:   2016-06-13T22:09:20Z

    SPARK-15776 Divide Expression inside an Aggregation function is casted to 
wrong type

----


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