Skip to content

Commit 0d553d0

Browse files
committed
[SPARK-47906][PYTHON][DOCS] Fix docstring and type hint of hll_union_agg
### What changes were proposed in this pull request? - Fix docstring; - Fix type hint: `allowDifferentLgConfigK: Optional[bool]` -> `Optional[Union[bool, Column]]` - Simplify implementation ### Why are the changes needed? fix incorrect docstring and type hints ### Does this PR introduce _any_ user-facing change? yes, doc changes ### How was this patch tested? ci ### Was this patch authored or co-authored using generative AI tooling? no Closes #46128 from zhengruifeng/fix_type_hll_union_agg. Authored-by: Ruifeng Zheng <ruifengz@apache.org> Signed-off-by: Ruifeng Zheng <ruifengz@apache.org>
1 parent 2bf4346 commit 0d553d0

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

python/pyspark/sql/connect/functions/builtin.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3775,16 +3775,14 @@ def hll_sketch_agg(col: "ColumnOrName", lgConfigK: Optional[Union[int, Column]]
37753775
hll_sketch_agg.__doc__ = pysparkfuncs.hll_sketch_agg.__doc__
37763776

37773777

3778-
def hll_union_agg(col: "ColumnOrName", allowDifferentLgConfigK: Optional[bool] = None) -> Column:
3778+
def hll_union_agg(
3779+
col: "ColumnOrName",
3780+
allowDifferentLgConfigK: Optional[Union[bool, Column]] = None,
3781+
) -> Column:
37793782
if allowDifferentLgConfigK is None:
37803783
return _invoke_function_over_columns("hll_union_agg", col)
37813784
else:
3782-
_allowDifferentLgConfigK = (
3783-
lit(allowDifferentLgConfigK)
3784-
if isinstance(allowDifferentLgConfigK, bool)
3785-
else allowDifferentLgConfigK
3786-
)
3787-
return _invoke_function_over_columns("hll_union_agg", col, _allowDifferentLgConfigK)
3785+
return _invoke_function_over_columns("hll_union_agg", col, lit(allowDifferentLgConfigK))
37883786

37893787

37903788
hll_union_agg.__doc__ = pysparkfuncs.hll_union_agg.__doc__

python/pyspark/sql/functions/builtin.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19354,7 +19354,8 @@ def hll_sketch_agg(col: "ColumnOrName", lgConfigK: Optional[Union[int, Column]]
1935419354

1935519355
@_try_remote_functions
1935619356
def hll_union_agg(
19357-
col: "ColumnOrName", allowDifferentLgConfigK: Optional[Union[bool, Column]] = None
19357+
col: "ColumnOrName",
19358+
allowDifferentLgConfigK: Optional[Union[bool, Column]] = None,
1935819359
) -> Column:
1935919360
"""
1936019361
Aggregate function: returns the updatable binary representation of the Datasketches
@@ -19366,8 +19367,8 @@ def hll_union_agg(
1936619367

1936719368
Parameters
1936819369
----------
19369-
col : :class:`~pyspark.sql.Column` or str or bool
19370-
allowDifferentLgConfigK : bool, optional
19370+
col : :class:`~pyspark.sql.Column` or str
19371+
allowDifferentLgConfigK : :class:`~pyspark.sql.Column` or bool, optional
1937119372
Allow sketches with different lgConfigK values to be merged (defaults to false).
1937219373

1937319374
Returns
@@ -19412,12 +19413,7 @@ def hll_union_agg(
1941219413
if allowDifferentLgConfigK is None:
1941319414
return _invoke_function_over_columns("hll_union_agg", col)
1941419415
else:
19415-
_allowDifferentLgConfigK = (
19416-
lit(allowDifferentLgConfigK)
19417-
if isinstance(allowDifferentLgConfigK, bool)
19418-
else allowDifferentLgConfigK
19419-
)
19420-
return _invoke_function_over_columns("hll_union_agg", col, _allowDifferentLgConfigK)
19416+
return _invoke_function_over_columns("hll_union_agg", col, lit(allowDifferentLgConfigK))
1942119417

1942219418

1942319419
@_try_remote_functions

0 commit comments

Comments
 (0)