{"record":{"id":"281215d4d420f976","repo":"apache/iceberg","slug":"cannot-scan-table-using-scan-snapshot-id-s-confi","errorCode":null,"errorMessage":"Cannot scan table using scan snapshot id %s: configured for incremental data in snapshots (%s, %s]","messagePattern":"Cannot scan table using scan snapshot id (.+?): configured for incremental data in snapshots \\((.+?), (.+?)\\]","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/apache/iceberg/IncrementalDataTableScan.java","lineNumber":57,"sourceCode":"  @Override\n  public TableScan asOfTime(long timestampMillis) {\n    throw new UnsupportedOperationException(\n        String.format(\n            \"Cannot scan table as of time %s: configured for incremental data in snapshots (%s, %s]\",\n            timestampMillis, context().fromSnapshotId(), context().toSnapshotId()));\n  }\n\n  @Override\n  public TableScan useRef(String ref) {\n    throw new UnsupportedOperationException(\n        String.format(\n            \"Cannot scan table using ref %s: configured for incremental data in snapshots (%s, %s]\",\n            ref, context().fromSnapshotId(), context().toSnapshotId()));\n  }\n\n  @Override\n  public TableScan useSnapshot(long scanSnapshotId) {\n    throw new UnsupportedOperationException(\n        String.format(\n            \"Cannot scan table using scan snapshot id %s: configured for incremental data in snapshots (%s, %s]\",\n            scanSnapshotId, context().fromSnapshotId(), context().toSnapshotId()));\n  }\n\n  @Override\n  public TableScan appendsBetween(long fromSnapshotId, long toSnapshotId) {\n    validateSnapshotIdsRefinement(fromSnapshotId, toSnapshotId);\n    return new IncrementalDataTableScan(\n        table(),\n        schema(),\n        context().fromSnapshotIdExclusive(fromSnapshotId).toSnapshotId(toSnapshotId));\n  }\n\n  @Override\n  public TableScan appendsAfter(long newFromSnapshotId) {\n    final Snapshot currentSnapshot = table().currentSnapshot();\n    Preconditions.checkState(","sourceCodeStart":39,"sourceCodeEnd":75,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/core/src/main/java/org/apache/iceberg/IncrementalDataTableScan.java#L39-L75","documentation":"useSnapshot pins a scan to one snapshot, which conflicts with an incremental scan's (fromSnapshotId, toSnapshotId) range. IncrementalDataTableScan rejects it with UnsupportedOperationException, echoing the configured range, because an incremental scan must compare two snapshots, not read one.","triggerScenarios":"Calling table.incrementalScan(...).useSnapshot(snapshotId) on an incremental scan result.","commonSituations":"Reuse of scan builders shared between normal and incremental scans; reading engines that pass 'snapshot-id' as a generic scan option to all scan types.","solutions":["Drop the useSnapshot call and configure fromSnapshot(long)/toSnapshot(long) for the incremental range.","If a single-snapshot read is wanted, use table.scan().useSnapshot(id) instead of an incremental scan.","Guard ref/snapshot pinning behind an instanceof check for incremental scans."],"exampleFix":"// before\nTableScan scan = table.incrementalScan(startId).useSnapshot(targetId);\n// after\nTableScan scan = table.incrementalScan(startId, targetId);","handlingStrategy":"type-guard","validationCode":"if (scan instanceof org.apache.iceberg.IncrementalDataTableScan) {\n  // pass the id via toSnapshot, not useSnapshot\n}","typeGuard":"boolean supportsSingleSnapshotScan(TableScan scan) {\n  return !(scan instanceof org.apache.iceberg.IncrementalDataTableScan);\n}","tryCatchPattern":"try {\n  scan.useSnapshot(id);\n} catch (UnsupportedOperationException e) {\n  scan = table.incrementalScan(fromId, id);\n}","preventionTips":["Map 'snapshot-id' options to toSnapshot for incremental scans in shared option plumbing.","Remember incremental scans always need a range, never a single snapshot."],"tags":["incremental-scan","snapshot-id","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}