Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SPARK-49387][PYTHON] Fix type hint for accuracy in percentile_approx and approx_percentile #47869

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/pyspark/sql/connect/functions/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -1223,7 +1223,7 @@ def percentile(
def percentile_approx(
col: "ColumnOrName",
percentage: Union[Column, float, Sequence[float], Tuple[float]],
accuracy: Union[Column, float] = 10000,
accuracy: Union[Column, int] = 10000,
) -> Column:
percentage = lit(list(percentage)) if isinstance(percentage, (list, tuple)) else lit(percentage)
return _invoke_function_over_columns("percentile_approx", col, percentage, lit(accuracy))
Expand All @@ -1235,7 +1235,7 @@ def percentile_approx(
def approx_percentile(
col: "ColumnOrName",
percentage: Union[Column, float, Sequence[float], Tuple[float]],
accuracy: Union[Column, float] = 10000,
accuracy: Union[Column, int] = 10000,
) -> Column:
percentage = lit(list(percentage)) if isinstance(percentage, (list, tuple)) else lit(percentage)
return _invoke_function_over_columns("approx_percentile", col, percentage, lit(accuracy))
Expand Down
8 changes: 4 additions & 4 deletions python/pyspark/sql/functions/builtin.py
Original file line number Diff line number Diff line change
Expand Up @@ -6339,7 +6339,7 @@ def percentile(
def percentile_approx(
col: "ColumnOrName",
percentage: Union[Column, float, Sequence[float], Tuple[float]],
accuracy: Union[Column, float] = 10000,
accuracy: Union[Column, int] = 10000,
) -> Column:
"""Returns the approximate `percentile` of the numeric column `col` which is the smallest value
in the ordered `col` values (sorted from least to greatest) such that no more than `percentage`
Expand All @@ -6360,7 +6360,7 @@ def percentile_approx(
When percentage is an array, each value of the percentage array must be between 0.0 and 1.0.
In this case, returns the approximate percentile array of column col
at the given percentage array.
accuracy : :class:`~pyspark.sql.Column` or float
accuracy : :class:`~pyspark.sql.Column` or int
is a positive numeric literal which controls approximation accuracy
at the cost of memory. Higher value of accuracy yields better accuracy,
1.0/accuracy is the relative error of the approximation. (default: 10000).
Expand Down Expand Up @@ -6397,7 +6397,7 @@ def percentile_approx(
def approx_percentile(
col: "ColumnOrName",
percentage: Union[Column, float, Sequence[float], Tuple[float]],
accuracy: Union[Column, float] = 10000,
accuracy: Union[Column, int] = 10000,
) -> Column:
"""Returns the approximate `percentile` of the numeric column `col` which is the smallest value
in the ordered `col` values (sorted from least to greatest) such that no more than `percentage`
Expand All @@ -6414,7 +6414,7 @@ def approx_percentile(
When percentage is an array, each value of the percentage array must be between 0.0 and 1.0.
In this case, returns the approximate percentile array of column col
at the given percentage array.
accuracy : :class:`~pyspark.sql.Column` or float
accuracy : :class:`~pyspark.sql.Column` or int
is a positive numeric literal which controls approximation accuracy
at the cost of memory. Higher value of accuracy yields better accuracy,
1.0/accuracy is the relative error of the approximation. (default: 10000).
Expand Down