{"record":{"id":"21454a603e7d38ff","repo":"prestodb/presto","slug":"not-supported-21454a","errorCode":"NOT_SUPPORTED","errorMessage":"Database  location is not set","messagePattern":"Database  location is not set","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java","lineNumber":393,"sourceCode":"    {\n        SchemaTableName schemaTableName = tableMetadata.getTable();\n        String schemaName = schemaTableName.getSchemaName();\n        String tableName = schemaTableName.getTableName();\n\n        Schema schema = toIcebergSchema(tableMetadata.getColumns());\n\n        PartitionSpec partitionSpec = parsePartitionFields(schema, getPartitioning(tableMetadata.getProperties()));\n\n        MetastoreContext metastoreContext = getMetastoreContext(session);\n        Database database = metastore.getDatabase(metastoreContext, schemaName)\n                .orElseThrow(() -> new SchemaNotFoundException(schemaName));\n\n        HdfsContext hdfsContext = new HdfsContext(session, schemaName, tableName);\n        String targetPath = getTableLocation(tableMetadata.getProperties());\n        if (targetPath == null) {\n            Optional<String> location = database.getLocation();\n            if (!location.isPresent() || location.get().isEmpty()) {\n                throw new PrestoException(NOT_SUPPORTED, \"Database \" + schemaName + \" location is not set\");\n            }\n\n            Path databasePath = new Path(location.get());\n            Path resultPath = new Path(databasePath, tableName);\n            targetPath = resultPath.toString();\n        }\n\n        TableOperations operations = new HiveTableOperations(\n                metastore,\n                getMetastoreContext(session),\n                hdfsEnvironment,\n                hdfsContext,\n                hiveTableOperationsConfig,\n                manifestFileCache,\n                schemaName,\n                tableName,\n                session.getUser(),\n                targetPath);","sourceCodeStart":375,"sourceCodeEnd":411,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergHiveMetadata.java#L375-L411","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Recreate or alter the schema to set a location: CREATE SCHEMA ... WITH (location = 'hdfs://...') or update the metastore database location","Specify the table location explicitly: CREATE TABLE ... WITH (location = 'hdfs://path/to/table')","Set the metastore warehouse dir (hive.metastore.warehouse.dir) so default databases get a location","Create the table under a different schema that has a valid location"],"exampleFix":"// before\nCREATE TABLE sales.orders (...); -- DB location not set\n// after\nCREATE TABLE sales.orders (...) WITH (location = 'hdfs://namenode:8020/warehouse/sales/orders');","handlingStrategy":"validation","validationCode":"-- Ensure the schema has a location, or pass one per table:\nSHOW CREATE SCHEMA sales; -- verify location\nCREATE TABLE sales.orders (...) WITH (location = 'hdfs://namenode:8020/warehouse/sales/orders');","typeGuard":null,"tryCatchPattern":"try {\n    stmt.execute(createTableSql);\n} catch (SQLException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"location is not set\")) {\n        // set schema location in the metastore or add WITH (location=...) and retry\n    } else { throw e; }\n}","preventionTips":["Always create schemas with an explicit, valid location","Set hive.metastore.warehouse.dir so default databases resolve a base path","Standardize table DDL templates to include WITH (location=...) where needed","Audit metastore databases for empty location fields"],"tags":["iceberg","table-location","hive-metastore"],"backgroundTag":"missing-table-location","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"}