Skip to content

Support zero-column operands in cross_join - #23235

Merged
rapids-bot[bot] merged 4 commits into
NVIDIA:mainfrom
madsbk:cross-join-zero-column
Jul 17, 2026
Merged

Support zero-column operands in cross_join#23235
rapids-bot[bot] merged 4 commits into
NVIDIA:mainfrom
madsbk:cross-join-zero-column

Conversation

@madsbk

@madsbk madsbk commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Description

Previously, cross_join threw "Left table is empty" or "Right table is empty" when either operand had zero columns. Zero-column operands with non-zero row counts are now valid. The result has left.num_rows() * right.num_rows() rows and left.num_columns() + right.num_columns() columns.

@madsbk madsbk self-assigned this Jul 13, 2026
@madsbk madsbk added improvement Improvement / enhancement to an existing function breaking Breaking change labels Jul 13, 2026
@github-actions github-actions Bot added libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API. labels Jul 13, 2026
@GPUtester GPUtester moved this to In Progress in cuDF Python Jul 13, 2026
@madsbk
madsbk marked this pull request as ready for review July 14, 2026 07:10
@madsbk
madsbk requested review from a team as code owners July 14, 2026 07:10
@madsbk
madsbk requested review from bdice, mhaseeb123 and mroeschke July 14, 2026 07:10
@NVIDIA NVIDIA deleted a comment from copy-pr-bot Bot Jul 14, 2026
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 87f1899c-8078-4b42-953c-c28fcca20725

📥 Commits

Reviewing files that changed from the base of the PR and between 428daff and a2dfdaa.

📒 Files selected for processing (3)
  • cpp/include/cudf/join/join.hpp
  • python/cudf/cudf/core/join/join.py
  • python/cudf/cudf/tests/reshape/test_merge.py
🚧 Files skipped from review as they are similar to previous changes (3)
  • python/cudf/cudf/core/join/join.py
  • cpp/include/cudf/join/join.hpp
  • python/cudf/cudf/tests/reshape/test_merge.py

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Cross joins now document and properly handle zero-column inputs, preserving the expected rows = left_rows × right_rows and combined column count.
    • Cross joins now detect row-count overflow and raise std::overflow_error when the computed result size exceeds supported limits.
    • Cross merges (how="cross") now retain correct row expansion for column-less operands, matching pandas behavior.
  • Tests
    • Expanded cross-join and cross-merge test coverage for zero-column and overflow scenarios.
  • Documentation
    • Updated cross_join API docs to reflect the exact output shape and overflow conditions.

Walkthrough

Cross joins now support zero-column operands while preserving the product of input row counts. Native code validates output-size overflow and passes explicit row counts to table construction. Python cross merges preserve row counts through an explicit index.

Changes

Cross Join Zero-Column Support

Layer / File(s) Summary
Native cross-join row-count handling
cpp/include/cudf/join/join.hpp, cpp/src/join/cross_join.cu, cpp/tests/join/cross_join_tests.cpp
Documents cross-join output dimensions, permits zero-column inputs, checks row-count overflow, constructs explicit-sized outputs, and tests row-count preservation.
Python cross-merge row preservation
python/cudf/cudf/core/join/join.py, python/cudf/cudf/tests/reshape/test_merge.py
Passes explicit operand row counts to libcudf, restores the index for zero-column results, and compares cross-merge results with pandas.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

  • rapidsai/cudf#22765: Adds related support for preserving and transporting row counts in zero-column tables.

Suggested labels: bug

Suggested reviewers: bdice, mhaseeb123

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: allowing zero-column operands in cross_join.
Description check ✅ Passed The description matches the changeset and explains the new zero-column cross_join behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

coderabbitai[bot]

This comment was marked as resolved.

Comment thread python/cudf/cudf/core/join/join.py

@PointKernel PointKernel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

C++ changes look good to me

@mhaseeb123 mhaseeb123 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.

Approving C++. Thanks for the contribution

@madsbk

madsbk commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

/merge

@rapids-bot
rapids-bot Bot merged commit 737fecb into NVIDIA:main Jul 17, 2026
138 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in cuDF Python Jul 17, 2026
@madsbk
madsbk deleted the cross-join-zero-column branch July 17, 2026 06:59
rapids-bot Bot pushed a commit that referenced this pull request Jul 20, 2026
#23340)

If a cudf-polars query raises an exception during execution, it is possible that it can leave a dangling collective that then tears down one process.

This is racy because it depends on tasks being cancelled in Python and then dropping C++ objects in a particular order.

The one test in the cudf-polars tests suite that could do this is fixed on main, so backport the relevant changes (#23235), and un-xfail the test.

Authors:
  - Lawrence Mitchell (https://github.com/wence-)
  - Mads R. B. Kristensen (https://github.com/madsbk)

Approvers:
  - Richard (Rick) Zamora (https://github.com/rjzamora)
  - Matthew Murray (https://github.com/Matt711)
  - Bradley Dice (https://github.com/bdice)
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: #23340
davidwendt pushed a commit to wjxiz1992/cudf that referenced this pull request Jul 21, 2026
NVIDIA#23340)

If a cudf-polars query raises an exception during execution, it is possible that it can leave a dangling collective that then tears down one process.

This is racy because it depends on tasks being cancelled in Python and then dropping C++ objects in a particular order.

The one test in the cudf-polars tests suite that could do this is fixed on main, so backport the relevant changes (NVIDIA#23235), and un-xfail the test.

Authors:
  - Lawrence Mitchell (https://github.com/wence-)
  - Mads R. B. Kristensen (https://github.com/madsbk)

Approvers:
  - Richard (Rick) Zamora (https://github.com/rjzamora)
  - Matthew Murray (https://github.com/Matt711)
  - Bradley Dice (https://github.com/bdice)
  - Vyas Ramasubramani (https://github.com/vyasr)

URL: NVIDIA#23340
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking Breaking change improvement Improvement / enhancement to an existing function libcudf Affects libcudf (C++/CUDA) code. Python Affects Python cuDF API.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants