{"record":{"id":"0a9b2fb65ad91531","repo":"prestodb/presto","slug":"not-supported-0a9b2f","errorCode":"NOT_SUPPORTED","errorMessage":"Cannot write to non-managed Hive table","messagePattern":"Cannot write to non-managed Hive table","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveTableWritabilityChecker.java","lineNumber":55,"sourceCode":"    public HiveTableWritabilityChecker(HiveClientConfig hiveClientConfig)\n    {\n        this(requireNonNull(hiveClientConfig, \"hiveClientConfig is null\").getWritesToNonManagedTablesEnabled());\n    }\n\n    public HiveTableWritabilityChecker(boolean writesToNonManagedTablesEnabled)\n    {\n        this.writesToNonManagedTablesEnabled = writesToNonManagedTablesEnabled;\n    }\n\n    @Override\n    public void checkTableWritable(Table table)\n    {\n        PrestoTableType tableType = table.getTableType();\n        if (!writesToNonManagedTablesEnabled\n                && !tableType.equals(MANAGED_TABLE)\n                && !tableType.equals(MATERIALIZED_VIEW)\n                && !tableType.equals(TEMPORARY_TABLE)) {\n            throw new PrestoException(NOT_SUPPORTED, \"Cannot write to non-managed Hive table\");\n        }\n\n        checkWritable(\n                table.getSchemaTableName(),\n                Optional.empty(),\n                getProtectMode(table),\n                table.getParameters(),\n                table.getStorage());\n    }\n}\n","sourceCodeStart":37,"sourceCodeEnd":66,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveTableWritabilityChecker.java#L37-L66","documentation":"Writes are only allowed to MANAGED_TABLE, MATERIALIZED_VIEW, or TEMPORARY_TABLE types; external/non-managed Hive tables are treated as read-only data owned outside Presto. checkTableWritable throws NOT_SUPPORTED when writesToNonManagedTablesEnabled is false (the default) and the target table type is not one of the writable types.","triggerScenarios":"INSERT INTO / UPDATE / DELETE / CREATE TABLE AS targeting a table whose PrestoTableType is EXTERNAL_TABLE (or any non-managed type) while the hive.non-managed-table-writes-enabled config is false.","commonSituations":"Pointing an INSERT at an external table backed by shared data; attempting writes after converting a managed table to external; environments where the safety config was intentionally left at its default.","solutions":["Write to a managed table instead, or convert the target to managed: ALTER TABLE ... SET PROPERTIES external_location / recreate as managed","Enable the connector config hive.non-managed-table-writes-enabled=true if the environment permits non-managed writes","Check table type via SHOW CREATE TABLE to confirm it is external before writing"],"exampleFix":"-- before (external table)\nINSERT INTO ext_table SELECT ...; -- fails\n-- after\nALTER TABLE ext_table UNSET PROPERTIES external_location; -- or recreate as managed\nINSERT INTO ext_table SELECT ...;","handlingStrategy":"validation","validationCode":"if (!table.getTableType().equals(PrestoTableType.MANAGED_TABLE)\n        && !table.getTableType().equals(PrestoTableType.MATERIALIZED_VIEW)\n        && !table.getTableType().equals(PrestoTableType.TEMPORARY_TABLE)) {\n    throw new IllegalStateException(\"target is non-managed; writes disabled\");\n}","typeGuard":"boolean isWritableType(PrestoTableType t) {\n    return t == PrestoTableType.MANAGED_TABLE || t == PrestoTableType.MATERIALIZED_VIEW || t == PrestoTableType.TEMPORARY_TABLE;\n}","tryCatchPattern":"try { insertInto(table); } catch (PrestoException e) { if (e.getErrorCode().getName().equals(\"NOT_SUPPORTED\")) { /* write to a managed staging table instead */ } else throw e; }","preventionTips":["Run SHOW CREATE TABLE to confirm the table is managed before INSERT/UPDATE/DELETE","Only enable hive.non-managed-table-writes-enabled when the ownership model allows it","Route writes through managed staging tables and CTAS"],"tags":["hive","not-supported","external-table","write-permissions"],"backgroundTag":"write-to-external-table","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"}