Repository navigation
UniqApacheHll fixes based on feedback - #2544
Conversation
Brings the implementation of ClickHouse#124667 to this branch: - the third parameter `estimator` (`'DEFAULT'` or `'COMPOSITE'`), the second computes the estimate from the registers of the sketch only, so it does not depend on the order of the inserts and of the merges; - a state that is read keeps the sketch as it was written, and a mixed state is merged in the order in which it is folded; - states of any parameters have one normalized state type; - the bytes of a `UUID` do not depend on the byte order of the host; - the function is marked as order dependent and is not registered on big-endian platforms; - the documentation tells how to hash `UInt8`, `UInt16` and `UInt32` like the C++ library. Related: ClickHouse#124667 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: UnamedRus <dtitmoav@gmail.com>
…Int` A sketch that another system writes, for example Spark into Parquet, has no length in front of it, while the state of `uniqApacheHLL` stores its sketch as a `VarUInt` length and the bytes. `CAST` of such a sketch to `AggregateFunction(uniqApacheHLL, ...)` fails with `CORRUPTED_DATA`, and `toString` of a state gives bytes that the other system cannot read. `addVarUIntLengthPrefix` puts the length of a string in front of it, `removeVarUIntLengthPrefix` takes it off and throws an exception when the length is not complete or is not the number of the bytes that follow, and `toVarUInt` encodes one unsigned number. The length is read as the `RowBinary` reader reads it. Related: ClickHouse#124667 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: UnamedRus <dtitmoav@gmail.com>
…o it A state can hold a union and a sketch of inserts that came after a merge, for example when the rows of the tail of a block are added to a state that has already merged the lookup tables of the block, as the aggregation by a `UInt8` key does. `merge` took the new sketches first and folded the pending sketch at its end, so the older rows came after the newer ones. As the HIP estimate and the bytes of the sketch depend on this order, the pending rows are now folded into the union before the sketches are taken. The result of the default estimator can still differ with the size of the blocks, since the lookup tables merge the rows in another order; the composite estimator does not, and a test checks it. Related: ClickHouse#124667 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: UnamedRus <dtitmoav@gmail.com>
Related: ClickHouse#124667 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: UnamedRus <dtitmoav@gmail.com>
The constant exists in the `VarInt.h` of upstream master only, so the function did not compile on this branch. It is defined in the file under another name, so that it does not clash when the branch merges upstream. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Signed-off-by: UnamedRus <dtitmoav@gmail.com>
Signed-off-by: Andrew Xie <dev@xie.is>
|
|
||
| for (size_t row = 0; row < input_rows_count; ++row) | ||
| { | ||
| const std::string_view value = column.getDataAt(row); |
There was a problem hiding this comment.
AI audit uncovered:
removeVarUIntLengthPrefix throws on a Nullable(String) column that contains any NULL.
A NULL is stored as an empty nested string. The result type is Nullable(String), and with short_circuit_function_evaluation_for_nulls_threshold = 1 the default null wrapper still runs executeImpl on those rows, so getDataAt is '' and this throws INCORRECT_DATA. One null fails the whole batch.
SELECT removeVarUIntLengthPrefix(if(number = 0, unhex('03616263'), CAST(NULL, 'Nullable(String)'))) FROM numbers(2)Skip null rows and decode only the rest. The constant-NULL test does not hit this path.
There was a problem hiding this comment.
Fixed, the function now skips NULL rows, decodes the rest, and wraps result in Nullable
Signed-off-by: Andrew Xie <dev@xie.is>
CI triage (short summary)No blockers. Nothing that failed was caused by this pull request. Head
The fast test and the amd debug stateless suites passed, which is where the new |
|
CI looks fine. AI audit returned no defects. #2545 which is this PR but for 26.8, has CI run aggregate functions 1/2/3 which are passing for the LGTM |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Add new functions
addVarUIntLengthPrefix,removeVarUIntLengthPrefix, andtoVarUIntto add or strip the length prefix so raw Apache DataSketches can be read asuniqApacheHLLstates and exported back. New optional third parameterestimatorforuniqApacheHLLwith values 'DEFAULT' or 'COMPOSITE'. 'COMPOSITE' gives a result not dependent on the order of inserts and merges.Documentation entry for user-facing changes
...
CI/CD Options
Exclude tests:
Regression jobs to run: