Skip to content

Commit

Permalink
Update test to read original attribute data after schema evolution.
Browse files Browse the repository at this point in the history
  • Loading branch information
bekadavis9 committed Oct 1, 2024
1 parent 47adf4d commit c4a4d76
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions test/src/unit-cppapi-schema-evolution.cc
Original file line number Diff line number Diff line change
Expand Up @@ -850,6 +850,8 @@ TEST_CASE(
}
query_w.submit_and_finalize();
array_w.close();
uint64_t fragment_write_ts = tiledb_timestamp_now_ms() + 1;
std::this_thread::sleep_for(std::chrono::milliseconds(100));

// Evolve schema to drop attribute "a"
ArraySchemaEvolution schema_evolution = ArraySchemaEvolution(ctx);
Expand All @@ -868,17 +870,35 @@ TEST_CASE(

// Read the array
std::string buffer;
std::vector<uint64_t> offsets = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
std::vector<uint64_t> offsets(10);
Array array_r(ctx, array_uri, TILEDB_READ);
Subarray subarray(ctx, array_r);
subarray.add_range(0, 1, 10);
Subarray subarray_r(ctx, array_r);
subarray_r.add_range(0, 1, 10);
Query query_r(ctx, array_r, TILEDB_READ);
query_r.set_layout(layout)
.set_subarray(subarray)
.set_subarray(subarray_r)
.set_data_buffer("a", buffer)
.set_offsets_buffer("a", offsets);
query_r.submit();
array_r.close();

// Read the original array
std::vector<int> a_data(10);
array_r.open(TILEDB_READ, fragment_write_ts);
Subarray subarray_r2(ctx, array_r);
subarray_r2.add_range(0, 1, 10);
Query query_r2(ctx, array_r, TILEDB_READ);
query_r2.set_layout(layout)
.set_subarray(subarray_r2)
.set_data_buffer("a", a_data);
query_r2.submit();
array_r.close();
auto result_num = (int)query_r2.result_buffer_elements()["a"].second;
CHECK(result_num == 10);
a_data.resize(result_num);
CHECK_THAT(
a_data,
Catch::Matchers::Equals(std::vector<int>{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}));
}

TEST_CASE(
Expand Down

0 comments on commit c4a4d76

Please sign in to comment.