{"record":{"id":"8ab6815b03be71eb","repo":"apache/seatunnel","slug":"the-non-primary-key-field-cannot-be-empty-please","errorCode":null,"errorMessage":"The non-primary key field cannot be empty. Please set other fields","messagePattern":"The non-primary key field cannot be empty\\. Please set other fields","errorType":"exception","errorClass":"SeaTunnelException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/xugu/XuguDialect.java","lineNumber":107,"sourceCode":"    @Override\n    public TablePath parse(String tablePath) {\n        return TablePath.of(tablePath, true);\n    }\n\n    @Override\n    public String tableIdentifier(TablePath tablePath) {\n        return quoteIdentifier(tablePath.getSchemaAndTableName());\n    }\n\n    @Override\n    public Optional<String> getUpsertStatement(\n            String database, String tableName, String[] fieldNames, String[] pkNames) {\n        List<String> nonUniqueKeyFields =\n                Arrays.stream(fieldNames)\n                        .filter(fieldName -> !Arrays.asList(pkNames).contains(fieldName))\n                        .collect(Collectors.toList());\n        if (nonUniqueKeyFields.isEmpty()) {\n            throw new SeaTunnelException(\n                    \"The non-primary key field cannot be empty. Please set other fields\");\n        }\n        String valuesBinding =\n                Arrays.stream(fieldNames)\n                        .map(fieldName -> \":\" + fieldName + \" \" + quoteIdentifier(fieldName))\n                        .collect(Collectors.joining(\", \"));\n\n        String usingClause = String.format(\"SELECT %s FROM DUAL\", valuesBinding);\n        String onConditions =\n                Arrays.stream(pkNames)\n                        .map(\n                                fieldName ->\n                                        String.format(\n                                                \"TARGET.%s=SOURCE.%s\",\n                                                quoteIdentifier(fieldName),\n                                                quoteIdentifier(fieldName)))\n                        .collect(Collectors.joining(\" AND \"));\n        String updateSetClause =","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/xugu/XuguDialect.java#L89-L125","documentation":"Thrown by XuguDialect.getUpsertStatement when building an upsert (MERGE) statement finds that all fields are primary key fields, leaving no non-key fields to update. Xugu upserts require at least one column that is not part of the primary key.","triggerScenarios":"Configuring a Xugu sink with a primary key where the sink's field list equals the primary key list exactly (no additional payload columns), so no UPDATE assignment can be generated.","commonSituations":"Sink table defined with all columns in the primary key; user forgot to include non-key columns in the sink schema; trying to do pure key-only writes with upsert mode enabled instead of append/insert mode.","solutions":["Include at least one non-primary-key column in the sink table and schema","If you only need key-based inserts, switch the sink to insert mode instead of upsert","Reduce the primary key definition on the target table so some columns become non-key fields","Set the sink primary key configuration correctly so it does not span all fields"],"exampleFix":"// before: fields=[id], pk=[id] -> throws\n// after\n// table: CREATE TABLE t (id INT PRIMARY KEY, val VARCHAR(64));\n// fields=[id, val], pk=[id]","handlingStrategy":"validation","validationCode":"// Before running an upsert sink on Xugu\nif (Arrays.asList(pkNames).containsAll(Arrays.asList(fieldNames))) {\n    throw new IllegalArgumentException(\"Need at least one non-primary-key field for upsert\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Design sink tables with at least one non-key column","Use insert/append mode for key-only writes","Verify primary key configuration does not cover all fields"],"tags":["jdbc","xugu","upsert","configuration"],"backgroundTag":"invalid-config-value","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}