prestodb/presto · error · PrestoException
JDBC_ERROR
JDBC_ERROR
Error message
JDBC_ERROR: SQLException
What it means
The catch-all branch of PostgreSqlClient.createTable: any SQLException from CREATE TABLE whose SQLSTATE is not the duplicate-table code is wrapped in a PrestoException with function code JDBC_ERROR. The original SQLException is preserved as the cause, so the real PostgreSQL error must be read from the stack trace.
Source
Thrown at presto-postgresql/src/main/java/com/facebook/presto/plugin/postgresql/PostgreSqlClient.java:180
return Optional.of(uuidReadMapping());
}
else if (typeName.equalsIgnoreCase(GEOMETRY) || typeName.equalsIgnoreCase(SPHERICAL_GEOGRAPHY)) {
return Optional.of(geometryReadMapping());
}
return super.toPrestoType(session, typeHandle);
}
@Override
public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata)
{
try {
createTable(tableMetadata, session, tableMetadata.getTable().getTableName());
}
catch (SQLException e) {
if (DUPLICATE_TABLE_SQLSTATE.equals(e.getSQLState())) {
throw new PrestoException(ALREADY_EXISTS, e);
}
throw new PrestoException(JDBC_ERROR, e);
}
}
@Override
protected void renameTable(JdbcIdentity identity, String catalogName, SchemaTableName oldTable, SchemaTableName newTable)
{
// PostgreSQL does not allow qualifying the target of a rename
try (Connection connection = connectionFactory.openConnection(identity)) {
String sql = format(
"ALTER TABLE %s RENAME TO %s",
quoted(catalogName, oldTable.getSchemaName(), oldTable.getTableName()),
quoted(newTable.getTableName()));
execute(connection, sql);
}
catch (SQLException e) {
throw new PrestoException(JDBC_ERROR, e);
}
}View on GitHub (pinned to 55bb57d202)
Solutions
- Read the cause (SQLException) for the real PostgreSQL message and SQLSTATE
- GRANT CREATE ON SCHEMA <schema> TO <presto_user> if it's a permission problem
- Create the missing schema: CREATE SCHEMA <schema>
- Check PostgreSQL server logs and connectivity if the error is connection-related, and retry transient failures
Example fix
// before CREATE TABLE catalog.missing_schema.t (...); // after CREATE SCHEMA IF NOT EXISTS missing_schema; GRANT CREATE ON SCHEMA missing_schema TO presto_user; CREATE TABLE catalog.missing_schema.t (...);
Defensive patterns
Strategy: try-catch
Validate before calling
sql
SELECT has_schema_privilege('<presto_user>', '<schema>', 'CREATE');
SELECT 1 FROM information_schema.schemata WHERE schema_name = '<schema>'; Try / catch
java
try {
client.createTable(session, tableMetadata);
} catch (PrestoException e) {
if (e.getErrorCode() == JDBC_ERROR.toErrorCode().getCode()) {
log.error("CREATE TABLE failed; inspect cause: " + e.getCause(), e);
}
throw e;
} Prevention
- GRANT CREATE ON SCHEMA to the Presto PostgreSQL user during provisioning
- Create the target schema as part of deployment
- Map Presto column types to PostgreSQL-supported types before DDL
- Retry transient connection failures with backoff
When it happens
Trigger: createTable fails with any non-42P07 SQLException — e.g. permission denied for schema, syntax/type mapping errors, connection loss during DDL, undefined schema, or disk full on the PostgreSQL server.
Common situations: The Presto PostgreSQL user lacks CREATE privilege on the target schema, the target schema doesn't exist, unsupported column types in tableMetadata, or transient network/database outages.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/0b334775cd4e3a4d.
Report an issue: GitHub.