zero323 commented on a change in pull request #27278:
[SPARK-30569][SQL][PYSPARK][SPARKR] Add percentile_approx DSL functions.
URL: https://github.com/apache/spark/pull/27278#discussion_r368307650
##########
File path: python/pyspark/sql/tests/test_functions.py
##########
@@ -310,6 +310,31 @@ def test_input_file_name_udf(self):
file_name = df.collect()[0].file
self.assertTrue("python/test_support/hello/hello.txt" in file_name)
+ def test_percentile_approx(self):
+ from pyspark.sql.functions import col, percentile_approx
+ from itertools import chain
+ import re
+
+ actual =
list(chain.from_iterable([re.findall("(percentile_approx\(.*\))", str(x)) for x
in [
+ percentile_approx(col("foo"), 0.5),
+ percentile_approx(col("bar"), 0.25, 42),
+ percentile_approx(col("bar"), [0.25, 0.5, 0.75]),
+ percentile_approx(col("foo"), [0.05, 0.95], 100),
+ percentile_approx("foo", 0.5),
+ percentile_approx("bar", [0.1, 0.9], 10),
+ ]]))
+
+ expected = [
+ "percentile_approx(foo, 0.5, 10000)",
+ "percentile_approx(bar, 0.25, 42)",
+ "percentile_approx(bar, [0.25,0.5,0.75], 10000)",
+ "percentile_approx(foo, [0.05,0.95], 100)",
+ "percentile_approx(foo, 0.5, 10000)",
+ "percentile_approx(bar, [0.1,0.9], 10)"
+ ]
+
+ self.assertListEqual(actual, expected)
Review comment:
Same as in case of R we want to check if data is properly passed to JVM.
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]