[FEA] Properly raise when attempting to cast `NA` to bool inside UDFs
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
**Is your feature request related to a problem? Please describe.**
With the merge of https://github.com/rapidsai/cudf/pull/8213 we have initial support for user defined functions that involve nulls. However the behavior in the following edge case does not match pandas if the input column contains nulls:
```python
def f(x):
if x > 2:
return 3
else:
return 4
```
In cases where `x is cudf.NA`, the first condition will eventually resolve to `if(cudf.NA)`. In the cuDF view, `NA` is treated as falsy for lack of a better solution in the initial implementation, and thus the code will take the first branch and return 3. However in pandas, it will *raise* and go down neither branch, complaining that `The boolean value of NA is ambiguous`. This is probably the correct behavior.
**Describe the solution you'd like**
Make it so that numba returns a non zero exit code from kernels if this situation occurs, and then propagate that error to the user as a python error.
**Describe alternatives you've considered**
Making nulls falsy leads to different results than pandas.
**Additional context**
cc @gmarkall
Contributor guide
Assessment
This issue has not been assessed yet.