-
Notifications
You must be signed in to change notification settings - Fork 28.3k
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-49552][PYTHON] Add DataFrame API support for new 'randstr' and 'uniform' SQL functions #48143
[SPARK-49552][PYTHON] Add DataFrame API support for new 'randstr' and 'uniform' SQL functions #48143
Changes from 22 commits
d9223e5
c0a2551
f6ffde0
c22fef2
c78d8f0
5b6194e
da390f9
836ec8e
4b41b34
54a1a2e
c372075
515b046
3504124
0683318
7ec25a8
1f5e866
8b64f33
0313fbe
d54eec7
48f1dde
f496e86
160a5f4
795f5a6
6bb123f
05a674c
fd3262f
4929fbd
ef7f9e7
d95a391
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -1008,6 +1008,22 @@ def unhex(col: "ColumnOrName") -> Column: | |||||
unhex.__doc__ = pysparkfuncs.unhex.__doc__ | ||||||
|
||||||
|
||||||
def uniform( | ||||||
min: Union[Column, int, float], | ||||||
max: Union[Column, int, float], | ||||||
seed: Optional[Union[Column, int]] = None, | ||||||
) -> Column: | ||||||
if seed is None: | ||||||
return _invoke_function_over_columns( | ||||||
"uniform", min, max, lit(random.randint(0, sys.maxsize)) | ||||||
) | ||||||
else: | ||||||
return _invoke_function_over_columns("uniform", min, max, seed) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this is done. |
||||||
|
||||||
|
||||||
uniform.__doc__ = pysparkfuncs.uniform.__doc__ | ||||||
|
||||||
|
||||||
def approxCountDistinct(col: "ColumnOrName", rsd: Optional[float] = None) -> Column: | ||||||
warnings.warn("Deprecated in 3.4, use approx_count_distinct instead.", FutureWarning) | ||||||
return approx_count_distinct(col, rsd) | ||||||
|
@@ -2578,6 +2594,16 @@ def regexp_like(str: "ColumnOrName", regexp: "ColumnOrName") -> Column: | |||||
regexp_like.__doc__ = pysparkfuncs.regexp_like.__doc__ | ||||||
|
||||||
|
||||||
def randstr(length: Union[Column, int], seed: Optional[Union[Column, int]] = None) -> Column: | ||||||
if seed is None: | ||||||
return _invoke_function_over_columns("randstr", length, lit(random.randint(0, sys.maxsize))) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this is done. |
||||||
else: | ||||||
return _invoke_function_over_columns("randstr", length, seed) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, this is done. |
||||||
|
||||||
|
||||||
randstr.__doc__ = pysparkfuncs.randstr.__doc__ | ||||||
|
||||||
|
||||||
def regexp_count(str: "ColumnOrName", regexp: "ColumnOrName") -> Column: | ||||||
return _invoke_function_over_columns("regexp_count", str, regexp) | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_invoke_function_over_columns
requires arguments be columns or column namesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is done.