Skip to content

Commit

Permalink
Bug fix: Reads no longer fail after dropping a fixed attribute and ad…
Browse files Browse the repository at this point in the history
…ding it back as var-sized.
  • Loading branch information
bekadavis9 committed Oct 1, 2024
1 parent 6b20735 commit 47adf4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion test/src/unit-cppapi-schema-evolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ TEST_CASE(

TEST_CASE(
"C++ API: SchemaEvolution, drop fixed attribute and add back as var-sized",
"[!mayfail][cppapi][schema][evolution][add][drop]") {
"[cppapi][schema][evolution][add][drop]") {
test::VFSTestSetup vfs_test_setup;
Context ctx{vfs_test_setup.ctx()};
auto array_uri{
Expand Down
16 changes: 15 additions & 1 deletion tiledb/sm/query/readers/reader_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ bool ReaderBase::skip_field(
return true;
}

// If an attribute exists but has changed from fixed->var or var->fixed after
// schema evolution, ignore for this fragment's tile offsets
if ((array_schema_.var_size(name) && !schema->var_size(name)) ||
(!array_schema_.var_size(name) && schema->var_size(name))) {
return true;
}

// If the fragment doesn't include timestamps
if (timestamps_not_present(name, frag_idx)) {
return true;
Expand Down Expand Up @@ -1135,7 +1142,14 @@ uint64_t ReaderBase::get_attribute_tile_size(

tile_size += fragment_metadata_[f]->tile_size(name, t);

if (array_schema_.var_size(name)) {
/**
* Note: There is a distinct case in which a schema may evolve from
* fixed-sized to var-sized. In this scenario, the LoadedFragmentMetadata
* contains fixed tiles. The tile_var_size should be calculated iff
* both the current _and_ loaded attributes are var-sized.
*/
if (array_schema_.var_size(name) &&
fragment_metadata_[f]->array_schema()->var_size(name)) {
tile_size +=
fragment_metadata_[f]->loaded_metadata()->tile_var_size(name, t);
}
Expand Down

0 comments on commit 47adf4d

Please sign in to comment.