{"record":{"id":"0b334775cd4e3a4d","repo":"prestodb/presto","slug":"jdbc-error-0b3347","errorCode":"JDBC_ERROR","errorMessage":"JDBC_ERROR: SQLException","messagePattern":"JDBC_ERROR: SQLException","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-postgresql/src/main/java/com/facebook/presto/plugin/postgresql/PostgreSqlClient.java","lineNumber":180,"sourceCode":"            return Optional.of(uuidReadMapping());\n        }\n        else if (typeName.equalsIgnoreCase(GEOMETRY) || typeName.equalsIgnoreCase(SPHERICAL_GEOGRAPHY)) {\n            return Optional.of(geometryReadMapping());\n        }\n        return super.toPrestoType(session, typeHandle);\n    }\n\n    @Override\n    public void createTable(ConnectorSession session, ConnectorTableMetadata tableMetadata)\n    {\n        try {\n            createTable(tableMetadata, session, tableMetadata.getTable().getTableName());\n        }\n        catch (SQLException e) {\n            if (DUPLICATE_TABLE_SQLSTATE.equals(e.getSQLState())) {\n                throw new PrestoException(ALREADY_EXISTS, e);\n            }\n            throw new PrestoException(JDBC_ERROR, e);\n        }\n    }\n\n    @Override\n    protected void renameTable(JdbcIdentity identity, String catalogName, SchemaTableName oldTable, SchemaTableName newTable)\n    {\n        // PostgreSQL does not allow qualifying the target of a rename\n        try (Connection connection = connectionFactory.openConnection(identity)) {\n            String sql = format(\n                    \"ALTER TABLE %s RENAME TO %s\",\n                    quoted(catalogName, oldTable.getSchemaName(), oldTable.getTableName()),\n                    quoted(newTable.getTableName()));\n            execute(connection, sql);\n        }\n        catch (SQLException e) {\n            throw new PrestoException(JDBC_ERROR, e);\n        }\n    }","sourceCodeStart":162,"sourceCodeEnd":198,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-postgresql/src/main/java/com/facebook/presto/plugin/postgresql/PostgreSqlClient.java#L162-L198","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nCREATE TABLE catalog.missing_schema.t (...);\n// after\nCREATE SCHEMA IF NOT EXISTS missing_schema;\nGRANT CREATE ON SCHEMA missing_schema TO presto_user;\nCREATE TABLE catalog.missing_schema.t (...);","handlingStrategy":"try-catch","validationCode":"sql\nSELECT has_schema_privilege('<presto_user>', '<schema>', 'CREATE');\nSELECT 1 FROM information_schema.schemata WHERE schema_name = '<schema>';","typeGuard":null,"tryCatchPattern":"java\ntry {\n    client.createTable(session, tableMetadata);\n} catch (PrestoException e) {\n    if (e.getErrorCode() == JDBC_ERROR.toErrorCode().getCode()) {\n        log.error(\"CREATE TABLE failed; inspect cause: \" + e.getCause(), e);\n    }\n    throw e;\n}","preventionTips":["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"],"tags":["postgresql","jdbc","create-table","sqlstate"],"backgroundTag":"jdbc-error","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"}