{"record":{"id":"4079f49a0948a80b","repo":"prestodb/presto","slug":"not-found-4079f4","errorCode":"NOT_FOUND","errorMessage":"Branch %s doesn't exist in table %s","messagePattern":"Branch (.+?) doesn't exist in table (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java","lineNumber":1148,"sourceCode":"    }\n\n    public void rollback()\n    {\n        transactionContext.rollback();\n    }\n\n    @Override\n    public void dropBranch(ConnectorSession session, ConnectorTableHandle tableHandle, String branchName, boolean branchExists)\n    {\n        IcebergTableHandle icebergTableHandle = (IcebergTableHandle) tableHandle;\n        verify(icebergTableHandle.getIcebergTableName().getTableType() == DATA, \"only the data table can have branch dropped\");\n        Table icebergTable = getIcebergTable(session, icebergTableHandle.getSchemaTableName());\n        if (icebergTable.refs().containsKey(branchName) && icebergTable.refs().get(branchName).isBranch()) {\n            icebergTable.manageSnapshots().removeBranch(branchName).commit();\n        }\n        else {\n            if (!branchExists) {\n                throw new PrestoException(NOT_FOUND, format(\"Branch %s doesn't exist in table %s\", branchName, icebergTableHandle.getSchemaTableName().getTableName()));\n            }\n        }\n    }\n\n    @Override\n    public void createBranch(\n            ConnectorSession session,\n            ConnectorTableHandle tableHandle,\n            String branchName,\n            boolean replace,\n            boolean ifNotExists,\n            Optional<ConnectorTableVersion> tableVersion,\n            Optional<Long> retainDays,\n            Optional<Integer> minSnapshotsToKeep,\n            Optional<Long> maxSnapshotAgeDays)\n    {\n        IcebergTableHandle icebergTableHandle = (IcebergTableHandle) tableHandle;\n        verify(icebergTableHandle.getIcebergTableName().getTableType() == DATA, \"only the data table can have branch created\");","sourceCodeStart":1130,"sourceCodeEnd":1166,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java#L1130-L1166","documentation":"Thrown when dropping a branch that does not exist on the Iceberg table. The connector checks table.refs() for a branch with the given name and, if absent (and the caller did not opt into if-exists semantics), fails with NOT_FOUND.","triggerScenarios":"Executing ALTER TABLE ... DROP BRANCH <name> where the branch name is misspelled or the branch was already removed; also raised when a caller passes branchExists=false and the branch is missing.","commonSituations":"Typo in branch name; branch already deleted by another job/user; running the drop twice; branch only exists in another catalog or table.","solutions":["Verify the branch exists via table refs (e.g. inspect the table's branches in Iceberg metadata) before dropping.","Use IF EXISTS so a missing branch is a no-op instead of an error.","Correct the branch name (check case sensitivity)."],"exampleFix":"// before\nALTER TABLE t DROP BRANCH audit_2024; -- branch doesn't exist\n// after\nALTER TABLE t DROP BRANCH IF EXISTS audit_2024;","handlingStrategy":"validation","validationCode":"-- check branch existence before dropping\nSELECT * FROM \"t$refs\" WHERE name = 'audit_2024' AND type = 'BRANCH';","typeGuard":null,"tryCatchPattern":"try { dropBranch(...); }\ncatch (PrestoException e) { if (NOT_FOUND.equals(e.getErrorCode())) { /* treat as no-op or fix the name */ } }","preventionTips":["Always use DROP BRANCH IF EXISTS in scripts","List refs before dropping","Watch for retention jobs that may remove branches first"],"tags":["iceberg","branch","not-found","ddl"],"backgroundTag":"iceberg-branch-not-found","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}