{"record":{"id":"df31343ea3623143","repo":"apache/iceberg","slug":"org-apache-iceberg-spark-sparkrewritetablecatalog-df3134","errorCode":null,"errorMessage":"org.apache.iceberg.spark.SparkRewriteTableCatalog does not support time travel","messagePattern":"org\\.apache\\.iceberg\\.spark\\.SparkRewriteTableCatalog does not support time travel","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java","lineNumber":61,"sourceCode":"  }\n\n  @Override\n  public SparkRewriteTable loadTable(Identifier ident) throws NoSuchTableException {\n    validateNoNamespace(ident);\n\n    String groupId = ident.name();\n    Table table = TABLE_CACHE.get(groupId);\n\n    if (table == null) {\n      throw new NoSuchTableException(ident);\n    }\n\n    return new SparkRewriteTable(table, groupId);\n  }\n\n  @Override\n  public SparkTable loadTable(Identifier ident, String version) throws NoSuchTableException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support time travel\");\n  }\n\n  @Override\n  public SparkTable loadTable(Identifier ident, long timestampMicros) throws NoSuchTableException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support time travel\");\n  }\n\n  @Override\n  public void invalidateTable(Identifier ident) {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support table invalidation\");\n  }\n\n  @Override\n  public SparkTable createTable(Identifier ident, TableInfo tableInfo)\n      throws TableAlreadyExistsException {\n    throw new UnsupportedOperationException(CLASS_NAME + \" does not support creating tables\");\n  }\n","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/spark/v4.1/spark/src/main/java/org/apache/iceberg/spark/SparkRewriteTableCatalog.java#L43-L79","documentation":"The version-based loadTable(ident, version) overload on SparkRewriteTableCatalog always throws UnsupportedOperationException because the rewrite catalog operates on the live cached table and cannot resolve versioned (snapshot-id/branch/tag) loads.","triggerScenarios":"Calling loadTable(ident, \"branch-or-tag\") on SparkRewriteTableCatalog, or running a Spark rewrite procedure with time travel / versionAsOf options that force a versioned load.","commonSituations":"Passing time-travel options (versionAsOf/timestampAsOf) to rewrite or maintenance procedures; generic engine code probing the catalog with the versioned overload.","solutions":["Do not time travel with the rewrite catalog; rewrite always operates on the current table state.","Load the historical snapshot via the regular SparkCatalog: SELECT ... VERSION AS OF, then perform other operations on it.","Remove version/timestamp options from procedure calls targeting the rewrite catalog."],"exampleFix":"// before\nTable t = rewriteCatalog.loadTable(ident, \"hist-tag\");\n// after\nTable t = sparkCatalog.loadTable(ident, \"hist-tag\"); // versioned loads go through the real catalog","handlingStrategy":"validation","validationCode":"if (catalog instanceof SparkRewriteTableCatalog && version != null) {\n  throw new IllegalArgumentException(\"Time travel is not supported by SparkRewriteTableCatalog\");\n}","typeGuard":"boolean supportsTimeTravel(CatalogPlugin c) {\n  return !(c instanceof SparkRewriteTableCatalog);\n}","tryCatchPattern":"try {\n  Table t = catalog.loadTable(ident, version);\n} catch (UnsupportedOperationException e) {\n  Table t = sparkCatalog.loadTable(ident, version); // versioned loads via the real catalog\n}","preventionTips":["Never pass versionAsOf/time-travel options to rewrite procedures.","Route time-travel reads to SparkCatalog.","Capability-check the catalog before versioned loads.","Rewrite only the current snapshot."],"tags":["spark","rewrite","time-travel","unsupported-operation"],"backgroundTag":"operation-not-supported","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}