{"record":{"id":"84eda80d38aa2305","repo":"apache/beam","slug":"fieldtype-gettypename-name-in-schema-is-not-supported-while","errorCode":null,"errorMessage":"${fieldType.getTypeName().name()} in schema is not supported while writing. Please provide statement and preparedStatementSetter","messagePattern":"(.+?) in schema is not supported while writing\\. Please provide statement and preparedStatementSetter","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcUtil.java","lineNumber":349,"sourceCode":"              }\n            };\n          } else if (logicalTypeName.equals(\"OTHER\")) {\n            return (element, ps, i, fieldWithIndex) ->\n                ps.setObject(\n                    i + 1, element.getValue(fieldWithIndex.getIndex()), java.sql.Types.OTHER);\n          } else {\n            // generic beam logic type (such as portable logical types)\n            return getPreparedStatementSetCaller(logicalType.getBaseType());\n          }\n        }\n      default:\n        {\n          JdbcIO.PreparedStatementSetCaller pssc =\n              typeNamePsSetCallerMap.get(fieldType.getTypeName());\n          if (pssc != null) {\n            return pssc;\n          } else {\n            throw new RuntimeException(\n                fieldType.getTypeName().name()\n                    + \" in schema is not supported while writing. Please provide statement and\"\n                    + \" preparedStatementSetter\");\n          }\n        }\n    }\n  }\n\n  @SuppressWarnings(\"nullness\") // ps.setArray not annotated to allow a null\n  private static void setArrayNull(PreparedStatement ps, int i) throws SQLException {\n    ps.setArray(i + 1, null);\n  }\n\n  static void setNullToPreparedStatement(PreparedStatement ps, int i, JDBCType type)\n      throws SQLException {\n    ps.setNull(i + 1, type.getVendorTypeNumber());\n  }\n","sourceCodeStart":331,"sourceCodeEnd":367,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcUtil.java#L331-L367","documentation":"JdbcUtil.getPreparedStatementSetCaller looks up a PreparedStatementSetCaller for each field's TypeName in typeNamePsSetCallerMap. If the schema contains a type with no registered setter (an unsupported logical/unknown type), it throws this RuntimeException telling the user to supply a custom statement and setter.","triggerScenarios":"Writing a Beam Row via JdbcIO where the schema includes a field whose TypeName has no mapping in JdbcUtil (e.g. certain logical types, BYTES-adjacent custom logical types, ITERABLE, MAP/ROW nested types).","commonSituations":"Schemas inferred from Avro/Proto or other sources include logical types (e.g. decimal variants, UUID logical type) that JDBC writers don't map; upgrading Beam introduces new logical types not yet supported by the JDBC writer.","solutions":["Convert unsupported fields to a supported type (String, Long, Double, BigDecimal, byte[], etc.) in a DoFn/map before writing.","Use JdbcIO.write() with withStatement() and withPreparedStatementSetter() to bind the field manually.","Register custom support upstream if the type is broadly needed, or check JdbcUtil's supported TypeName map and align the schema."],"exampleFix":"// before\nschema = Schema.builder().addUuidField(\"id\").build(); // UUID logical type unsupported\n// after\nschema = Schema.builder().addStringField(\"id\").build(); // convert UUID to String before write","handlingStrategy":"fallback","validationCode":"// pre-check field types against JDBC-supported TypeNames before writing\nfor (Schema.Field f : schema.getFields()) {\n  if (!SUPPORTED_TYPE_NAMES.contains(f.getType().getTypeName())) {\n    throw new IllegalArgumentException(\"Field '\" + f.getName() + \"' needs conversion or custom setter: \"\n        + f.getType().getTypeName());\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  rows.apply(JdbcIO.<Row>writeWithSchema());\n} catch (RuntimeException e) {\n  if (e.getMessage() != null && e.getMessage().endsWith(\"Please provide statement and preparedStatementSetter\")) {\n    // rebuild write with withStatement()/withPreparedStatementSetter() handling the unsupported type\n  }\n  throw e;\n}","preventionTips":["Normalize schemas (flatten logical types) to JDBC-supported types before the write step.","Check JdbcUtil's typeNamePsSetCallerMap coverage when upgrading Beam versions.","Prefer withPreparedStatementSetter() for exotic columns rather than relying on schema inference."],"tags":["jdbc","java","schema","unsupported-type"],"backgroundTag":"unsupported-dtype","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}