@@ -2038,14 +2038,20 @@ private void executeDropExtendedStats(ConnectorSession session, IcebergTableExec
20382038 {
20392039 checkArgument (executeHandle .procedureHandle () instanceof IcebergDropExtendedStatsHandle , "Unexpected procedure handle %s" , executeHandle .procedureHandle ());
20402040
2041- Table icebergTable = catalog .loadTable (session , executeHandle .schemaTableName ());
2042- beginTransaction (icebergTable );
2043- UpdateStatistics updateStatistics = transaction .updateStatistics ();
2044- for (StatisticsFile statisticsFile : icebergTable .statisticsFiles ()) {
2045- updateStatistics .removeStatistics (statisticsFile .snapshotId ());
2041+ try {
2042+ Table icebergTable = catalog .loadTable (session , executeHandle .schemaTableName ());
2043+ beginTransaction (icebergTable );
2044+ UpdateStatistics updateStatistics = transaction .updateStatistics ();
2045+ for (StatisticsFile statisticsFile : icebergTable .statisticsFiles ()) {
2046+ updateStatistics .removeStatistics (statisticsFile .snapshotId ());
2047+ }
2048+ updateStatistics .commit ();
2049+ commitTransaction (transaction , "drop extended stats" );
20462050 }
2047- updateStatistics .commit ();
2048- commitTransaction (transaction , "drop extended stats" );
2051+ catch (NotFoundException e ) {
2052+ throw new TrinoException (ICEBERG_INVALID_METADATA , e );
2053+ }
2054+
20492055 transaction = null ;
20502056 }
20512057
@@ -2054,8 +2060,13 @@ private void executeRollbackToSnapshot(ConnectorSession session, IcebergTableExe
20542060 checkArgument (executeHandle .procedureHandle () instanceof IcebergRollbackToSnapshotHandle , "Unexpected procedure handle %s" , executeHandle .procedureHandle ());
20552061 long snapshotId = ((IcebergRollbackToSnapshotHandle ) executeHandle .procedureHandle ()).snapshotId ();
20562062
2057- Table icebergTable = catalog .loadTable (session , executeHandle .schemaTableName ());
2058- icebergTable .manageSnapshots ().setCurrentSnapshot (snapshotId ).commit ();
2063+ try {
2064+ Table icebergTable = catalog .loadTable (session , executeHandle .schemaTableName ());
2065+ icebergTable .manageSnapshots ().setCurrentSnapshot (snapshotId ).commit ();
2066+ }
2067+ catch (NotFoundException e ) {
2068+ throw new TrinoException (ICEBERG_INVALID_METADATA , e );
2069+ }
20592070 }
20602071
20612072 private void executeExpireSnapshots (ConnectorSession session , IcebergTableExecuteHandle executeHandle )
@@ -2074,10 +2085,15 @@ private void executeExpireSnapshots(ConnectorSession session, IcebergTableExecut
20742085 IcebergSessionProperties .EXPIRE_SNAPSHOTS_MIN_RETENTION );
20752086
20762087 // ForwardingFileIo handles bulk operations so no separate function implementation is needed
2077- table .expireSnapshots ()
2078- .expireOlderThan (session .getStart ().toEpochMilli () - retention .toMillis ())
2079- .planWith (icebergScanExecutor )
2080- .commit ();
2088+ try {
2089+ table .expireSnapshots ()
2090+ .expireOlderThan (session .getStart ().toEpochMilli () - retention .toMillis ())
2091+ .planWith (icebergScanExecutor )
2092+ .commit ();
2093+ }
2094+ catch (NotFoundException e ) {
2095+ throw new TrinoException (ICEBERG_INVALID_METADATA , e );
2096+ }
20812097 }
20822098
20832099 private static void validateTableExecuteParameters (
0 commit comments