You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "peter-toth (via GitHub)" <gi...@apache.org> on 2023/08/22 13:28:14 UTC

[GitHub] [spark] peter-toth opened a new pull request, #42610: [SPARK-44871][SQL][3.4] Fix percentile_disc behaviour

peter-toth opened a new pull request, #42610:
URL: https://github.com/apache/spark/pull/42610

   ### What changes were proposed in this pull request?
   This PR fixes `percentile_disc()` function as currently it returns inforrect results in some cases. E.g.:
   ```
   SELECT
     percentile_disc(0.0) WITHIN GROUP (ORDER BY a) as p0,
     percentile_disc(0.1) WITHIN GROUP (ORDER BY a) as p1,
     percentile_disc(0.2) WITHIN GROUP (ORDER BY a) as p2,
     percentile_disc(0.3) WITHIN GROUP (ORDER BY a) as p3,
     percentile_disc(0.4) WITHIN GROUP (ORDER BY a) as p4,
     percentile_disc(0.5) WITHIN GROUP (ORDER BY a) as p5,
     percentile_disc(0.6) WITHIN GROUP (ORDER BY a) as p6,
     percentile_disc(0.7) WITHIN GROUP (ORDER BY a) as p7,
     percentile_disc(0.8) WITHIN GROUP (ORDER BY a) as p8,
     percentile_disc(0.9) WITHIN GROUP (ORDER BY a) as p9,
     percentile_disc(1.0) WITHIN GROUP (ORDER BY a) as p10
   FROM VALUES (0), (1), (2), (3), (4) AS v(a)
   ```
   currently returns:
   ```
   +---+---+---+---+---+---+---+---+---+---+---+
   | p0| p1| p2| p3| p4| p5| p6| p7| p8| p9|p10|
   +---+---+---+---+---+---+---+---+---+---+---+
   |0.0|0.0|0.0|1.0|1.0|2.0|2.0|2.0|3.0|3.0|4.0|
   +---+---+---+---+---+---+---+---+---+---+---+
   ```
   but after this PR it returns the correct:
   ```
   +---+---+---+---+---+---+---+---+---+---+---+
   | p0| p1| p2| p3| p4| p5| p6| p7| p8| p9|p10|
   +---+---+---+---+---+---+---+---+---+---+---+
   |0.0|0.0|0.0|1.0|1.0|2.0|2.0|3.0|3.0|4.0|4.0|
   +---+---+---+---+---+---+---+---+---+---+---+
   ```
   
   ### Why are the changes needed?
   Bugfix.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, fixes a correctness bug, but the old behaviour can be restored with `spark.sql.legacy.percentileDiscCalculation=true`.
   
   ### How was this patch tested?
   Added new UTs.
   


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] MaxGekk closed pull request #42610: [SPARK-44871][SQL][3.4] Fix percentile_disc behaviour

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk closed pull request #42610: [SPARK-44871][SQL][3.4] Fix percentile_disc behaviour
URL: https://github.com/apache/spark/pull/42610


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] MaxGekk commented on pull request #42610: [SPARK-44871][SQL][3.4] Fix percentile_disc behaviour

Posted by "MaxGekk (via GitHub)" <gi...@apache.org>.
MaxGekk commented on PR #42610:
URL: https://github.com/apache/spark/pull/42610#issuecomment-1688541336

   +1, LGTM. Merging to 3.4.
   Thank you, @peter-toth and @cloud-fan for review.


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

To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org