{"record":{"id":"28cf2567986317c0","repo":"prestodb/presto","slug":"createstruct","errorCode":null,"errorMessage":"createStruct","messagePattern":"createStruct","errorType":"exception","errorClass":"SQLFeatureNotSupportedException","httpStatus":null,"severity":"error","filePath":"presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoConnection.java","lineNumber":588,"sourceCode":"        Properties properties = new Properties();\n        for (Map.Entry<String, String> entry : clientInfo.entrySet()) {\n            properties.setProperty(entry.getKey(), entry.getValue());\n        }\n        return properties;\n    }\n\n    @Override\n    public Array createArrayOf(String typeName, Object[] elements)\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"createArrayOf\");\n    }\n\n    @Override\n    public Struct createStruct(String typeName, Object[] attributes)\n            throws SQLException\n    {\n        throw new SQLFeatureNotSupportedException(\"createStruct\");\n    }\n\n    @Override\n    public void setSchema(String schema)\n            throws SQLException\n    {\n        checkOpen();\n        this.schema.set(schema);\n    }\n\n    @Override\n    public String getSchema()\n            throws SQLException\n    {\n        checkOpen();\n        return schema.get();\n    }\n","sourceCodeStart":570,"sourceCodeEnd":606,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-jdbc/src/main/java/com/facebook/presto/jdbc/PrestoConnection.java#L570-L606","documentation":"PrestoConnection.createStruct(String typeName, Object[] attributes) unconditionally throws SQLFeatureNotSupportedException(\"createStruct\"). The driver does not implement java.sql.Struct creation, so the stub always fails locally. Presto ROW-type values cannot be constructed through this API.","triggerScenarios":"Calling connection.createStruct(\"typename\", attrs) and passing the result to setObject/setObject-with-target-type.","commonSituations":"ORMs or ETL frameworks mapping structured/composite columns through Struct; migrations from Oracle-style drivers.","solutions":["Pass attributes as Object[] via setObject and CAST(? AS ROW(...)) in the SQL text","Encode ROW values as JSON strings and cast on the server side","Refactor schemas/queries to avoid ROW-typed bind parameters where possible"],"exampleFix":"// before\nStruct st = connection.createStruct(\"address\", attrs);\nps.setObject(1, st);\n// after\nps.setObject(1, attrs);\n// sql: INSERT ... VALUES (CAST(? AS ROW(city VARCHAR, zip VARCHAR)))","handlingStrategy":"try-catch","validationCode":"DatabaseMetaData meta = connection.getMetaData();\nif (meta.getDriverName().contains(\"Presto\")) {\n    // bind ROW values via Object[] + CAST, not createStruct\n}","typeGuard":"static boolean supportsCreateStruct(DatabaseMetaData meta) throws SQLException {\n    return !meta.getDriverName().contains(\"Presto\");\n}","tryCatchPattern":"try {\n    Struct st = connection.createStruct(\"address\", attrs);\n    ps.setObject(1, st);\n} catch (SQLFeatureNotSupportedException e) {\n    ps.setObject(1, attrs); // pair with CAST(? AS ROW(...)) in SQL\n}","preventionTips":["Prefer JSON-encoded strings or explicit CASTs for ROW-typed parameters","Avoid Struct-based mapping in generic helpers targeting Presto","Test ROW round trips (write+read) against Presto in CI"],"tags":["jdbc","presto","unsupported-operation","struct"],"backgroundTag":"sql-feature-not-supported","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"}