Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[c++] Corner-case bug in extend-enumeration logic #2897

Merged
merged 4 commits into from
Aug 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions apis/python/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -1642,10 +1642,7 @@ def test_timestamped_schema_evolve(tmp_path):
atbl = pa.Table.from_pydict(
{
"soma_joinid": [3, 4],
"myenum": pd.Series(["b", "c"], dtype="category"),
# TODO https://github.com/single-cell-data/TileDB-SOMA/issues/2896
# "myenum": pd.Series(['b', 'b'], dtype='category'),
# Perhaps leave this t=3 as-is, and add a write of ['c', 'c'] at t=4.
"myenum": pd.Series(["b", "b"], dtype="category"),
}
)
with soma.DataFrame.open(uri, "w", tiledb_timestamp=3) as sdf:
Expand All @@ -1661,8 +1658,8 @@ def test_timestamped_schema_evolve(tmp_path):

with soma.DataFrame.open(uri, tiledb_timestamp=3) as sdf:
table = sdf.read().concat()
assert table["myenum"].to_pylist() == ["a", "b", "a", "b", "c"]
assert table["myenum"].to_pylist() == ["a", "b", "a", "b", "b"]

with soma.DataFrame.open(uri) as sdf:
table = sdf.read().concat()
assert table["myenum"].to_pylist() == ["a", "b", "a", "b", "c"]
assert table["myenum"].to_pylist() == ["a", "b", "a", "b", "b"]
11 changes: 11 additions & 0 deletions libtiledbsoma/src/soma/soma_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,17 @@ bool SOMAArray::_extend_and_evolve_schema_str(
index_schema->format = ArrowAdapter::to_arrow_format(disk_index_type)
.data();
return true;
} else {
// Example:
//
// * Already on storage/schema there are values a,b,c with indices
// 0,1,2.
// * User appends values b,c which, within the Arrow data coming in
// from the user, have indices 0,1.
// * We need to remap those to 1,2.

SOMAArray::_remap_indexes(
column_name, enmr, enums_in_write, index_schema, index_array);
}
return false;
}
Expand Down
Loading