{"record":{"id":"ddfbe66d525edc08","repo":"prestodb/presto","slug":"value-is-not-null-but-decimal-stream-is-not-presen","errorCode":null,"errorMessage":"Value is not null but decimal stream is not present","messagePattern":"Value is not null but decimal stream is not present","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/reader/DecimalBatchStreamReader.java","lineNumber":113,"sourceCode":"        if (!rowGroupOpen) {\n            openRowGroup();\n        }\n\n        seekToOffset();\n\n        if (decimalStream == null && scaleStream == null && presentStream != null) {\n            presentStream.skip(nextBatchSize);\n            Block nullValueBlock = RunLengthEncodedBlock.create(type, null, nextBatchSize);\n            readOffset = 0;\n            nextBatchSize = 0;\n            return nullValueBlock;\n        }\n\n        BlockBuilder builder = type.createBlockBuilder(null, nextBatchSize);\n\n        if (presentStream == null) {\n            if (decimalStream == null) {\n                throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), \"Value is not null but decimal stream is not present\");\n            }\n            if (scaleStream == null) {\n                throw new OrcCorruptionException(streamDescriptor.getOrcDataSourceId(), \"Value is not null but scale stream is not present\");\n            }\n\n            for (int i = 0; i < nextBatchSize; i++) {\n                long sourceScale = scaleStream.next();\n                if (type.isShort()) {\n                    long rescaledDecimal = Decimals.rescale(decimalStream.nextLong(), (int) sourceScale, type.getScale());\n                    type.writeLong(builder, rescaledDecimal);\n                }\n                else {\n                    Slice decimal = UnscaledDecimal128Arithmetic.unscaledDecimal();\n                    Slice rescaledDecimal = UnscaledDecimal128Arithmetic.unscaledDecimal();\n\n                    decimalStream.nextLongDecimal(decimal);\n                    rescale(decimal, (int) (type.getScale() - sourceScale), rescaledDecimal);\n                    type.writeSlice(builder, rescaledDecimal);","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/reader/DecimalBatchStreamReader.java#L95-L131","documentation":"DecimalBatchStreamReader.readBlock throws OrcCorruptionException when the present stream is null (meaning all values are treated as non-null) but the DECIMAL stream holding the numeric values is absent. A decimal column with non-null values must contain both its decimal data stream and a scale stream.","triggerScenarios":"readBlock on a DECIMAL column where presentStream == null and decimalStream == null — i.e. the stripe has no decimal data stream though the reader assumes all rows are non-null.","commonSituations":"Truncated ORC files missing decimal streams; files written by buggy writers that skip empty-seeming streams; corrupt footers/stripe metadata mapping streams incorrectly.","solutions":["Regenerate the ORC file from source data with a reliable writer.","Inspect stripe metadata with orc-tools to confirm the missing decimal stream.","Verify the writer closes files completely; avoid reading in-progress files.","Upgrade Presto/ORC reader and writer versions to rule out known stream-writing bugs."],"exampleFix":"// before\nSELECT dec_col FROM corrupt_table; // OrcCorruptionException\n// after\n-- rewrite the file, or guard:\ntry { readDecimal() } catch (OrcCorruptionException e) { fail/skip split }","handlingStrategy":"try-catch","validationCode":"// confirm decimal DATA and SECONDARY streams exist: orc-tools meta file.orc","typeGuard":null,"tryCatchPattern":"try { block = streamReader.readBlock(); } catch (OrcCorruptionException e) { failQueryWithGuidance(e); }","preventionTips":["Write decimals with standard Hive/Spark ORC writers","Validate stripe metadata before serving tables","Keep reader/writer ORC library versions current"],"tags":["orc","corruption","decimal","missing-stream","presto"],"backgroundTag":"orc-corruption-missing-stream","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}