prestodb/presto · error · PrestoException

NOT_SUPPORTED

NOT_SUPPORTED

Error message

Database  location is not set

What it means

beginCreateTable() determines the target location for a new Iceberg table. If no explicit table location property is given, it falls back to the parent database's location. When the database has no location set (or an empty one), Presto throws NOT_SUPPORTED because it cannot derive a table path.

Source

Thrown at presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java:393

    {
        SchemaTableName schemaTableName = tableMetadata.getTable();
        String schemaName = schemaTableName.getSchemaName();
        String tableName = schemaTableName.getTableName();

        Schema schema = toIcebergSchema(tableMetadata.getColumns());

        PartitionSpec partitionSpec = parsePartitionFields(schema, getPartitioning(tableMetadata.getProperties()));

        MetastoreContext metastoreContext = getMetastoreContext(session);
        Database database = metastore.getDatabase(metastoreContext, schemaName)
                .orElseThrow(() -> new SchemaNotFoundException(schemaName));

        HdfsContext hdfsContext = new HdfsContext(session, schemaName, tableName);
        String targetPath = getTableLocation(tableMetadata.getProperties());
        if (targetPath == null) {
            Optional<String> location = database.getLocation();
            if (!location.isPresent() || location.get().isEmpty()) {
                throw new PrestoException(NOT_SUPPORTED, "Database " + schemaName + " location is not set");
            }

            Path databasePath = new Path(location.get());
            Path resultPath = new Path(databasePath, tableName);
            targetPath = resultPath.toString();
        }

        TableOperations operations = new HiveTableOperations(
                metastore,
                getMetastoreContext(session),
                hdfsEnvironment,
                hdfsContext,
                hiveTableOperationsConfig,
                manifestFileCache,
                schemaName,
                tableName,
                session.getUser(),
                targetPath);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Recreate or alter the schema to set a location: CREATE SCHEMA ... WITH (location = 'hdfs://...') or update the metastore database location
  2. Specify the table location explicitly: CREATE TABLE ... WITH (location = 'hdfs://path/to/table')
  3. Set the metastore warehouse dir (hive.metastore.warehouse.dir) so default databases get a location
  4. Create the table under a different schema that has a valid location

Example fix

// before
CREATE TABLE sales.orders (...); -- DB location not set
// after
CREATE TABLE sales.orders (...) WITH (location = 'hdfs://namenode:8020/warehouse/sales/orders');
Defensive patterns

Strategy: validation

Validate before calling

-- Ensure the schema has a location, or pass one per table:
SHOW CREATE SCHEMA sales; -- verify location
CREATE TABLE sales.orders (...) WITH (location = 'hdfs://namenode:8020/warehouse/sales/orders');

Try / catch

try {
    stmt.execute(createTableSql);
} catch (SQLException e) {
    if (e.getMessage() != null && e.getMessage().contains("location is not set")) {
        // set schema location in the metastore or add WITH (location=...) and retry
    } else { throw e; }
}

Prevention

When it happens

Trigger: CREATE TABLE without a location property in a schema whose metastore Database has location absent or empty — e.g. schema created without WITH (location=...) or a default database with no managed location.

Common situations: Schema created without a location on filesystems that don't support metastore default paths; databases created by external tools that leave location empty; warehouse dir not configured in the metastore.

Understand the failure class

Background: Presto NOT_SUPPORTED error: what "not supported" means and how to fix it — this error's family across 3 libraries.

Related errors


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