Skip to content

Commit

Permalink
Throw better error message when replacing corrupted iceberg table
Browse files Browse the repository at this point in the history
  • Loading branch information
posulliv authored and ebyhr committed Nov 23, 2024
1 parent ff9b2a0 commit 5a6ff9e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1061,8 +1061,10 @@ public ConnectorOutputTableHandle beginCreateTable(ConnectorSession session, Con

String tableLocation = null;
if (replace) {
IcebergTableHandle table = (IcebergTableHandle) getTableHandle(session, tableMetadata.getTableSchema().getTable(), Optional.empty(), Optional.empty());
if (table != null) {
ConnectorTableHandle tableHandle = getTableHandle(session, tableMetadata.getTableSchema().getTable(), Optional.empty(), Optional.empty());
if (tableHandle != null) {
checkValidTableHandle(tableHandle);
IcebergTableHandle table = (IcebergTableHandle) tableHandle;
verifyTableVersionForUpdate(table);
Table icebergTable = catalog.loadTable(session, table.getSchemaTableName());
Optional<String> providedTableLocation = getTableLocation(tableMetadata.getProperties());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7629,6 +7629,8 @@ public void testCorruptedTableLocation()
assertQueryFails("SELECT 1 FROM " + tableName + " WHERE false", "Metadata not found in metadata location for table " + schemaTableName);
assertQueryFails("SHOW CREATE TABLE " + tableName, "Metadata not found in metadata location for table " + schemaTableName);
assertQueryFails("CREATE TABLE a_new_table (LIKE " + tableName + " EXCLUDING PROPERTIES)", "Metadata not found in metadata location for table " + schemaTableName);
assertQueryFails("CREATE OR REPLACE TABLE " + tableName + " (id INT, country VARCHAR, independence ROW(month VARCHAR, year INT))", "Metadata not found in metadata location for table " + schemaTableName);
assertQueryFails("CREATE OR REPLACE TABLE " + tableName + " AS SELECT 1 x, 'IRELAND' y", "Metadata not found in metadata location for table " + schemaTableName);
assertQueryFails("DESCRIBE " + tableName, "Metadata not found in metadata location for table " + schemaTableName);
assertQueryFails("SHOW COLUMNS FROM " + tableName, "Metadata not found in metadata location for table " + schemaTableName);
assertQueryFails("SHOW STATS FOR " + tableName, "Metadata not found in metadata location for table " + schemaTableName);
Expand Down

0 comments on commit 5a6ff9e

Please sign in to comment.