{"record":{"id":"7df7cfe07f0647f4","repo":"prestodb/presto","slug":"missing-table-7df7cf","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/GrantTask.java","lineNumber":56,"sourceCode":"import static com.google.common.collect.ImmutableSet.toImmutableSet;\nimport static com.google.common.util.concurrent.Futures.immediateFuture;\n\npublic class GrantTask\n        implements DDLDefinitionTask<Grant>\n{\n    @Override\n    public String getName()\n    {\n        return \"GRANT\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(Grant 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> tableHandle = metadata.getMetadataResolver(session).getTableHandle(tableName);\n        if (!tableHandle.isPresent()) {\n            throw new SemanticException(MISSING_TABLE, statement, \"Table '%s' does not exist\", tableName);\n        }\n\n        Set<Privilege> privileges;\n        if (statement.getPrivileges().isPresent()) {\n            privileges = statement.getPrivileges().get().stream()\n                    .map(privilege -> parsePrivilege(statement, privilege))\n                    .collect(toImmutableSet());\n        }\n        else {\n            // All privileges\n            privileges = EnumSet.allOf(Privilege.class);\n        }\n\n        // verify current identity has permissions to grant permissions\n        for (Privilege privilege : privileges) {\n            accessControl.checkCanGrantTablePrivilege(session.getRequiredTransactionId(), session.getIdentity(), session.getAccessControlContext(), privilege, tableName, createPrincipal(statement.getGrantee()), statement.isWithGrantOption());\n        }\n","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/GrantTask.java#L38-L74","documentation":"Thrown by GrantTask when GRANT (privilege on a table) is executed against a table name for which metadata.getMetadataResolver(session).getTableHandle(tableName) is empty. Unlike DROP statements there is no IF EXISTS variant, so a missing table always fails with MISSING_TABLE.","triggerScenarios":"Executing `GRANT SELECT ON table_name TO user` where createQualifiedObjectName resolves the name but no TableHandle exists in the connector.","commonSituations":"Typo'd table name; granting before table creation in a migration script; wrong current schema so the unqualified name resolves elsewhere; table exists in another catalog.","solutions":["Verify the table exists and fix the name (SHOW TABLES, qualify with catalog.schema)","Create the table before running the GRANT in deployment scripts","Re-run the grant against the correct catalog/schema"],"exampleFix":"// before\nGRANT SELECT ON orders TO USER bob; -- orders not in current schema\n// after\nGRANT SELECT ON sales.orders TO USER bob;","handlingStrategy":"validation","validationCode":"-- ensure the table exists before GRANT\nSELECT * FROM information_schema.tables\nWHERE table_catalog='sales' AND table_schema='myschema' AND table_name='orders';","typeGuard":null,"tryCatchPattern":"try { grantPrivileges(...); } catch (SemanticException e) { if (e.getCode() == SemanticErrorCode.MISSING_TABLE) { /* fail provisioning step with clear message */ } throw e; }","preventionTips":["Order deployment scripts: CREATE TABLE before GRANT","Always qualify grants with catalog.schema.table","Verify names against SHOW TABLES output before running GRANT"],"tags":["presto","sql","missing-table","permissions"],"backgroundTag":"object-does-not-exist","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"}