{"record":{"id":"a8fe63f54a19116a","repo":"apache/seatunnel","slug":"the-decimal-column-type-decimal-is-out-o-a8fe63","errorCode":null,"errorMessage":"The decimal column {} type decimal({},{}) is out of range, which is scale less than 0, it will be converted to decimal({},{})","messagePattern":"The decimal column (.+?) type decimal\\((.+?),(.+?)\\) is out of range, which is scale less than 0, it will be converted to decimal\\((.+?),(.+?)\\)","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/phoenix/PhoenixTypeConverter.java","lineNumber":237,"sourceCode":"                            precision,\n                            scale);\n                } else if (precision > MAX_PRECISION) {\n                    scale = (int) Math.max(0, scale - (precision - MAX_PRECISION));\n                    precision = MAX_PRECISION;\n                    log.warn(\n                            \"The decimal column {} type decimal({},{}) is out of range, \"\n                                    + \"which exceeds the maximum precision of {}, \"\n                                    + \"it will be converted to decimal({},{})\",\n                            column.getName(),\n                            decimalType.getPrecision(),\n                            decimalType.getScale(),\n                            MAX_PRECISION,\n                            precision,\n                            scale);\n                }\n                if (scale < 0) {\n                    scale = 0;\n                    log.warn(\n                            \"The decimal column {} type decimal({},{}) is out of range, \"\n                                    + \"which is scale less than 0, \"\n                                    + \"it will be converted to decimal({},{})\",\n                            column.getName(),\n                            decimalType.getPrecision(),\n                            decimalType.getScale(),\n                            precision,\n                            scale);\n                } else if (scale > MAX_SCALE) {\n                    scale = MAX_SCALE;\n                    log.warn(\n                            \"The decimal column {} type decimal({},{}) is out of range, \"\n                                    + \"which exceeds the maximum scale of {}, \"\n                                    + \"it will be converted to decimal({},{})\",\n                            column.getName(),\n                            decimalType.getPrecision(),\n                            decimalType.getScale(),\n                            MAX_SCALE,","sourceCodeStart":219,"sourceCodeEnd":255,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/dialect/phoenix/PhoenixTypeConverter.java#L219-L255","documentation":"When mapping a decimal column back to Phoenix, a negative scale is not representable, so the converter logs this warning and sets the scale to 0 (after the precision fixes above). The resulting Phoenix column is a plain integer-scaled decimal; fractional data may be rounded on write.","triggerScenarios":"PhoenixTypeConverter.reconvert() on a DecimalType whose scale is negative (e.g. DecimalType(10,-3) as produced by some systems to mean thousands rounding), or a scale driven negative by the precision-clamping branch when precision was drastically reduced.","commonSituations":"Cross-engine schema exchange (Spark/Flink-style negative-scale decimals) feeding a Phoenix sink; heavily reduced precision columns where scale was decremented below 0.","solutions":["Ensure the source decimal has a non-negative scale in the catalog schema.","Explicitly round/transform the column to scale >= 0 upstream (e.g. CAST(col AS DECIMAL(10,0))).","Inspect the warning to identify the column and verify scale 0 is acceptable for your data.","If precision clamping caused this, start with a smaller, valid precision so scale is never decremented below 0."],"exampleFix":"// before\nnew DecimalType(10, -3);\n// after\nnew DecimalType(10, 0); // round value upstream first","handlingStrategy":"validation","validationCode":"DecimalType dt = (DecimalType) col.getDataType();\nif (dt.getScale() < 0) {\n    col = CatalogColumn.of(col.getName(), new DecimalType(dt.getPrecision(), 0), col.isNullable(), col.getDefaultValue());\n}","typeGuard":"boolean hasNonNegativeScale(CatalogColumn c) {\n    return c.getDataType() instanceof DecimalType\n        && ((DecimalType) c.getDataType()).getScale() >= 0;\n}","tryCatchPattern":null,"preventionTips":["Round values upstream before the sink when using negative-scale semantics","Keep source decimal scales non-negative in catalog schemas","Audit cross-engine schemas (Spark/Flink) for negative-scale decimals"],"tags":["jdbc","phoenix","decimal","scale","type-conversion"],"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-14T05:17:10.506Z"}