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 @@ -67,6 +67,7 @@
import static com.google.common.base.Verify.verify;
import static com.google.common.collect.ImmutableList.toImmutableList;
import static com.google.common.collect.ImmutableMap.toImmutableMap;
import static com.google.common.collect.ImmutableSet.toImmutableSet;
import static io.trino.spi.StandardErrorCode.ALREADY_EXISTS;
import static io.trino.spi.StandardErrorCode.NOT_FOUND;
import static io.trino.spi.StandardErrorCode.SCHEMA_NOT_EMPTY;
Expand Down Expand Up @@ -111,12 +112,24 @@ public synchronized void createSchema(ConnectorSession session, String schemaNam
}

@Override
public synchronized void dropSchema(ConnectorSession session, String schemaName)
public synchronized void dropSchema(ConnectorSession session, String schemaName, boolean cascade)
{
if (!schemas.contains(schemaName)) {
throw new TrinoException(NOT_FOUND, format("Schema [%s] does not exist", schemaName));
}

if (cascade) {
Set<SchemaTableName> viewNames = views.keySet().stream()
.filter(view -> view.getSchemaName().equals(schemaName))
.collect(toImmutableSet());
viewNames.forEach(viewName -> dropView(session, viewName));

Set<SchemaTableName> tableNames = tables.values().stream()
.filter(table -> table.getSchemaName().equals(schemaName))
.map(TableInfo::getSchemaTableName)
.collect(toImmutableSet());
tableNames.forEach(tableName -> dropTable(session, getTableHandle(session, tableName)));
}
// DropSchemaTask has the same logic, but needs to check in connector side considering concurrent operations
if (!isSchemaEmpty(schemaName)) {
throw new TrinoException(SCHEMA_NOT_EMPTY, "Schema not empty: " + schemaName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ protected boolean hasBehavior(TestingConnectorBehavior connectorBehavior)
return false;

case SUPPORTS_RENAME_SCHEMA:
case SUPPORTS_DROP_SCHEMA_CASCADE:
return false;

case SUPPORTS_ADD_COLUMN:
Expand Down