[BUG] `cast_variant` skips unsupported target type validation for empty inputs
- Dominant language
- C++
- Stars
- 9.8k
- Forks
- 1.1k
- Avg merge
- 3d 6m
- Merged PRs (30d)
- 278
Description
**Describe the bug**
`cudf::io::parquet::experimental::cast_variant` appears to bypass validation of unsupported `desired_type` values when the input `list` column is empty.
The public API docs for `cast_variant` say that `desired_type` must be one of `STRING` or `INT8`/`INT16`/`INT32`/`INT64`, and that unsupported target types should throw `std::invalid_argument`.
However, the implementation currently returns early for empty inputs:
```cpp
if (num_rows == 0) { return make_empty_column(desired_type); }
```
This happens before dispatch reaches the unsupported-type path, so a call such as:
```cpp
cast_variant(empty_list_uint8, cudf::data_type{cudf::type_id::FLOAT64})
```
can succeed and return an empty FLOAT64 column, even though FLOAT64 is not a supported target type for variant casting.
**Expected Behavior**
cast_variant should reject unsupported desired_type values consistently, regardless of whether the input column is empty or non-empty. Supported empty casts, such as empty variant values to INT32 or STRING, should continue to return valid empty output columns.
**Additional Context**
This came up during review discussion on PR https://github.com/rapidsai/cudf/pull/23036. The current behavior looks like a real test gap and may require moving or adding target-type validation before the empty-input fast path.
Contributor guide
Assessment
This issue has not been assessed yet.