{"record":{"id":"75091c2fe3c10f8e","repo":"prestodb/presto","slug":"not-supported-75091c","errorCode":"NOT_SUPPORTED","errorMessage":"Could not read unscaled value into a short decimal from column ","messagePattern":"Could not read unscaled value into a short decimal from column ","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/plain/FixedLenByteArrayShortDecimalPlainValuesDecoder.java","lineNumber":73,"sourceCode":"        int extraBytesLength = typeLength - Long.BYTES;\n        byte[] inputBytes = input.getByteArray();\n        int inputBytesOffset = input.getByteArrayOffset();\n        for (int i = offset; i < offset + length; i++) {\n            checkBytesFitInShortDecimal(inputBytes, inputBytesOffset, extraBytesLength, columnDescriptor);\n            values[i] = getShortDecimalValue(inputBytes, inputBytesOffset + extraBytesLength, Long.BYTES);\n            inputBytesOffset += typeLength;\n        }\n        input.skip(length * typeLength);\n    }\n\n    public static void checkBytesFitInShortDecimal(byte[] bytes, int offset, int length, ColumnDescriptor descriptor)\n    {\n        int endOffset = offset + length;\n        // Equivalent to expectedValue = bytes[endOffset] < 0 ? -1 : 0\n        byte expectedValue = (byte) (bytes[endOffset] >> 7);\n        for (int i = offset; i < endOffset; i++) {\n            if (bytes[i] != expectedValue) {\n                throw new PrestoException(NOT_SUPPORTED, \"Could not read unscaled value into a short decimal from column \" + descriptor);\n            }\n        }\n    }\n\n    @Override\n    public void skip(int length)\n    {\n        checkArgument(length >= 0, \"invalid length %s\", length);\n        input.skip(length * typeLength);\n    }\n\n    @Override\n    public long getRetainedSizeInBytes()\n    {\n        return INSTANCE_SIZE;\n    }\n}\n","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parquet/src/main/java/com/facebook/presto/parquet/batchreader/decoders/plain/FixedLenByteArrayShortDecimalPlainValuesDecoder.java#L55-L91","documentation":"FixedLenByteArrayShortDecimalPlainValuesDecoder stores fixed-length BINARY decimals as short decimals; a short decimal must fit in 8 bytes, so values longer than 8 bytes must be sign-extension padding. checkBytesFitInShortDecimal checks that all high bytes equal the sign bit; if any middle byte differs from the expected sign-extension byte, the value does not fit a short decimal and a PrestoException (NOT_SUPPORTED) is thrown naming the column descriptor.","triggerScenarios":"readNext() -> checkBytesFitInShortDecimal on a fixed-length byte array longer than 8 bytes where bytes[0..endOffset) are not all equal to the sign-extension value, i.e. the unscaled decimal magnitude exceeds 64 bits.","commonSituations":"DECIMAL(19+) fixed-length columns read as short decimal; a genuinely large unscaled value (e.g. 10^20) stored in a file whose schema claims short precision; schema drift between file annotation and table definition.","solutions":["Confirm the column's DECIMAL precision in the Parquet schema; if > 18, read it as a long decimal","Re-map the column type in the connector/table definition so wide decimals use the long-decimal decoder","Rewrite the file with precision <= 18 after verifying values fit in 64 bits","If the value truly overflows 64 bits, the short-decimal representation is impossible — change the target type, not the file"],"exampleFix":"// before: reading DECIMAL(25,0) FLBA column through the short-decimal decoder\n// after: declare/read the column as DECIMAL(25,0) so the long-decimal path is used\n//   CREATE TABLE t (col DECIMAL(25,0));","handlingStrategy":"validation","validationCode":"// If the FLBA length > 8, values must be sign-extended small decimals; verify declared precision:\n// prec <= 18 required for the short-decimal path\n// parquet-tools schema file.parquet | grep DECIMAL","typeGuard":"boolean flbaFitsShortDecimal(int fixedLenBytes) { return fixedLenBytes <= 8; }","tryCatchPattern":"try {\n    decoder.readNext(length);\n} catch (PrestoException e) {\n    if (e.getErrorCode() == NOT_SUPPORTED && e.getMessage().contains(\"Could not read unscaled value into a short decimal\")) {\n        // re-read column with long-decimal decoder\n    }\n    throw e;\n}","preventionTips":["Declare long-decimal types for FLBA columns longer than 8 bytes","Keep file DECIMAL annotations and table schemas in sync","Validate fixed-length decimal columns at ingest","Reject or rewrite files whose values genuinely exceed 64-bit unscaled range"],"tags":["parquet","decimal","not-supported"],"backgroundTag":"decimal-precision-mismatch","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}