Skip to content

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

@vsmanish1772

Description

@vsmanish1772

What happened?

When calling get_add_actions() on a Delta table that has no add actions (i.e., no data files), the function panics with exception: PanicException
exc_value: index out of bounds: the len is 0 but the index is 0

This is a regression from version 1.1.4, where this scenario worked correctly without errors.

Root Cause:
The issue is in crates/core/src/table/state.rs at line 358 in the EagerSnapshot::add_actions_table() function:

let result = concat_batches(results[0].schema_ref(), &results)?;

This code attempts to access results[0] without checking if the results vector is empty. When there are no files in the table, self.files()? returns an empty iterator, resulting in an empty results vector, which causes the index out of bounds panic.

Expected behavior

The function should handle empty tables gracefully and return an empty RecordBatch with the appropriate schema, similar to how it behaved in version 1.1.4.

Binding
Python (also affects Rust)

Bindings Version
Versions after 1.1.4 (current main branch affected)

Steps to reproduce

  1. Create or load a Delta table with no data files (e.g., a newly initialized table or a table where all data has been deleted)
  2. Call get_add_actions() on the table
  3. Observe the panic

Example code:

from deltalake import DeltaTable

# Load a table with no data files
dt = DeltaTable("path/to/empty/table")
dt.get_add_actions()  # This will panic

Expected behavior

The function should handle empty tables gracefully and return an empty RecordBatch with the appropriate schema, similar to how it behaved in version 1.1.4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions