{"record":{"id":"7f95651c7ca8babc","repo":"prestodb/presto","slug":"already-exists-7f9565","errorCode":"ALREADY_EXISTS","errorMessage":"Schema already exists: '${schemaName}'","messagePattern":"Schema already exists: '(.+?)'","errorType":"error_code","errorClass":"SchemaAlreadyExistsException","httpStatus":null,"severity":"error","filePath":"presto-kudu/src/main/java/com/facebook/presto/kudu/schema/NoSchemaEmulation.java","lineNumber":34,"sourceCode":"import com.facebook.presto.spi.PrestoException;\nimport com.facebook.presto.spi.SchemaNotFoundException;\nimport com.facebook.presto.spi.SchemaTableName;\nimport com.google.common.collect.ImmutableList;\nimport org.apache.kudu.client.KuduClient;\n\nimport java.util.List;\n\nimport static com.facebook.presto.kudu.KuduClientSession.DEFAULT_SCHEMA;\nimport static com.facebook.presto.spi.StandardErrorCode.GENERIC_USER_ERROR;\n\npublic class NoSchemaEmulation\n        implements SchemaEmulation\n{\n    @Override\n    public void createSchema(KuduClient client, String schemaName)\n    {\n        if (DEFAULT_SCHEMA.equals(schemaName)) {\n            throw new SchemaAlreadyExistsException(schemaName);\n        }\n        else {\n            throw new PrestoException(GENERIC_USER_ERROR, \"Creating schema in Kudu connector not allowed if schema emulation is disabled.\");\n        }\n    }\n\n    @Override\n    public void dropSchema(KuduClient client, String schemaName)\n    {\n        if (DEFAULT_SCHEMA.equals(schemaName)) {\n            throw new PrestoException(GENERIC_USER_ERROR, \"Deleting default schema not allowed.\");\n        }\n        else {\n            throw new SchemaNotFoundException(schemaName);\n        }\n    }\n\n    @Override","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-kudu/src/main/java/com/facebook/presto/kudu/schema/NoSchemaEmulation.java#L16-L52","documentation":"With schema emulation disabled (NoSchemaEmulation), Kudu uses only the 'default' schema. createSchema throws SchemaAlreadyExistsException (which surfaces as ALREADY_EXISTS) when asked to create the built-in default schema, and a generic user error for any other name.","triggerScenarios":"CREATE SCHEMA default; or CREATE SCHEMA any_name; on a Kudu catalog configured without schema emulation (kudu.schema-emulation.enabled=false).","commonSituations":"Users with multi-schema habits (e.g. from Hive) try to organize Kudu tables into schemas; scripts assuming schema emulation is on.","solutions":["Enable schema emulation: set kudu.schema-emulation.enabled=true and restart (optionally with a prefix for emulated schema tables)","Keep all tables in the default schema when emulation is disabled","Drop the CREATE SCHEMA step from scripts targeting Kudu without emulation"],"exampleFix":"// before (etc catalog properties)\nkudu.schema-emulation.enabled=false\n// after\nkudu.schema-emulation.enabled=true","handlingStrategy":"validation","validationCode":"if (catalogConfig.get(\"kudu.schema-emulation.enabled\", \"false\").equals(\"false\") && \"default\".equals(schemaName)) {\n    throw new IllegalStateException(\"Schema 'default' already exists in Kudu; no emulation configured\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    session.createSchema(schemaName);\n} catch (SchemaAlreadyExistsException e) {\n    log.info(\"Schema {} already exists; skipping\", schemaName);\n} catch (PrestoException e) {\n    if (e.getMessage().contains(\"schema emulation is disabled\")) {\n        throw new IllegalStateException(\"Enable kudu.schema-emulation.enabled to create schemas\", e);\n    }\n    throw e;\n}","preventionTips":["Check SHOW SCHEMAS on the Kudu catalog before CREATE SCHEMA","Make CREATE SCHEMA idempotent (catch ALREADY_EXISTS)","Enable schema emulation if multi-schema organization is required"],"tags":["kudu","schema","configuration"],"backgroundTag":"schema-already-exists","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"}