{"record":{"id":"490d2b6063c22bb9","repo":"apache/seatunnel","slug":"unsupported-operation-type-the-min-value-type-s","errorCode":null,"errorMessage":"Unsupported operation type, the MIN value type %s is different with MAX value type %s.","messagePattern":"Unsupported operation type, the MIN value type (.+?) is different with MAX value type (.+?)\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/splitter/AbstractJdbcSourceChunkSplitter.java","lineNumber":364,"sourceCode":"            } catch (ArithmeticException e) {\n                // Stop chunk split to avoid dead loop when number overflows.\n                break;\n            }\n        }\n        // add the ending split\n        splits.add(ChunkRange.of(chunkStart, null));\n        return splits;\n    }\n\n    // ------------------------------------------------------------------------------------------\n\n    /** Returns the distribution factor of the given table. */\n    @SuppressWarnings(\"MagicNumber\")\n    protected double calculateDistributionFactor(\n            TableId tableId, Object min, Object max, long approximateRowCnt) {\n\n        if (!min.getClass().equals(max.getClass())) {\n            throw new IllegalStateException(\n                    String.format(\n                            \"Unsupported operation type, the MIN value type %s is different with MAX value type %s.\",\n                            min.getClass().getSimpleName(), max.getClass().getSimpleName()));\n        }\n        if (approximateRowCnt == 0) {\n            return Double.MAX_VALUE;\n        }\n        BigDecimal difference = ObjectUtils.minus(max, min);\n        // factor = (max - min + 1) / rowCount\n        final BigDecimal subRowCnt = difference.add(BigDecimal.valueOf(1));\n        double distributionFactor =\n                subRowCnt.divide(new BigDecimal(approximateRowCnt), 4, ROUND_CEILING).doubleValue();\n        log.info(\n                \"The distribution factor of table {} is {} according to the min split key {}, max split key {} and approximate row count {}\",\n                tableId,\n                distributionFactor,\n                min,\n                max,","sourceCodeStart":346,"sourceCodeEnd":382,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-cdc/connector-cdc-base/src/main/java/org/apache/seatunnel/connectors/cdc/base/source/enumerator/splitter/AbstractJdbcSourceChunkSplitter.java#L346-L382","documentation":"calculateDistributionFactor() computes a factor used to decide whether the table is evenly distributed for chunk splitting. If the MIN and MAX sampled values of the split column are of different Java classes (e.g. different driver-side representations of the value), the arithmetic is meaningless, so it throws IllegalStateException.","triggerScenarios":"distributionFactor() -> calculateDistributionFactor(tableId, min, max, approximateRowCnt) where min.getClass() != max.getClass(); typically caused by the DB returning heterogeneous types for MIN()/MAX() on odd column types (e.g. mixed charsets, enum/uint driver mappings).","commonSituations":"Split column of a type whose MIN/MAX come back as different classes (e.g. BIT, ENUM, unsigned variants in the MySQL driver); corrupted or mixed-type data in the column; dialect-specific driver type mapping quirks.","solutions":["Check the split column type; switch to a PK/unique column with a consistent, supported numeric/date/string type","Inspect the actual column data for mixed/invalid values and normalize the column","Avoid keyless or exotic typed columns; add a plain BIGINT/INT primary key for splitting","If caused by a driver type-mapping bug, upgrade the JDBC driver or connector version"],"exampleFix":"// before: split column = status ENUM(...)\n// ALTER TABLE db.t ADD COLUMN id BIGINT AUTO_INCREMENT PRIMARY KEY;\n// after: connector picks `id` (consistent Long min/max) for chunk splitting","handlingStrategy":"validation","validationCode":"// Ensure min/max of the split column have a consistent type:\nSELECT MIN(id), MAX(id), \n       MIN(id) = MAX(id) OR typeof(MIN(id)) = typeof(MAX(id)) AS types_ok FROM db.t;","typeGuard":"boolean sameType(Object min, Object max) { return min != null && max != null && min.getClass().equals(max.getClass()); }","tryCatchPattern":"try { factor = calculateDistributionFactor(tableId, min, max, cnt); }\ncatch (IllegalStateException e) { LOG.warn(\"Mixed min/max types for {}\", tableId); useFallbackChunkSize(); }","preventionTips":["Choose split keys with homogeneous, well-supported types (INT/BIGINT/DATE/VARCHAR)","Avoid ENUM/BIT/unsigned exotic columns as split keys","Clean mixed-type data in candidate split columns"],"tags":["cdc","type-mismatch","chunk-splitting"],"backgroundTag":"type-mismatch","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}