zhengruifeng opened a new pull request, #46196: URL: https://github.com/apache/spark/pull/46196
### What changes were proposed in this pull request? Make `max_by, min_by` doctests deterministic ### Why are the changes needed? https://github.com/apache/spark/pull/45939 fixed this issue by sorting the rows, unfortunately, it is not enough: in group `department=Finance`, two rows `("Finance", "Frank", 5)` and `("Finance", "George", 5)` have the same value `years_in_dept=5`, so `min_by("name", "years_in_dept")` and `max_by("name", "years_in_dept")` is still non-deterministic. This test failed in some env: ``` ********************************************************************** File "/home/jenkins/python/pyspark/sql/connect/functions/builtin.py", line 1177, in pyspark.sql.connect.functions.builtin.max_by Failed example: df.groupby("department").agg( sf.max_by("name", "years_in_dept") ).sort("department").show() Expected: +----------+---------------------------+ |department|max_by(name, years_in_dept)| +----------+---------------------------+ | Consult| Henry| | Finance| George| +----------+---------------------------+ Got: +----------+---------------------------+ |department|max_by(name, years_in_dept)| +----------+---------------------------+ | Consult| Henry| | Finance| Frank| +----------+---------------------------+ <BLANKLINE> ********************************************************************** File "/home/jenkins/python/pyspark/sql/connect/functions/builtin.py", line 1205, in pyspark.sql.connect.functions.builtin.min_by Failed example: df.groupby("department").agg( sf.min_by("name", "years_in_dept") ).sort("department").show() Expected: +----------+---------------------------+ |department|min_by(name, years_in_dept)| +----------+---------------------------+ | Consult| Eva| | Finance| George| +----------+---------------------------+ Got: +----------+---------------------------+ |department|min_by(name, years_in_dept)| +----------+---------------------------+ | Consult| Eva| | Finance| Frank| +----------+---------------------------+ <BLANKLINE> ********************************************************************** ``` ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? ci ### Was this patch authored or co-authored using generative AI tooling? no -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
