Skip to content

Incorrect physical_rows recorded when migrating from old versions of tables with deletions #1531

Closed

Description

@wjones127

v0.8.0: We started recording the number of physical rows, but implementation used count_rows() to compute this.
v0.7.5 is the version right before that.

How to reproduce

Install pylance 0.7.5

python -m venv .venv
source .venv/bin/activate
pip install pylance==0.7.5
python

Write a table, and delete some rows

import lance
import pyarrow as pa

tab = pa.table({'x': range(100)})
dataset = lance.write_dataset(tab, 'test')
dataset.delete("x >= 10 and x < 20")
dataset.count_rows()
90

Now, install pylance 0.8.0:

pip install pylance==0.8.0
python

Count rows at first is correct. However, once we write to the table, it becomes incorrect:

import lance
import pyarrow as pa

dataset = lance.dataset('test')
dataset.count_rows() # 90

tab = pa.table({'x': range(5)})
dataset = lance.write_dataset(tab, 'test', mode='append')
dataset.count_rows() # 85 
dataset.to_table().num_rows # 95

Activity

  1. added
    bugSomething isn't working
    rustRust related tasks
    on Nov 6, 2023
  2. self-assigned this
    on Nov 6, 2023
  3. wjones127 commented on Nov 7, 2023

    @wjones127
    ContributorAuthor

    If I rerun the repro using the latest version of Lance instead of v0.8.0 we will also experience data loss:

    >>> import lance
    >>> import pyarrow as pa
    >>>
    >>> dataset = lance.dataset('test')
    >>> dataset.count_rows() 
    90
    >>>
    >>> tab = pa.table({'x': range(5)})
    >>> dataset = lance.write_dataset(tab, 'test', mode='append')
    >>> dataset.count_rows() 
    80
    >>> dataset.to_table().num_rows
    90

    This seems to be because we pass the dataset fragments and not the new to-be-committed fragments here:

    https://github.com/lancedb/lance/blob/dc83011078a4e966d5eae908af3ab982f4638e48/rust/lance/src/io/commit.rs#L170

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingrustRust related tasks

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions