Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
}