{"record":{"id":"3a093d5f5c934d48","repo":"prestodb/presto","slug":"not-supported-3a093d","errorCode":"NOT_SUPPORTED","errorMessage":"Unexpected table present in Hive metastore: ","messagePattern":"Unexpected table present in Hive metastore: ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java","lineNumber":566,"sourceCode":"        if (database.isPresent()) {\n            return getDatabaseProperties(database.get());\n        }\n        throw new SchemaNotFoundException(schemaName.getSchemaName());\n    }\n\n    @Override\n    public HiveTableHandle getTableHandle(ConnectorSession session, SchemaTableName tableName)\n    {\n        requireNonNull(tableName, \"tableName is null\");\n        MetastoreContext metastoreContext = getMetastoreContext(session);\n        Optional<Table> table = metastore.getTable(metastoreContext, tableName.getSchemaName(), tableName.getTableName());\n        if (!table.isPresent()) {\n            return null;\n        }\n\n        if (getSourceTableNameFromSystemTable(tableName).isPresent()) {\n            // We must not allow system table due to how permissions are checked in SystemTableAwareAccessControl.checkCanSelectFromTable()\n            throw new PrestoException(NOT_SUPPORTED, \"Unexpected table present in Hive metastore: \" + tableName);\n        }\n\n        if (!isOfflineDataDebugModeEnabled(session)) {\n            verifyOnline(tableName, Optional.empty(), getProtectMode(table.get()), table.get().getParameters());\n        }\n\n        return new HiveTableHandle(tableName.getSchemaName(), tableName.getTableName());\n    }\n\n    @Override\n    public ConnectorTableHandle getTableHandleForStatisticsCollection(ConnectorSession session, SchemaTableName tableName, Map<String, Object> analyzeProperties)\n    {\n        HiveTableHandle handle = getTableHandle(session, tableName);\n        if (handle == null) {\n            return null;\n        }\n        Optional<List<List<String>>> partitionValuesList = getPartitionList(analyzeProperties);\n        ConnectorTableMetadata tableMetadata = getTableMetadata(session, handle);","sourceCodeStart":548,"sourceCodeEnd":584,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveMetadata.java#L548-L584","documentation":"getTableHandle looks up tables in the Hive metastore; system tables (identified via getSourceTableNameFromSystemTable) must never be resolved as regular connector tables because permission checks (SystemTableAwareAccessControl.checkCanSelectFromTable) depend on them being routed separately. If such a table name is nonetheless present in the metastore, NOT_SUPPORTED is thrown.","triggerScenarios":"Calling getTableHandle (via handle/sourceTableHandle paths) with a SchemaTableName that matches a Hive system-table naming pattern and is actually present in the metastore.","commonSituations":"Users manually creating tables whose names collide with Presto's system table naming convention; migration/backup restores that recreated system-table-named entries; tooling that dumps and reimports metastore tables indiscriminately.","solutions":["Rename or drop the offending table from the Hive metastore so its name no longer collides with a system table name","Query the actual system table through the proper system schema instead of the base connector","Avoid creating Hive tables using reserved system-table naming patterns"],"exampleFix":"-- before: a metastore table named like a system table, e.g. \"orders$partitions\"\n-- after\nALTER TABLE `orders$partitions` RENAME TO `orders_partitions_meta`;","handlingStrategy":"validation","validationCode":"if (getSourceTableNameFromSystemTable(tableName).isPresent()) {\n    throw new IllegalArgumentException(\"Use the system catalog, not the hive catalog, for: \" + tableName);\n}","typeGuard":"boolean isRegularHiveTable(SchemaTableName name) {\n    return getSourceTableNameFromSystemTable(name).isEmpty();\n}","tryCatchPattern":"try {\n    // metadata/table handle lookup\n} catch (PrestoException e) {\n    if (e.getErrorCode().getCode() == StandardErrorCode.NOT_SUPPORTED.toErrorCode().getCode()) {\n        // reroute to the proper system catalog/schema\n    } else throw e;\n}","preventionTips":["Never create Hive tables whose names contain the system-table separator (e.g. '$')","Filter metastore listings to exclude system-table-shaped names before resolving","Query system tables via their dedicated system schema"],"tags":["hive","system-table","metastore","not-supported"],"backgroundTag":"system-table-name-collision","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"}