prestodb/presto · error · SchemaAlreadyExistsException

ALREADY_EXISTS

ALREADY_EXISTS

Error message

Schema already exists: '${schemaName}'

What it means

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.

Source

Thrown at presto-kudu/src/main/java/com/facebook/presto/kudu/schema/NoSchemaEmulation.java:34

import com.facebook.presto.spi.PrestoException;
import com.facebook.presto.spi.SchemaNotFoundException;
import com.facebook.presto.spi.SchemaTableName;
import com.google.common.collect.ImmutableList;
import org.apache.kudu.client.KuduClient;

import java.util.List;

import static com.facebook.presto.kudu.KuduClientSession.DEFAULT_SCHEMA;
import static com.facebook.presto.spi.StandardErrorCode.GENERIC_USER_ERROR;

public class NoSchemaEmulation
        implements SchemaEmulation
{
    @Override
    public void createSchema(KuduClient client, String schemaName)
    {
        if (DEFAULT_SCHEMA.equals(schemaName)) {
            throw new SchemaAlreadyExistsException(schemaName);
        }
        else {
            throw new PrestoException(GENERIC_USER_ERROR, "Creating schema in Kudu connector not allowed if schema emulation is disabled.");
        }
    }

    @Override
    public void dropSchema(KuduClient client, String schemaName)
    {
        if (DEFAULT_SCHEMA.equals(schemaName)) {
            throw new PrestoException(GENERIC_USER_ERROR, "Deleting default schema not allowed.");
        }
        else {
            throw new SchemaNotFoundException(schemaName);
        }
    }

    @Override

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Enable schema emulation: set kudu.schema-emulation.enabled=true and restart (optionally with a prefix for emulated schema tables)
  2. Keep all tables in the default schema when emulation is disabled
  3. Drop the CREATE SCHEMA step from scripts targeting Kudu without emulation

Example fix

// before (etc catalog properties)
kudu.schema-emulation.enabled=false
// after
kudu.schema-emulation.enabled=true
Defensive patterns

Strategy: validation

Validate before calling

if (catalogConfig.get("kudu.schema-emulation.enabled", "false").equals("false") && "default".equals(schemaName)) {
    throw new IllegalStateException("Schema 'default' already exists in Kudu; no emulation configured");
}

Try / catch

try {
    session.createSchema(schemaName);
} catch (SchemaAlreadyExistsException e) {
    log.info("Schema {} already exists; skipping", schemaName);
} catch (PrestoException e) {
    if (e.getMessage().contains("schema emulation is disabled")) {
        throw new IllegalStateException("Enable kudu.schema-emulation.enabled to create schemas", e);
    }
    throw e;
}

Prevention

When it happens

Trigger: CREATE SCHEMA default; or CREATE SCHEMA any_name; on a Kudu catalog configured without schema emulation (kudu.schema-emulation.enabled=false).

Common situations: Users with multi-schema habits (e.g. from Hive) try to organize Kudu tables into schemas; scripts assuming schema emulation is on.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/7f95651c7ca8babc. Report an issue: GitHub.