{"record":{"id":"63e085b5638d2952","repo":"apache/seatunnel","slug":"decimal-scale-exceeds-maximum-truncating-to","errorCode":null,"errorMessage":"DECIMAL scale {} exceeds maximum {}, truncating to {}","messagePattern":"DECIMAL scale (.+?) exceeds maximum (.+?), truncating to (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/duckdb/DuckDBTypeConverter.java","lineNumber":211,"sourceCode":"    private void handleDecimalType(\n            PhysicalColumn.PhysicalColumnBuilder builder, BasicTypeDefine typeDefine) {\n        long precision =\n                typeDefine.getPrecision() != null ? typeDefine.getPrecision() : DEFAULT_PRECISION;\n        int scale = typeDefine.getScale() != null ? typeDefine.getScale() : DEFAULT_SCALE;\n\n        if (precision > MAX_PRECISION) {\n            log.warn(\n                    \"DECIMAL precision {} exceeds maximum {}, truncating to {}\",\n                    precision,\n                    MAX_PRECISION,\n                    MAX_PRECISION);\n            precision = MAX_PRECISION;\n        }\n        if (scale < 0) {\n            log.warn(\"DECIMAL scale {} is negative, setting to 0\", scale);\n            scale = 0;\n        } else if (scale > MAX_SCALE) {\n            log.warn(\n                    \"DECIMAL scale {} exceeds maximum {}, truncating to {}\",\n                    scale,\n                    MAX_SCALE,\n                    MAX_SCALE);\n            scale = MAX_SCALE;\n        }\n\n        if (scale <= 0) {\n            builder.dataType(new DecimalType((int) precision, 0));\n        } else {\n            builder.dataType(new DecimalType((int) precision, scale));\n        }\n        builder.columnLength(precision);\n        builder.scale(scale);\n    }\n\n    @Override\n    public BasicTypeDefine reconvert(Column column) {","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/duckdb/DuckDBTypeConverter.java#L193-L229","documentation":"Warning from DuckDBTypeConverter.handleDecimalType: the DECIMAL scale exceeds the dialect's MAX_SCALE, so scale is truncated to MAX_SCALE. Extra fractional digits will be lost (rounded) when data flows through the converted column definition.","triggerScenarios":"convert called on a BasicTypeDefine with getScale() > MAX_SCALE, e.g. DECIMAL(30,20) when the dialect max scale is lower.","commonSituations":"High-precision financial data (scale > 12, etc.) synced from sources like MySQL DECIMAL(65,30) or Postgres NUMERIC with large scale into DuckDB.","solutions":["Round/cast the source column to the supported scale: CAST(col AS DECIMAL(p, MAX_SCALE)).","If full precision is required, transport the value as string and handle decimals downstream.","Check the connector's MAX_SCALE constant and use a compatible source schema.","Accept the truncation if the extra digits are insignificant for your use case."],"exampleFix":"// before\nSELECT rate FROM fx; -- DECIMAL(30,20)\n// after\nSELECT CAST(rate AS DECIMAL(30,12)) AS rate FROM fx; -- within dialect MAX_SCALE","handlingStrategy":"validation","validationCode":"if (scale > MAX_SCALE) {\n  sql = \"SELECT CAST(col AS DECIMAL(\" + precision + \",\" + MAX_SCALE + \")) AS col FROM ...\";\n}","typeGuard":"boolean isDuckDbSafeScale(DecimalType t) { return t.getScale() <= MAX_SCALE; }","tryCatchPattern":null,"preventionTips":["Check source DECIMAL scales against the dialect max before configuring the job.","Cast to a safe scale upstream so rounding is explicit and controlled.","If exact high-scale values are required, transport as string."],"tags":["jdbc","duckdb","decimal","scale"],"backgroundTag":"value-out-of-range","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}