Repository navigation
Support the Parquet ALP encoding - #125135
Conversation
…ormat master This brings the `ALP` encoding and the `FILE` logical type into the generated Thrift code used by the native Parquet reader and writer. Related: ClickHouse/arrow#87 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The tree is identical; this points the submodule at the commit on the `ClickHouse/apache-arrow-25.0.0` branch. Related: ClickHouse/arrow#87 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The native Parquet reader decodes data pages with the `ALP` (Adaptive Lossless floating-Point, encoding 10) encoding, as specified in https://github.com/apache/parquet-format/blob/master/AlpEncoding.md Every field of the page is validated, so malformed pages throw `INCORRECT_DATA`. Skipping values doesn't touch the skipped vectors, thanks to the offset array. The writer encodes `Float32` and `Float64` columns with `ALP` when the new setting `output_format_parquet_use_alp_encoding` is enabled (it is disabled by default, as the specification recommends for now). The parameters are chosen with the two-level sampling from the paper. Such columns are written without a dictionary, and a page for which `ALP` would be bigger than `PLAIN` is written as `PLAIN`. `ParquetMetadata` shows `ALP` instead of `UNDEFINED`, which Arrow reports for all the encodings it doesn't know. The tests read `alp_extended.zstd.parquet` from apache/parquet-testing (written by the Arrow C++ implementation) and a file written by arrow-rs with data pages v2, and compare the values bit-exactly. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… data files Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [690d72f] Summary: ✅
AI ReviewSummaryAdds native Parquet Missing context / blind spots
Final VerdictStatus: ✅ Approve. |
Validate that the `ALP` vectors are stored back to back after the offset array (the first offset must be `num_vectors * 4` and each vector must end where the next one begins), skip choosing the candidate parameters for pages without values, and initialize `Candidate::wins` (`cppcoreguidelines-pro-type-member-init`). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Keep the message of the first-offset check as `Invalid offset of ALP vector 0` and cover a gap before the first vector and a wrong offset of the second vector. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Observation, not fixed in this pass: the evenly-spaced sampling in |
Build profile diff (arm_release)Comparing Binary sizes
The official master build is compiled with Object file sizes458 object files changed (+362.75 KiB total), 1 added.
719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Compile time of recompiled translation units
|
`takeSample` took the values at a fixed stride, so the sample aliased with periodic data: for values with a step of 0.25 the 64-value sample of a vector (stride 16) and the 256-value sample for the candidates (stride 4) contained only the integers. The parameters chosen on such a sample made 3/4 of a vector exceptions, and the pages were written as `PLAIN`. Now one value is taken from each block of `stride` values at a pseudo-random position inside the block. This also lets `ALP` encode the `d_large` column of the round trip test, and makes `f_decimal` slightly smaller. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125135&sha=6d49a80de76afda458caae72b4243f7439f92763&name_0=PR&name_1=AST%20fuzzer%20%28amd_debug%2C%20targeted%29 ( |
|
#125126 is the fix. This is the same reduced I checked it with the fuzzer's repro ( |
…constructor The check that each vector ends where the next one begins was done in `decodeVector`, so it did not run for vectors that were skipped, and the end of the last vector was not compared with the end of the page. Now `AlpPage` walks the vector headers when it is constructed: each offset must be exactly the end of the previous vector, the bit width and the number of exceptions are validated there, and the last vector must end exactly at the end of the page. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ed vectors On ties the encoder preferred the bigger exponent and factor, as in the paper. The ties are mostly between combinations with the same difference of the exponent and the factor, which give the same integers, but the extra multiplications by inexact powers of ten add rounding errors: for `Float32` values with a step of 0.25, (2, 0) makes no exceptions while (6, 4) makes them for 5% of the values, and a sample may not contain them. This made `05366_parquet_alp_encoding_periodic_values` flaky depending on the randomized `max_block_size`. Prefer the smaller exponent and factor instead. Address review: the sampled vectors of a page are now chosen at a pseudo-random position inside each block of vectors, like the values in `takeSample`, and a page that does not compress with the candidates of the previous pages is tried again with the candidates chosen from itself. Give the size check of the test some margin for the small randomized blocks. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125135&sha=be0f0a5f841d2afc33dc3c4b4216d8c3e966cd3b&name_0=PR&name_1=Stateless%20tests%20%28amd_binary%2C%20flaky%20check%29 #125135 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 @groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125135&sha=df119dd7b8557cd3906c09630cdd45ac47cdf73b&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20s3%20storage%2C%20DBReplicated%2C%20sequential%29 ( |
|
Acknowledged. I'm investigating So far: the waits in the test only require 1 row and then 11 rows (inherited from the original The 2026-10-06 failure in #124210 has a different signature ( |
|
Fix: #126074. The waits now require all 10 and 20 rows; with lines 19 and 20 written late, the old thresholds reproduce the truncated output 5/5 and the new ones pass. |
The release branch for 26.10 was created in #126122 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing them The waits before the two SELECTs required `count() >= 1` and `count() >= 11`, which only proves that one FileLog batch was committed. The second round appends lines 1..20 with separate writes, so a batch can start in the middle of the loop and read a prefix, with the rest arriving in the next batch. On `Stateless tests (arm_binary, s3 storage, DBReplicated, sequential)` the SELECT then ran between the part with 11..18 and the part with 19, 20, and printed 1..18 (PR ClickHouse#125135) or 1..19 (PR ClickHouse#125433). Wait for every row the following SELECT prints instead (10 and 20). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…encoding The test was added on master and pins `data/alp_extended.zstd.parquet` as `INCORRECT_DATA`, because master does not support the `ALP` encoding. This PR adds the support, so the file is now read successfully. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=125135&sha=abb8c02fbf1f3901947b20e4e2659d3af0f7f41a&name_0=PR #125135 Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged master. Remaining failures on
The |
…names
Rename `AlpEncoding.{h,cpp}` to `ALPEncoding.{h,cpp}`, and `AlpTraits`,
`AlpPage`, `AlpDecoder`, `AlpPageEncoder`, `AlpEncoder`, `makeAlpDecoder`,
`makeAlpFloatEncoder`, `makeAlpDoubleEncoder` accordingly. The names from
the specification (`AlpEncoding.md`, `AlpInfo`) are kept as they are.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pressionCodecALP` Related: #125135 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
alexey-milovidov
left a comment
There was a problem hiding this comment.
Now all good.
…out-arrow Master added the `ALP` encoding of Parquet (#125135), whose writer was an adapter to `parquet::TypedEncoder` and whose reader used `arrow::internal::unpack`. Reconcile it with the native writer of this branch: - `ALPEncoder` now has the same interface as `PlainEncoder` and `DictionaryEncoder` (`put`, `estimatedDataEncodedSize`, `flush`), and `lastPageEncoding` instead of `encoding`. - The `ALP` decoder uses the native `unpackBits`, which is now declared in `Decoding.h`. - Test `04708_functions_to_subcolumns_file_storages`: keep both the removal of the `no-fasttest` tag (this branch) and of `SET enable_analyzer` (master).
…Metadata` format Thrift stores the footer's raw `i32` values of `ColumnMetaData.encodings` into `std::vector<parquet::format::Encoding::type>`. Arrow's `encodings()` maps unknown values to `UNDEFINED` (`LoadEnumSafe`), and for those the fallback added by ClickHouse#125135 looks the Thrift value up in `_Encoding_VALUES_TO_NAMES`. `find` takes `const int &`, so the enum element is loaded; a value outside the enum's range is undefined behavior, and ASan/UBSan builds abort: ParquetMetadataInputFormat.cpp:361:85: runtime error: load of value 4294967295, which is not a valid value for type 'const parquet::format::Encoding::type' Look up the raw integer with `thriftEnumToInt`, the memcpy-based helper the native reader already uses to validate footer and page-header enums. It moves unchanged from `Reader.cpp` into `Parquet/ThriftUtil.h` so both can use it. The output is the same for every input: unknown values still show as `UNDEFINED`, and `ALP` still resolves through the fallback. The test patches the `encodings` list of a file written by ClickHouse. The native writer stores each `ColumnChunk` twice (after the chunk's data and in the footer), and Arrow reads only the footer, so every patch uses `replaceAll` and the test checks that the unpatched bytes are gone. Closes ClickHouse#131694 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Support the Parquet
ALP(Adaptive Lossless floating-Point) encoding ofFLOATandDOUBLEcolumns (https://github.com/apache/parquet-format/blob/master/AlpEncoding.md) in the native Parquet reader and writer.The first commits update
contrib/arrowto have theALPencoding in the generated Thrift code (sync ofparquet.thriftwith apache/parquet-format master).Reading:
ALPpages are decoded with full validation of the page and vector headers (malformed data throwsINCORRECT_DATA); bit-unpacking uses Arrow's SIMDunpack; skipped vectors are not decoded.Writing: the new setting
output_format_parquet_use_alp_encoding(disabled by default, as the specification recommends for this encoding in Preview) writesFLOAT/DOUBLEcolumns withALP. The encoder does the two-level (exponent, factor) search from the paper. A page that would be larger thanPLAINis written asPLAIN. Unlike parquet-java / Arrow / arrow-rs, which useALPonly as a fallback after dictionary encoding, with this setting float columns are written withALPdirectly: in ClickHouse dictionary encoding falls back only when the dictionary exceedsoutput_format_parquet_max_dictionary_size, so most column chunks would never getALP.ParquetMetadatanow showsALPinencodings(Arrow's enum doesn't have it).On 50M rows of decimal-like doubles with zstd, the file is 118 MB with
ALPvs. 209 MB withPLAIN, and reading is slightly faster.Interoperability: tests decode
alp_extended.zstd.parquetfrom apache/parquet-testing (written by Arrow C++) and a file written by arrow-rs bit-exactly; arrow-rs also reads files written by ClickHouse bit-exactly. Only compression mode 0 is supported (as defined by the specification).Related: ClickHouse/arrow#87
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Support the
ALPencoding of floating-point columns in Parquet: such files can be read, and can be written with the new settingoutput_format_parquet_use_alp_encoding.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/125135]
Version info
26.11.1.451-master(included in26.11and later)