Skip to content

Commit 3d347c5

Browse files
piotrrzyskofindepi
authored andcommitted
Fix handling of dropped base tables for Iceberg MVs
Because the engine does not consider MVs stale while they are still within the grace period, an error should not be returned even if a base table has been dropped and the grace period has not yet elapsed.
1 parent 37394ec commit 3d347c5

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

plugin/trino-iceberg/src/main/java/io/trino/plugin/iceberg/IcebergMetadata.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3928,13 +3928,10 @@ case FirstChangeSnapshot(Snapshot snapshot) -> {
39283928
firstTableChange = firstTableChange
39293929
.map(epochMilli -> Math.min(epochMilli, snapshot.timestampMillis()));
39303930
}
3931-
case UnknownTableChange() -> {
3931+
case UnknownTableChange(), GoneOrCorruptedTableChange() -> {
39323932
hasStaleIcebergTables = true;
39333933
firstTableChange = Optional.empty();
39343934
}
3935-
case GoneOrCorruptedTableChange() -> {
3936-
return new MaterializedViewFreshness(STALE, Optional.empty());
3937-
}
39383935
}
39393936
}
39403937

testing/trino-testing/src/main/java/io/trino/testing/BaseConnectorTest.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1801,9 +1801,14 @@ private void testMaterializedViewBaseTableGone(boolean initialized)
18011801
assertUpdate("REFRESH MATERIALIZED VIEW " + viewName, 1);
18021802
}
18031803
assertUpdate("DROP TABLE " + baseTable);
1804-
assertQueryFails(
1805-
"TABLE " + viewName,
1806-
"line 1:1: Failed analyzing stored view '%1$s\\.%2$s\\.%3$s': line 3:3: Table '%1$s\\.%2$s\\.%4$s' does not exist".formatted(catalog, schema, viewName, baseTable));
1804+
if (initialized) {
1805+
assertQuerySucceeds("TABLE " + viewName);
1806+
}
1807+
else {
1808+
assertQueryFails(
1809+
"TABLE " + viewName,
1810+
"line 1:1: Failed analyzing stored view '%1$s\\.%2$s\\.%3$s': line 3:3: Table '%1$s\\.%2$s\\.%4$s' does not exist".formatted(catalog, schema, viewName, baseTable));
1811+
}
18071812
assertUpdate("DROP MATERIALIZED VIEW " + viewName);
18081813
}
18091814

0 commit comments

Comments
 (0)