Skip to content

fix: handle empty tables in get_add_actions()#3922

Merged
rtyler merged 3 commits intodelta-io:mainfrom
vsmanish1772:fix/get-add-actions-empty-table-3918
Nov 15, 2025
Merged

fix: handle empty tables in get_add_actions()#3922
rtyler merged 3 commits intodelta-io:mainfrom
vsmanish1772:fix/get-add-actions-empty-table-3918

Conversation

@vsmanish1772
Copy link
Copy Markdown
Contributor

@vsmanish1772 vsmanish1772 commented Nov 6, 2025

Description

This PR fixes a panic that occurs when get_add_actions() is called on a Delta table that has no add actions (i.e., no data files).

Problem

When calling get_add_actions() on a table with no files, the function panics with:

index out of bounds: the len is 0 but the index is 0

This happens because the code attempts to access results[0] without checking if the results vector is empty.

Solution

  • Added early return check for empty files before creating the evaluator
  • When files are empty, create an empty RecordBatch with the correct schema
  • This matches the behavior from version 1.1.4 where empty tables were handled gracefully

Changes

  • Check if files are empty before processing
  • Return empty RecordBatch with correct schema when no files exist

Testing

  • Added unit test that covers the empty table scenario
  • Test verifies both flattened and non-flattened schemas

Fixes #3918

@github-actions github-actions bot added binding/python Issues for the Python package binding/rust Issues for the Rust crate labels Nov 6, 2025
@github-actions
Copy link
Copy Markdown

github-actions bot commented Nov 6, 2025

ACTION NEEDED

delta-rs follows the Conventional Commits specification for release automation.

The PR title and description are used as the merge commit message. Please update your PR title and description to match the specification.

@vsmanish1772 vsmanish1772 changed the title Fix: Handle empty tables in get_add_actions() fix: Handle empty tables in get_add_actions() Nov 6, 2025
@vsmanish1772 vsmanish1772 force-pushed the fix/get-add-actions-empty-table-3918 branch from f723817 to 01e5e8e Compare November 6, 2025 19:43
@vsmanish1772 vsmanish1772 changed the title fix: Handle empty tables in get_add_actions() fix: handle empty tables in get_add_actions() Nov 6, 2025
@codecov
Copy link
Copy Markdown

codecov bot commented Nov 9, 2025

Codecov Report

❌ Patch coverage is 69.23077% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.17%. Comparing base (5575ad1) to head (c5a285f).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
crates/core/src/table/state.rs 69.23% 4 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3922      +/-   ##
==========================================
- Coverage   74.19%   74.17%   -0.02%     
==========================================
  Files         152      152              
  Lines       39552    39554       +2     
  Branches    39552    39554       +2     
==========================================
- Hits        29346    29340       -6     
- Misses       8879     8885       +6     
- Partials     1327     1329       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vsmanish1772 vsmanish1772 force-pushed the fix/get-add-actions-empty-table-3918 branch from 4572dc7 to 5dffd72 Compare November 9, 2025 10:10
@vsmanish1772
Copy link
Copy Markdown
Contributor Author

can someone look into this please? The build complains about formatting but locally it doesnt throw that error

@rtyler
Copy link
Copy Markdown
Member

rtyler commented Nov 15, 2025

@vsmanish1772 what version of Rust are you building with? CI runs with 1.91 or whatever is stable, but I see the issues with 1.90 as well

Manish Sogiyawar added 2 commits November 15, 2025 14:43
- Fix panic when get_add_actions() is called on tables with no add actions
- Return empty RecordBatch with correct schema instead of panicking
- Add unit test to verify get_add_actions() works after delete and vacuum

Fixes delta-io#3918

Signed-off-by: Manish Sogiyawar <msogiyawar@vectra.ai>
Signed-off-by: Manish Sogiyawar <msogiyawar@vectra.ai>
@vsmanish1772
Copy link
Copy Markdown
Contributor Author

@vsmanish1772 what version of Rust are you building with? CI runs with 1.91 or whatever is stable, but I see the issues with 1.90 as well

@rtyler I'm using rustc 1.91.0 (f8297e351 2025-10-28)

@rtyler rtyler force-pushed the fix/get-add-actions-empty-table-3918 branch from 3680d0d to 765ba81 Compare November 15, 2025 14:46
@rtyler rtyler enabled auto-merge (rebase) November 15, 2025 15:00
See delta-io#3918

Signed-off-by: R. Tyler Croy <rtyler@brokenco.de>
@rtyler rtyler force-pushed the fix/get-add-actions-empty-table-3918 branch from 8d1eae8 to c5a285f Compare November 15, 2025 15:00
@rtyler rtyler merged commit 84d954a into delta-io:main Nov 15, 2025
28 of 29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

binding/python Issues for the Python package binding/rust Issues for the Rust crate

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[Bug]: get_add_actions() panics with "index out of bounds" when table has no data files

3 participants