Skip to content
Open
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
14 changes: 8 additions & 6 deletions python/pyspark/sql/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# limitations under the License.
#

# mypy: disable-error-code="empty-body"

import sys

from typing import Callable, List, Optional, TYPE_CHECKING, overload, Dict, Union, cast, Tuple
Expand Down Expand Up @@ -189,7 +191,7 @@ def agg(self, *exprs: Union[Column, Dict[str, str]]) -> "DataFrame":
return DataFrame(jdf, self.session)

@dfapi
def count(self) -> "DataFrame": # type: ignore[empty-body]
def count(self) -> "DataFrame":
"""Counts the number of records for each group.

.. versionadded:: 1.3.0
Expand Down Expand Up @@ -223,7 +225,7 @@ def count(self) -> "DataFrame": # type: ignore[empty-body]
"""

@df_varargs_api
def mean(self, *cols: str) -> DataFrame: # type: ignore[empty-body]
def mean(self, *cols: str) -> DataFrame:
"""Computes average values for each numeric columns for each group.

:func:`mean` is an alias for :func:`avg`.
Expand All @@ -240,7 +242,7 @@ def mean(self, *cols: str) -> DataFrame: # type: ignore[empty-body]
"""

@df_varargs_api
def avg(self, *cols: str) -> "DataFrame": # type: ignore[empty-body]
def avg(self, *cols: str) -> "DataFrame":
"""Computes average values for each numeric columns for each group.

:func:`mean` is an alias for :func:`avg`.
Expand Down Expand Up @@ -291,7 +293,7 @@ def avg(self, *cols: str) -> "DataFrame": # type: ignore[empty-body]
"""

@df_varargs_api
def max(self, *cols: str) -> "DataFrame": # type: ignore[empty-body]
def max(self, *cols: str) -> "DataFrame":
"""Computes the max value for each numeric columns for each group.

.. versionadded:: 1.3.0
Expand Down Expand Up @@ -335,7 +337,7 @@ def max(self, *cols: str) -> "DataFrame": # type: ignore[empty-body]
"""

@df_varargs_api
def min(self, *cols: str) -> "DataFrame": # type: ignore[empty-body]
def min(self, *cols: str) -> "DataFrame":
"""Computes the min value for each numeric column for each group.

.. versionadded:: 1.3.0
Expand Down Expand Up @@ -384,7 +386,7 @@ def min(self, *cols: str) -> "DataFrame": # type: ignore[empty-body]
"""

@df_varargs_api
def sum(self, *cols: str) -> DataFrame: # type: ignore[empty-body]
def sum(self, *cols: str) -> DataFrame:
"""Computes the sum for each numeric columns for each group.

.. versionadded:: 1.3.0
Expand Down
9 changes: 4 additions & 5 deletions python/pyspark/sql/udf.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,22 +707,21 @@ def register(
"SQL_GROUPED_AGG_PANDAS_ITER_UDF or SQL_GROUPED_AGG_ARROW_ITER_UDF"
},
)
source_udf = _create_udf(
register_udf = UserDefinedFunction(
f.func,
returnType=f.returnType,
name=name,
evalType=f.evalType,
deterministic=f.deterministic,
)
register_udf = source_udf._unwrapped # type: ignore[attr-defined]
return_udf = register_udf
return_udf: "UserDefinedFunctionLike" = register_udf
else:
if returnType is None:
returnType = StringType()
return_udf = _create_udf(
register_udf = UserDefinedFunction(
f, returnType=returnType, evalType=PythonEvalType.SQL_BATCHED_UDF, name=name
)
register_udf = return_udf._unwrapped # type: ignore[attr-defined]
return_udf = register_udf._wrapped()
self.sparkSession._jsparkSession.udf().registerPython(name, register_udf._judf)
return return_udf

Expand Down