bzhaoopenstack opened a new pull request, #37367:
URL: https://github.com/apache/spark/pull/37367
window and min_periods parameters is not be validated in rolling function.
### What changes were proposed in this pull request?
Validate the said 2 parameters to be a integer only in rolling func, will
raise ValueError if they are not Integer
### Why are the changes needed?
I guess we miss the validation towards those parameters.
PySpark will raise Error during using other type inputs
```
>>> s = ps.Series([4, 3, 5, 2, 6])
>>> s.rolling(1).sum()
0 4
1 3
2 5
3 2
4 6
dtype: int64
>>> s.rolling('STRING').sum()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/spark/spark/python/pyspark/pandas/generic.py", line 2707, in
rolling
return Rolling(self, window=window, min_periods=min_periods)
File "/home/spark/spark/python/pyspark/pandas/window.py", line 179, in
__init__
super().__init__(window, min_periods)
File "/home/spark/spark/python/pyspark/pandas/window.py", line 147, in
__init__
if window < 0:
TypeError: '<' not supported between instances of 'str' and 'int'
>>>
```
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
Input other types of window and min_periods in rolling func will raise
ValueError
--
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]