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 @@ -34,6 +34,7 @@
import io.trino.spi.connector.RelationType;
import io.trino.spi.connector.SchemaNotFoundException;
import io.trino.spi.connector.SchemaTableName;
import io.trino.spi.connector.TableNotFoundException;
import io.trino.spi.security.TrinoPrincipal;
import io.trino.spi.type.TypeManager;
import org.apache.iceberg.BaseTable;
Expand All @@ -47,6 +48,7 @@
import org.apache.iceberg.catalog.Namespace;
import org.apache.iceberg.exceptions.NoSuchNamespaceException;
import org.apache.iceberg.nessie.NessieIcebergClient;
import org.projectnessie.model.IcebergTable;

import java.util.Iterator;
import java.util.List;
Expand Down Expand Up @@ -255,7 +257,14 @@ public void dropTable(ConnectorSession session, SchemaTableName schemaTableName)
@Override
public void dropCorruptedTable(ConnectorSession session, SchemaTableName schemaTableName)
{
throw new TrinoException(NOT_SUPPORTED, "Cannot drop corrupted table %s from Iceberg Nessie catalog".formatted(schemaTableName));
IcebergTable table = nessieClient.table(toIdentifier(schemaTableName));
if (table == null) {
throw new TableNotFoundException(schemaTableName);
}
nessieClient.dropTable(toIdentifier(schemaTableName), true);
String tableLocation = table.getMetadataLocation().replaceFirst("/metadata/[^/]*$", "");
deleteTableDirectory(fileSystemFactory.create(session), schemaTableName, tableLocation);
invalidateTableCache(schemaTableName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,6 @@ public void testDropTableWithMissingManifestListFile()
.hasMessageContaining("metadata location for register_table is not supported");
}

@Test
@Override
public void testDropTableWithNonExistentTableLocation()
{
assertThatThrownBy(super::testDropTableWithNonExistentTableLocation)
.hasMessageMatching("Cannot drop corrupted table (.*)");
}

@Override
protected boolean isFileSorted(Location path, String sortColumnName)
{
Expand Down