xinrong-databricks commented on a change in pull request #34130:
URL: https://github.com/apache/spark/pull/34130#discussion_r718936626
##########
File path: python/pyspark/sql/functions.py
##########
@@ -2770,11 +2870,16 @@ def instr(str, substr):
>>> df.select(instr(df.s, 'b').alias('s')).collect()
[Row(s=2)]
"""
- sc = SparkContext._active_spark_context
+ sc = SparkContext._active_spark_context # type: ignore[attr-defined]
return Column(sc._jvm.functions.instr(_to_java_column(str), substr))
-def overlay(src, replace, pos, len=-1):
+def overlay(
+ src: "ColumnOrName",
+ replace: "ColumnOrName",
+ pos: Union[Column, int],
+ len: Union[Column, int] = 1,
Review comment:
Thanks for catching that!
##########
File path: python/pyspark/sql/functions.py
##########
@@ -4450,7 +4573,7 @@ def _unresolved_named_lambda_variable(*name_parts):
)
-def _get_lambda_parameters(f):
+def _get_lambda_parameters(f: Callable) -> Any:
Review comment:
Updated to `ValuesView`
##########
File path: python/pyspark/sql/functions.py
##########
@@ -80,13 +96,13 @@ def _invoke_binary_math_function(name, col1, col2):
)
-def _options_to_str(options=None):
+def _options_to_str(options: Optional[Any] = None) -> dict:
Review comment:
Sounds good!
##########
File path: python/pyspark/sql/functions.py
##########
@@ -1586,15 +1651,25 @@ def when(condition, value):
>>> df.select(when(df.age == 2, df.age + 1).alias("age")).collect()
[Row(age=3), Row(age=None)]
"""
- sc = SparkContext._active_spark_context
+ sc = SparkContext._active_spark_context # type: ignore[attr-defined]
if not isinstance(condition, Column):
raise TypeError("condition should be a Column")
v = value._jc if isinstance(value, Column) else value
jc = sc._jvm.functions.when(condition._jc, v)
return Column(jc)
-def log(arg1, arg2=None):
+@overload # type: ignore[no-redef]
Review comment:
I am afraid so, otherwise we will hit
```
python/pyspark/sql/functions.py:1673: error: Name "log" already defined on
line 479
Found 1 error in 1 file (checked 315 source files)
```
--
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]