{"record":{"id":"a910acdb957e7128","repo":"apache/seatunnel","slug":"common-unsupported-operation-a910ac","errorCode":"COMMON_UNSUPPORTED_OPERATION","errorMessage":"Unsupported type: ","messagePattern":"Unsupported type: ","errorType":"error_code","errorClass":"ElasticsearchConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/serialize/KeyExtractor.java","lineNumber":77,"sourceCode":"\n        List<FieldFormatter> fieldFormatters = new ArrayList<>(primaryKeys.length);\n        for (String fieldName : primaryKeys) {\n            int fieldIndex = rowType.indexOf(fieldName);\n            SeaTunnelDataType<?> fieldType = rowType.getFieldType(fieldIndex);\n            FieldFormatter fieldFormatter = createFieldFormatter(fieldIndex, fieldType);\n            fieldFormatters.add(fieldFormatter);\n        }\n        return new KeyExtractor(fieldFormatters.toArray(new FieldFormatter[0]), keyDelimiter);\n    }\n\n    private static FieldFormatter createFieldFormatter(\n            int fieldIndex, SeaTunnelDataType fieldType) {\n        return row -> {\n            switch (fieldType.getSqlType()) {\n                case ROW:\n                case ARRAY:\n                case MAP:\n                    throw new ElasticsearchConnectorException(\n                            CommonErrorCodeDeprecated.UNSUPPORTED_OPERATION,\n                            \"Unsupported type: \" + fieldType);\n                case DATE:\n                    LocalDate localDate = (LocalDate) row.getField(fieldIndex);\n                    return localDate.toString();\n                case TIME:\n                    LocalTime localTime = (LocalTime) row.getField(fieldIndex);\n                    return localTime.toString();\n                case TIMESTAMP:\n                    LocalDateTime localDateTime = (LocalDateTime) row.getField(fieldIndex);\n                    return localDateTime.toString();\n                default:\n                    return row.getField(fieldIndex).toString();\n            }\n        };\n    }\n\n    private interface FieldFormatter extends Serializable {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-elasticsearch/src/main/java/org/apache/seatunnel/connectors/seatunnel/elasticsearch/serialize/KeyExtractor.java#L59-L95","documentation":"KeyExtractor formats primary-key fields into a string key for Elasticsearch document _id generation. Nested or collection types (ROW, ARRAY, MAP) cannot be rendered as a flat key string, so the library throws ElasticsearchConnectorException with UNSUPPORTED_OPERATION when a primary key column has one of those SQL types.","triggerScenarios":"Declaring a SeaTunnel table whose primary key (or index/`_id` key) column is of type ROW, ARRAY, or MAP; KeyExtractor.createFieldFormatter throws as soon as it builds the field formatter for that column.","commonSituations":"Source tables with composite/nested keys mapped to Elasticsearch sinks; CDC rows whose primary key is a struct; users assuming nested fields are flattened automatically for key extraction.","solutions":["Change the primary key column to a primitive scalar type (STRING, INT, LONG, etc.)","If the key must come from a nested field, flatten it upstream with a transform (e.g. FieldMapper/Copy) and use the flattened scalar field as the primary key","Cast or convert the key column to STRING in the source SQL/catalog before writing to Elasticsearch"],"exampleFix":"// before\nprimaryKeys = [\"user\"]  // user is ROW<id INT, name STRING>\n// after\nprimaryKeys = [\"user_id\"]  // user_id is a scalar STRING/INT field, extracted via transform","handlingStrategy":"validation","validationCode":"for (String pk : primaryKeys) {\n    SeaTunnelDataType<?> t = rowType.getFieldType(rowType.indexOf(pk));\n    SqlType s = t.getSqlType();\n    if (s == SqlType.ROW || s == SqlType.ARRAY || s == SqlType.MAP) {\n        throw new IllegalArgumentException(\"Primary key field '\" + pk + \"' must be a scalar type, got \" + s);\n    }\n}","typeGuard":"boolean isScalarKey(SeaTunnelDataType<?> t) {\n    SqlType s = t.getSqlType();\n    return s != SqlType.ROW && s != SqlType.ARRAY && s != SqlType.MAP;\n}","tryCatchPattern":null,"preventionTips":["Declare only scalar primary-key columns for ES sinks","Flatten nested fields with transforms before sink","Add a startup schema check that validates key column types"],"tags":["elasticsearch","primary-key","unsupported-type","serialization"],"backgroundTag":"incompatible-source-type","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}