NVIDIA / NVIDIA/cudf

[BUG] AST Limitation: Unable to Handle Single String Literal Expressions

Open
#14,324 1 comment 0 reactions 0 assignees View on GitHub
0 - Backlog bug libcudf Python
Dominant language
C++
Stars
9.8k
Forks
1.1k
Avg merge
3d 6m
Merged PRs (30d)
278

Description

**Describe the bug**

The AST evaluator currently encounters a limitation where it is unable to handle an expression consisting of just one string literal, this is not a problem with other data types. While this scenario may be considered an edge case, it would be nice to address it for consistency with how other libraries, such as Pandas, handle similar situations.

```
df.eval(" 'alex' ")
Traceback (most recent call last):
File "", line 1, in
File "/home/alexander/envs/cudf_dev/lib/python3.10/site-packages/nvtx/nvtx.py", line 101, in inner
result = func(*args, **kwargs)
File "/home/alexander/envs/cudf_dev/lib/python3.10/site-packages/cudf/core/dataframe.py", line 7065, in eval
None: libcudf.transform.compute_column(
File "/home/alexander/envs/cudf_dev/lib/python3.10/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "transform.pyx", line 196, in cudf._lib.transform.compute_column
RuntimeError: CUDF failure at: /opt/mambaforge/conda-bld/libcudf-ext_1692118605400/work/cpp/src/column/column_factories.cpp:161: Invalid, non-fixed-width type.

```
**Steps/Code to reproduce bug**
```
import cudf
df = cudf.DataFrame({'A': [], 'B': []})
df.eval(" 'alex' ")
```

`RuntimeError: CUDF failure at: /opt/mambaforge/conda-bld/libcudf-ext_1692118605400/work/cpp/src/column/column_factories.cpp:161: Invalid, non-fixed-width type.`

**Expected behavior**

For a similar example but with other data types.

```
import cudf
df = cudf.DataFrame({'A': [], 'B': []})
df.eval(" 123 ")
```

**Environment overview (please complete the following information)**
- Environment location: conda
- Method of cuDF install: conda
- branch-23.10, origin/branch-23.10

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.