diff --git a/test/src/unit-capi-array_schema.cc b/test/src/unit-capi-array_schema.cc index e04735b5ac4..f4d52067137 100644 --- a/test/src/unit-capi-array_schema.cc +++ b/test/src/unit-capi-array_schema.cc @@ -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", diff --git a/test/src/unit-cppapi-schema.cc b/test/src/unit-cppapi-schema.cc index b0c731c8638..2a798efd68d 100644 --- a/test/src/unit-cppapi-schema.cc +++ b/test/src/unit-cppapi-schema.cc @@ -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)); @@ -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); diff --git a/tiledb/sm/array_schema/array_schema.cc b/tiledb/sm/array_schema/array_schema.cc index 76a0bc22424..b0fbc42f51b 100644 --- a/tiledb/sm/array_schema/array_schema.cc +++ b/tiledb/sm/array_schema/array_schema.cc @@ -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(); @@ -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(); }