beliefer opened a new pull request #29626:
URL: https://github.com/apache/spark/pull/29626


   ### What changes were proposed in this pull request?
   Spark SQL exists a bug show below:
   
   ```
   spark.sql(
     " SELECT COUNT(DISTINCT 2), COUNT(DISTINCT 2, 3)")
     .show()
   +-----------------+--------------------+
   |count(DISTINCT 2)|count(DISTINCT 2, 3)|
   +-----------------+--------------------+
   |                1|                   1|
   +-----------------+--------------------+
   
   spark.sql(
     " SELECT COUNT(DISTINCT 2), COUNT(DISTINCT 3, 2)")
     .show()
   +-----------------+--------------------+
   |count(DISTINCT 2)|count(DISTINCT 3, 2)|
   +-----------------+--------------------+
   |                1|                   0|
   +-----------------+--------------------+
   ```
   The first query is correct, but the second query is not.
   The root reason is the first not rewrited by `RewriteDistinctAggregates`.
   
   
   ### Why are the changes needed?
   Fix a bug.
   `SELECT COUNT(DISTINCT 2), COUNT(DISTINCT 3, 2)` should return 1, 1
   
   
   ### Does this PR introduce _any_ user-facing change?
   Yes
   
   
   ### How was this patch tested?
   New UT
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



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

Reply via email to