{"record":{"id":"cab8d204891bf408","repo":"prestodb/presto","slug":"missing-table-cab8d2","errorCode":"MISSING_TABLE","errorMessage":"Table '%s' does not exist","messagePattern":"Table '(.+?)' does not exist","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/DropBranchTask.java","lineNumber":55,"sourceCode":"\npublic class DropBranchTask\n        implements DDLDefinitionTask<DropBranch>\n{\n    @Override\n    public String getName()\n    {\n        return \"DROP BRANCH\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(DropBranch statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, Session session, List<Expression> parameters, WarningCollector warningCollector, String query)\n    {\n        QualifiedObjectName tableName = createQualifiedObjectName(session, statement, statement.getTableName(), metadata);\n        Optional<TableHandle> tableHandleOptional = metadata.getMetadataResolver(session).getTableHandle(tableName);\n\n        if (!tableHandleOptional.isPresent()) {\n            if (!statement.isTableExists()) {\n                throw new SemanticException(MISSING_TABLE, statement, \"Table '%s' does not exist\", tableName);\n            }\n            return immediateFuture(null);\n        }\n\n        Optional<MaterializedViewDefinition> optionalMaterializedView = metadata.getMetadataResolver(session).getMaterializedView(tableName);\n        if (optionalMaterializedView.isPresent()) {\n            throw new SemanticException(NOT_SUPPORTED, statement, \"'%s' is a materialized view, and drop branch is not supported\", tableName);\n        }\n\n        getConnectorIdOrThrow(session, metadata, tableName.getCatalogName());\n        accessControl.checkCanDropBranch(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), tableName);\n\n        metadata.dropBranch(session, tableHandleOptional.get(), statement.getBranchName(), statement.isBranchExists());\n        return immediateFuture(null);\n    }\n}\n","sourceCodeStart":37,"sourceCodeEnd":72,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/DropBranchTask.java#L37-L72","documentation":"DropBranchTask.execute resolves the target table handle via metadata.getMetadataResolver(session).getTableHandle. When no handle is returned the table does not exist; unless IF EXISTS was specified, it throws SemanticException(MISSING_TABLE). With IF EXISTS the statement is a no-op.","triggerScenarios":"Executing DROP BRANCH ON <table> (without IF EXISTS) where the qualified table name cannot be resolved to a TableHandle by the connector.","commonSituations":"Typo in table name; wrong catalog/schema qualification; table dropped concurrently by another session; querying a branch/tag name as if it were a table; connector metadata lag after ingestion.","solutions":["Verify the table with SHOW TABLES FROM <catalog>.<schema> and correct the name.","Add IF EXISTS: DROP BRANCH IF EXISTS ... ON <table> to make the drop idempotent.","Confirm the fully qualified name points at the intended catalog and schema."],"exampleFix":"// before\nDROP BRANCH b1 ON hive.default.events; -- table doesn't exist\n// after (idempotent)\nDROP BRANCH IF EXISTS b1 ON hive.default.events;","handlingStrategy":"validation","validationCode":"-- Confirm the table exists before DROP BRANCH\nSELECT table_name FROM information_schema.tables\nWHERE table_catalog = 'hive' AND table_schema = 'default' AND table_name = 'events';","typeGuard":null,"tryCatchPattern":"try {\n  session.execute(`DROP BRANCH ${branch} ON ${table}`);\n} catch (e) {\n  if (/Table '.*' does not exist/.test(e.message)) {\n    log.warn(`Skipping drop branch: ${table} missing`);\n    return; // or use IF EXISTS next time\n  }\n  throw e;\n}","preventionTips":["Use DROP BRANCH IF EXISTS in idempotent scripts and migrations.","Verify table names with SHOW TABLES before destructive DDL.","Fully qualify table names (catalog.schema.table) to avoid wrong-target resolution."],"tags":["presto","sql","missing-table","ddl"],"backgroundTag":"table-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"}