Skip to content

Commit

Permalink
Unordered tile/cell order is now rejected when creating an ArraySchema (
Browse files Browse the repository at this point in the history
#4973)

This PR disables the ability to create an Array Schema with UNORDERED
tile/cell order. + Tests (C/C++).

[sc-47276]

---
TYPE: BUG
DESC: Rejecting unordered tile/cell order when creating an ArraySchema.
  • Loading branch information
DimitrisStaratzis authored May 16, 2024
1 parent 5c01699 commit 25fd4ce
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/src/unit-capi-array_schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,26 @@ TEST_CASE_METHOD(
tiledb_array_schema_free(&array_schema);
}

TEST_CASE_METHOD(
ArraySchemaFx,
"C API: Test array schema with invalid cell/tile order",
"[capi][array-schema]") {
// Create array schema
tiledb_array_schema_t* array_schema;
int rc = tiledb_array_schema_alloc(ctx_, TILEDB_SPARSE, &array_schema);
REQUIRE(rc == TILEDB_OK);

// Check that UNORDERED order fails
rc = tiledb_array_schema_set_tile_order(ctx_, array_schema, TILEDB_UNORDERED);
REQUIRE(rc == TILEDB_ERR);

rc = tiledb_array_schema_set_cell_order(ctx_, array_schema, TILEDB_UNORDERED);
REQUIRE(rc == TILEDB_ERR);

// Clean up
tiledb_array_schema_free(&array_schema);
}

TEST_CASE_METHOD(
ArraySchemaFx,
"C API: Test array schema with invalid dimension domain and tile extent",
Expand Down
4 changes: 4 additions & 0 deletions test/src/unit-cppapi-schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ TEST_CASE("C++ API: Schema", "[cppapi][schema]") {
schema.add_attribute(a2);
schema.add_attribute(a3);
schema.add_attribute(a4);
CHECK_THROWS(schema.set_cell_order(TILEDB_UNORDERED));
CHECK_THROWS(schema.set_tile_order(TILEDB_UNORDERED));
schema.set_cell_order(TILEDB_ROW_MAJOR);
schema.set_tile_order(TILEDB_COL_MAJOR);
CHECK_THROWS(schema.set_allows_dups(1));
Expand Down Expand Up @@ -152,6 +154,8 @@ TEST_CASE("C++ API: Schema", "[cppapi][schema]") {
schema.add_attribute(a2);
schema.add_attribute(a3);
schema.add_attribute(a4);
CHECK_THROWS(schema.set_cell_order(TILEDB_UNORDERED));
CHECK_THROWS(schema.set_tile_order(TILEDB_UNORDERED));
schema.set_cell_order(TILEDB_ROW_MAJOR);
schema.set_tile_order(TILEDB_COL_MAJOR);
schema.set_allows_dups(true);
Expand Down
10 changes: 10 additions & 0 deletions tiledb/sm/array_schema/array_schema.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1524,6 +1524,11 @@ Status ArraySchema::set_cell_order(Layout cell_order) {
Status_ArraySchemaError("Cannot set cell order; Hilbert order is only "
"applicable to sparse arrays"));

if (cell_order == Layout::UNORDERED)
return LOG_STATUS(Status_ArraySchemaError(
"Cannot set cell order; Cannot create ArraySchema "
"with UNORDERED cell order"));

cell_order_ = cell_order;

return Status::Ok();
Expand Down Expand Up @@ -1618,6 +1623,11 @@ Status ArraySchema::set_tile_order(Layout tile_order) {
return LOG_STATUS(Status_ArraySchemaError(
"Cannot set tile order; Hilbert order is not applicable to tiles"));

if (tile_order == Layout::UNORDERED)
return LOG_STATUS(Status_ArraySchemaError(
"Cannot set tile order; Cannot create ArraySchema "
"with UNORDERED tile order"));

tile_order_ = tile_order;
return Status::Ok();
}
Expand Down

0 comments on commit 25fd4ce

Please sign in to comment.