Repository navigation
Harden the native ORC reader and writer against malformed input - #129345
Conversation
Use checked arithmetic when decoding the nanoseconds and adjusting the seconds of ORC timestamps, and reject malformed values. Malformed nanoseconds in the timestamp statistics disable the filter pushdown instead of overflowing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Compare the dictionary threshold as a double, and reject `DateTime64` values whose seconds or millisecond statistics overflow. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The `LowCardinality` path returned empty strings for non-null rows of an empty dictionary, while the eager path rejected them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Size the decompression buffer by the maximum ratio of the codec, and grow the string offsets and bytes as they are decoded, so a small file cannot allocate the whole compression block or a huge dictionary up front. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Validate all stripes once when reading the tail, and check every stream length while summing the offsets, including the streams of the columns that are not read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Round up the number of row groups without overflowing, and check it against the row indexes before allocating. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Limit the column statistics, stripe statistics, column encodings, row index entries and bloom filters by the numbers of columns, stripes and row groups, so a small metadata message cannot allocate many objects. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [f0c5420] Summary: ✅
AI ReviewSummaryReviewed head Consumers checked for the normalized timestamp representation:
Missing context / blind spots
Final VerdictStatus: ✅ Approve. No code changes requested; normal CI validation remains pending. |
The native ORC reader and writer are built in the fast test, only S3 is not. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
ORC is not built in the fast test after all: it does not check out snappy, and the ORC writer test failed there. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Trust the sizes from the chunk headers only up to the maximum compression ratio of the codec, so a few bytes cannot request the whole compression block. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The writer stored negative sub-millisecond nanoseconds in the statistics, which disabled the pruning, and the literals and statistics were compared with different signs of the nanoseconds, which could prune matching rows. Round the milliseconds down and keep the nanoseconds non-negative everywhere, as in the reference implementation. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Read the non-null values at once and move them to their rows, instead of decoding every value byte by byte. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units23 translation units recompiled, 85 s compile time in total, 23 of them have a recent master baseline. |
The C++ writer of ORC rounds the negative milliseconds toward zero, while the Java writer rounds them down. Probe both keys, so the normalized literals keep the matching rows in files from either writer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry-picked from #129345. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Hardening of the native ORC reader and writer, a follow-up to the replacement of the apache/orc library. Malformed files could cause signed overflows in the timestamp decoding and in the timestamp statistics used by the filter pushdown, silently decode an empty dictionary as empty strings with lazy dictionaries, allocate the declared compression block, codec chunk size or dictionary size before validating the data, and wrap around the stripe, stream and row group arithmetic. The writer had undefined conversions for a huge
output_format_orc_dictionary_key_size_thresholdand for extremeDateTime64values. The repeated objects of the metadata are now limited by the numbers of columns, stripes and row groups.The timestamps before the epoch are now normalized in the statistics and in the literals of the filter pushdown, as in the reference implementation: the writer stored negative sub-millisecond nanoseconds, and the comparison could prune matching rows. Nullable floats are read with one copy instead of byte by byte.
cc @alexey-milovidov
Closes: #129500
Related: #127690
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Workflow [PR]
Sync PR [sync-upstream/pr/129345]
Version info
26.11.1.1532-master(included in26.11and later)