Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/16404
  
    ```Scala
    sql("select a + rand() from testData2 group by a, a + rand()").explain(true)
    ```
    
    After we merging this PR, I am afraid we might hitting a common 
misunderstanding. Users might assume `a + rand()` in the aggregate and group by 
are referring to the same expression. However, the non-deterministic 
expressions `rand()` in aggregate and group by actually return different 
results. See the plan
    ```
    (CAST(a AS DOUBLE) + rand(-8319334304660323190)): double
    Aggregate [a#23, (cast(a#23 as double) + _nondeterministic#249)], 
[(cast(a#23 as double) + rand(-8319334304660323190)) AS (CAST(a AS DOUBLE) + 
rand(-8319334304660323190))#248]
    +- Project [a#23, b#24, rand(-993354445377164024) AS _nondeterministic#249]
       +- SubqueryAlias testdata2, `testData2`
          +- SerializeFromObject [assertnotnull(assertnotnull(input[0, 
org.apache.spark.sql.test.SQLTestData$TestData2, true], top level Product input 
object), - root class: "org.apache.spark.sql.test.SQLTestData.TestData2").a AS 
a#23, assertnotnull(assertnotnull(input[0, 
org.apache.spark.sql.test.SQLTestData$TestData2, true], top level Product input 
object), - root class: "org.apache.spark.sql.test.SQLTestData.TestData2").b AS 
b#24]
             +- ExternalRDD [obj#22]
    ```
    



---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to