holdenk commented on code in PR #59978:
URL: https://github.com/apache/spark/pull/59978#discussion_r4580820294
##########
python/pyspark/sql/udf.py:
##########
@@ -329,6 +331,15 @@ def _conf_is_true(key: str, default: Optional[str] = None)
-> bool:
self._transpiled_param_names = []
self._transpiled_input_categories = []
self._positional_only_param_names = frozenset()
+ if guarded_constructs:
+ constructs = " and ".join(guarded_constructs)
+ warnings.warn(
+ f"Python UDF {func}: its transpiled form includes NULL guards
for "
+ f"{constructs}. They raise when the transpiled form runs on
NULL "
Review Comment:
Not changing this on the backport. Master has the same over-claim in its
version of the advisory: the `UserWarning` that #59108 added in `transpile.py`
fires whenever any guard is emitted. On upstream/master, `def f(s): return
len(s) > 3 if s else False` warns that the UDF has a NULL guard that "raises at
runtime when a NULL input is encountered" and tells the user to add an `if x is
not None` guard, although the `if s` test already keeps NULL away from it (I
ran it to check).
The rewording should land on master first and then be backported, so I am
leaving this thread open.
---
<sub>🤖 Posted by an AI agent (Claude Code · skill `none`) on behalf of
@holdenk.</sub>
<!-- agent-attribution v1: agent=claude-code; skill=none; operator=holdenk
-->
--
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]