diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java index 6a7f6e3989ed..de818584b17c 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/BaseHiveConnectorTest.java @@ -616,6 +616,17 @@ public void testSchemaOperations() assertUpdate(session, "DROP SCHEMA new_schema"); } + @Test + public void testCreateSchemaWithIncorrectLocation() + { + String schemaName = "test_create_schema_with_incorrect_location_" + randomNameSuffix(); + String schemaLocation = "s3://testbucket/%s/a#hash/%s".formatted(schemaName, schemaName); + + assertThatThrownBy(() -> assertUpdate("CREATE SCHEMA " + schemaName + " WITH (location = '" + schemaLocation + "')")) + .hasMessageContaining("Invalid location URI") + .hasStackTraceContaining("Fragment is not allowed in a file system location"); + } + @Test public void testSchemaAuthorizationForUser() { diff --git a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveS3AndGlueMetastoreTest.java b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveS3AndGlueMetastoreTest.java index 5f22419b9204..d66491bb0821 100644 --- a/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveS3AndGlueMetastoreTest.java +++ b/plugin/trino-hive/src/test/java/io/trino/plugin/hive/TestHiveS3AndGlueMetastoreTest.java @@ -276,26 +276,6 @@ public void testCtasWithIncorrectLocation() .hasStackTraceContaining("Fragment is not allowed in a file system location"); } - @Test - public void testCreateSchemaWithIncorrectLocation() - { - String schemaName = "test_create_schema_with_incorrect_location_" + randomNameSuffix(); - String schemaLocation = "s3://%s/%2$s/a#hash/%2$s".formatted(bucketName, schemaName); - String tableName = "test_basic_operations_table_" + randomNameSuffix(); - String qualifiedTableName = schemaName + "." + tableName; - - assertUpdate("CREATE SCHEMA " + schemaName + " WITH (location = '" + schemaLocation + "')"); - try (UncheckedCloseable ignored = onClose("DROP SCHEMA " + schemaName)) { - assertThat(getSchemaLocation(schemaName)).isEqualTo(schemaLocation); - - assertThatThrownBy(() -> assertUpdate("CREATE TABLE " + qualifiedTableName + "(col_str, col_int) AS VALUES ('str1', 1)")) - .hasMessageContaining("Fragment is not allowed in a file system location"); - - assertThatThrownBy(() -> assertUpdate("CREATE TABLE " + qualifiedTableName + "(col_str varchar, col_int integer)")) - .hasMessageContaining("Fragment is not allowed in a file system location"); - } - } - @Test public void testSchemaNameEscape() { diff --git a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/glue/TestIcebergS3AndGlueMetastoreTest.java b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/glue/TestIcebergS3AndGlueMetastoreTest.java index cac690815439..ac1a6720a96d 100644 --- a/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/glue/TestIcebergS3AndGlueMetastoreTest.java +++ b/plugin/trino-iceberg/src/test/java/io/trino/plugin/iceberg/catalog/glue/TestIcebergS3AndGlueMetastoreTest.java @@ -156,24 +156,4 @@ public void testCtasWithIncorrectLocation() " AS SELECT * FROM tpch.tiny.nation")) .hasMessageContaining("Fragment is not allowed in a file system location"); } - - @Test - public void testCreateSchemaWithIncorrectLocation() - { - String schemaName = "test_create_schema_with_incorrect_location_" + randomNameSuffix(); - String schemaLocation = "s3://%s/%s/a#hash/%s".formatted(bucketName, schemaName, schemaName); - String tableName = "test_basic_operations_table_" + randomNameSuffix(); - String qualifiedTableName = schemaName + "." + tableName; - - assertUpdate("CREATE SCHEMA " + schemaName + " WITH (location = '" + schemaLocation + "')"); - try (UncheckedCloseable ignored = onClose("DROP SCHEMA " + schemaName)) { - assertThat(getSchemaLocation(schemaName)).isEqualTo(schemaLocation); - - assertThatThrownBy(() -> assertUpdate("CREATE TABLE " + qualifiedTableName + "(col_str varchar, col_int int)")) - .hasMessageContaining("location contains a fragment"); - - assertThatThrownBy(() -> assertUpdate("CREATE TABLE " + qualifiedTableName + " AS SELECT * FROM tpch.tiny.nation")) - .hasMessageContaining("location contains a fragment"); - } - } }