Skip to content

cast_variant skips unsupported target type validation for empty inputs - #23462

Merged
rapids-bot[bot] merged 17 commits into
NVIDIA:mainfrom
abigalekim:ak/cast-variant-bugfix
Aug 6, 2026
Merged

cast_variant skips unsupported target type validation for empty inputs#23462
rapids-bot[bot] merged 17 commits into
NVIDIA:mainfrom
abigalekim:ak/cast-variant-bugfix

Conversation

@abigalekim

@abigalekim abigalekim commented Jul 28, 2026

Copy link
Copy Markdown
Contributor

Description

Solves the issue mentioned in #23361. cast_variant now rejects 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, continue to return empty columns. This PR also refactors the UnsupportedTypesThrows test, which now covers both the empty-input (early-return) path and the non-empty-input (dispatch) path.

Checklist

  • I am familiar with the Contributing Guidelines.
  • New or existing tests cover these changes.
  • The documentation is up to date with these changes.

@abigalekim
abigalekim requested a review from a team as a code owner July 28, 2026 16:20
@copy-pr-bot

copy-pr-bot Bot commented Jul 28, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@github-actions github-actions Bot added the libcudf Affects libcudf (C++/CUDA) code. label Jul 28, 2026
@abigalekim abigalekim added bug Something isn't working non-breaking Non-breaking change labels Jul 28, 2026
@abigalekim
abigalekim requested a review from vuule July 28, 2026 16:20
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved validation for unsupported variant cast target types with explicit early rejection.
    • Unsupported casts now consistently throw std::invalid_argument for both empty and non-empty inputs.
  • Tests
    • Updated and expanded unit tests to verify std::invalid_argument is thrown for every unsupported type_id, separately for empty and non-empty inputs, with clearer failure messages.

Walkthrough

cast_variant now validates requested target types before casting, and tests confirm unsupported types throw for both empty and non-empty inputs.

Changes

VARIANT cast validation

Layer / File(s) Summary
Early target-type validation
cpp/src/io/parquet/experimental/variant_extract.cu
Validates supported variant cast output types before dispatch and throws std::invalid_argument for unsupported types.
Unsupported target coverage
cpp/tests/io/experimental/variant_extract_test.cpp
Tests unsupported target types with empty and non-empty inputs and adds the required <bit> include.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • rapidsai/cudf#23361 — Covers validating desired_type before empty-input handling bypasses unsupported-type validation.

Possibly related PRs

Suggested labels: bug, libcudf, non-breaking

Suggested reviewers: vuule, mhaseeb123, mythrocks

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the fix for unsupported target type validation when inputs are empty.
Description check ✅ Passed The description explains the validation fix and the test coverage for empty and non-empty inputs.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Comment @coderabbitai help to get the list of available commands.

Comment thread cpp/tests/io/experimental/variant_extract_test.cpp Outdated
@abigalekim

Copy link
Copy Markdown
Contributor Author

/ok to test c1e0e9d

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
cpp/tests/io/experimental/variant_extract_test.cpp (1)

387-463: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add <bit> for std::bit_cast cpp/tests/io/experimental/variant_extract_test.cpp uses std::bit_cast in enc_float64 but doesn’t include <bit>, so compilation depends on an indirect include.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@cpp/tests/io/experimental/variant_extract_test.cpp` around lines 387 - 463,
Update the includes in variant_extract_test.cpp to directly include the standard
<bit> header required by std::bit_cast in enc_float64, removing the dependency
on indirect includes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@cpp/tests/io/experimental/variant_extract_test.cpp`:
- Around line 387-463: Update the includes in variant_extract_test.cpp to
directly include the standard <bit> header required by std::bit_cast in
enc_float64, removing the dependency on indirect includes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: f0be71af-e328-4b13-a3c0-b417c204c187

📥 Commits

Reviewing files that changed from the base of the PR and between c1e0e9d and 1cd9b98.

📒 Files selected for processing (2)
  • cpp/src/io/parquet/experimental/variant_extract.cu
  • cpp/tests/io/experimental/variant_extract_test.cpp
🚧 Files skipped from review as they are similar to previous changes (1)
  • cpp/src/io/parquet/experimental/variant_extract.cu

@abigalekim

Copy link
Copy Markdown
Contributor Author

/ok to test b0d37be

rmm::device_async_resource_ref mr)
{
validate_variant_child(values);
cudf::type_dispatcher(desired_type, validate_variant_type_fn{});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can get rid of the type dispatcher here. It's generally quite expensive and the functor being dispatch seems trivial enough.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I have refactored it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the comment only referred to validate_variant_type_fn, not the entire cast. I'm not sure that we want all casting in a single function.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have re-refactored it to address this comment!

@vuule vuule left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few small comments

Comment thread cpp/tests/io/experimental/variant_extract_test.cpp Outdated
Comment thread cpp/tests/io/experimental/variant_extract_test.cpp Outdated
@abigalekim

Copy link
Copy Markdown
Contributor Author

/ok to test df6e561

@abigalekim
abigalekim requested review from mhaseeb123 and vuule July 30, 2026 22:51
@mhaseeb123

mhaseeb123 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Hi @abigalekim, please update the PR description to say what exactly we are doing here instead of just linking the issue 🙂. Please don't include the problem statement in the description, just what the PR exactly does and what does it fix in maybe a small 3-4 line paragraph

Comment thread cpp/src/io/parquet/experimental/variant_extract.cu Outdated
Comment thread cpp/src/io/parquet/experimental/variant_extract.cu Outdated
Comment thread cpp/src/io/parquet/experimental/variant_extract.cu Outdated
Comment thread cpp/tests/io/experimental/variant_extract_test.cpp Outdated
}

// Non-empty input: the dispatch path must also throw for unsupported types.
auto col = make_apache_variant(avf::primitive_int32);

@mhaseeb123 mhaseeb123 Aug 4, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚁🚁🚁 (iykyk 😄)

Comment thread cpp/tests/io/experimental/variant_extract_test.cpp Outdated
@abigalekim
abigalekim requested a review from mhaseeb123 August 5, 2026 00:55
@abigalekim

Copy link
Copy Markdown
Contributor Author

I have added the PR description as well!

@abigalekim

Copy link
Copy Markdown
Contributor Author

/ok to test 704c9bd

@abigalekim

Copy link
Copy Markdown
Contributor Author

/ok to test 480db43

@abigalekim

Copy link
Copy Markdown
Contributor Author

/ok to test b35620a

@abigalekim

Copy link
Copy Markdown
Contributor Author

/ok to test 047d5bb

@vuule

vuule commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

/merge

@rapids-bot
rapids-bot Bot merged commit 8bf8473 into NVIDIA:main Aug 6, 2026
140 checks passed
@abigalekim
abigalekim deleted the ak/cast-variant-bugfix branch August 6, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working libcudf Affects libcudf (C++/CUDA) code. non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants