Repository navigation
Read the change data feed of Delta Lake with our own Parquet reader - #130062
alexey-milovidov wants to merge 28 commits into
Conversation
The change data feed of a Delta Lake table (`delta_lake_snapshot_start_version`) was read by delta-kernel-rs itself: `table_changes_scan_execute` read the data files with `parquet-rs` and its own object store client, in one stream, and `ReadFromDeltaLakeTableChangesStep` converted the Arrow batches. Now delta-kernel-rs is used only for the metadata: it lists the data files of the change data feed and resolves their deletion vectors (new FFI `table_changes_scan_files_*` in the fork), and the files are read like the data files of a snapshot, by `ReadFromObjectStorageStep`, in parallel, with our Parquet reader and caches. `ReadFromDeltaLakeTableChangesStep` is removed. Each file comes with the transform from the kernel, which adds the partition values and the `_change_type`, `_commit_version` and `_commit_timestamp` columns. For that: - `ExpressionVisitor` supports the "replace" and "drop" field transforms, which the kernel uses for `_change_type` of CDC files, where it is a physical column. - `DataLakeObjectMetadata::additional_file_columns`: CDC files read `_change_type` from the file, while other data files do not have it. - `DataLakeObjectMetadata::selected_rows`: a pair of deletion vectors of a file selects the changed rows instead of excluding the deleted ones; `DeletionVectorTransform` supports both. The submodule `contrib/delta-kernel-rs` is updated to the branch `cdf-scan-files` of the fork. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [0322c43] AI ReviewSummaryRoutes Delta Lake change data feed files through Consumer tracing covered selection bitmaps in Findings
Missing context / blind spots
Final VerdictStatus: Confirm the Cloud registration counterpart and provide focused evidence for serialized reads and older receivers. The previously fixed public-code findings do not need new inline threads. |
- Update `contrib/delta-kernel-rs` to the merge of ClickHouse/delta-kernel-rs#21 in the branch `ClickHouse/v0.23.0` of the fork. - Fix `bugprone-optional-value-conversion` in `getChangeDataFeedVersionRange`. - Copy the column mapping of the snapshot instead of keeping a reference: the snapshot can be evicted from the cache of snapshots while the files are listed. - Do not use the TopN query condition cache for the change data feed: the pinned snapshot does not identify the data files of a range of versions. - Support subcolumns (e.g. `struct_col.field`) with the schema transform of a data lake object: the format reads a subcolumn by itself, so pass it through the transform, or extract it from the column that the transform makes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # src/Storages/ObjectStorage/StorageObjectStorageSource.cpp
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes46 object files changed (+139.95 KiB total), 0 added.
717 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 units395 translation units recompiled, 2218 s compile time in total, 395 of them have a recent master baseline. Median compile-time ratio to the baselines is ×0.95 (machine-speed difference or a change affecting every TU); per-TU deltas below are relative to that ratio. Symbol sizes
|
delta-kernel-rs passes the most significant 64 bits in `value_ms` and the least significant in `value_ls`, but `ExpressionVisitor::visitDecimalLiteral` swapped them: a `Decimal(25, 2)` partition value `1.23` was read as `22689495210662748487.68`. The change data feed now evaluates the transform of each file (with the partition values) with this visitor. Addresses review: #130062 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
With column mapping, the transform of a data file (of a snapshot or of the change data feed) had the physical names of the columns, but the logical names of the fields of structs, while the columns read from the file and the requested subcolumns use physical names: `t.x` is requested as `c-t.c-t-x`, which was not found in `c-t Tuple(x ...)`. Rename the fields with `replaceTypeNamesToPhysicalRecursively`, moved to `KernelUtils`. Addresses review: #130062 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…a transform - A CDC file of the change data feed reads the `_change_type` column in addition to the columns of the format header, but the filter info (with the key condition, which refers to columns by positions in the header it is built for) was shared with the other data files: `WHERE _commit_version >= 2` threw a `std::out_of_range` exception in `Parquet::Reader::prefilterAndInitRowGroups`. Make a copy of the filter info for such a file. - A requested subcolumn was passed through the transform by its full name even if the format did not read it by itself (e.g. `t.x` with `t`, or `t.x.null`, for which the format reads `t.x`): `NOT_FOUND_COLUMN_IN_BLOCK`. Output the column in storage of each requested column, and extract it from the longest column or subcolumn the transform outputs or the format reads. This also lifts the limitation of the subcolumns of partitioned tables in `05560_delta_lake_corpus`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130062&sha=6286e2160af09b9f104ece2f433b684245a00bd8&name_0=PR PR: #130062 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ageObjectStorageSource` https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130062&sha=ea2fcd1ff8f640048b994d3bae1f819e01b750f5&name_0=PR&name_1=Build%20%28arm_tidy%2C%204%2F4%29 #130062 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Resolve the conflict in `contrib/delta-kernel-rs`: master moved the submodule to a cherry-pick of the cbindgen target platform fix on the old pin, the PR to the merge of ClickHouse/delta-kernel-rs#21. Point it to the cbindgen fix cherry-picked onto the merge of #21 (branch `cdf-scan-files-cbindgen-target` of the fork). Not `ClickHouse/v0.23.0`, which builds `delta_kernel_ffi` only as a plain lib, while ClickHouse still links its staticlib through corrosion.
The data files of the change data feed are read in parallel now, so the rows of versions 1 and 2 can come in any order. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130062&sha=f88c55dbdf928a0a7cfbcabc6233ca4642a9caed&name_0=PR&name_1=Integration%20tests%20%28amd_asan_ubsan%2C%20db%20disk%2C%20targeted%29 #130062 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Master removed the `ActionsDAG.h` include from `DataLakeObjectMetadata.h` to recompile fewer translation units, and `NamesAndTypesList` was only available through it. Keep the header light: store `additional_file_columns` as a `shared_ptr` to a forward-declared `NamesAndTypesList`, null when there are no such columns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… the format Address review: the partition columns and the columns of the change data feed (`_change_type`, `_commit_version`, `_commit_timestamp`) are added by the schema transform of each data file, but the filter on them was still passed to the Parquet reader. A data file of `cdf-table-with-cdc-and-dvs` has an incidental physical `_change_type` column with only NULLs, so its statistics pruned the row whose change type is `delete` in version 10 before the transform replaced the column. `ReadFromFormatInfo::columns_added_after_format` lists such columns, and `getFormatFilter` drops the conjuncts on them, like for Hive partition and virtual columns. Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts: # contrib/delta-kernel-rs # src/Processors/QueryPlan/ReadFromObjectStorageStep.cpp
The listing of the change data feed joined every `add.path` to the table directory, so a table that references its data files by absolute URI (e.g. a shallow clone with `file:/...` or `s3a://...`) could not be read. Use `IKernelHelper::resolveDataFilePath`, as the snapshot read does, which also checks the access to the source. Address review: #130062 (comment) PRRT_kwDOA5dJV863FZJk Co-Authored-By: Claude Opus 5.5 <[email protected]>
…mFormatInfo` The new field changed the bytes of an existing query-plan payload unconditionally. Write and read it only at the step serialization version `SERIALIZATION_VERSION_WITH_COLUMNS_ADDED_AFTER_FORMAT`, so that at an older version the bytes are unchanged and the set is read as empty (the behavior before the field existed). The names are sorted, so the bytes do not depend on the order of the hash set. The step that serializes this structure (`ReadFromObjectStorage`) is registered outside of this repository, and has to register the new version to send the set. Address review: PRRT_kwDOA5dJV863FZJp Co-Authored-By: Claude Opus 5.5 <[email protected]>
…pinned Delta Lake metadata With `delta_lake_reload_schema_for_consistency`, `buildStorageMetadataFromState` replaced the schema of the change data feed with the schema of the snapshot, so `_change_type` and the other columns of the change data feed were unknown. Build the schema of the change data feed for its version range. Address review: PRRT_kwDOA5dJV863FZJv Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflicts: `TableSnapshot.cpp` - master added `[[nodiscard]]` to `DataObjectInfo`, which this branch moved to `DeltaLake/DataObjectInfo.h`; kept the move and added the attributes there. `ReadFromTableChangesStep.h` - removed in this branch, kept removed.
… data feed of Delta Lake Master enabled `modernize-use-nodiscard`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…lumn is requested The additional file columns of a data lake object (`_change_type` of a CDC file of the Delta Lake change data feed) were read only when the query requested the column itself. A request for a subcolumn such as `_change_type.size` did not read it, and the schema transform, which extracts the subcolumn from the column, threw `NOT_FOUND_COLUMN_IN_BLOCK`. Account for the column in storage of requested subcolumns and of the filter inputs. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
📊 Cloud Performance Report ✅ AI verdict: No query changed in a way this PR can account for. It reworks how the Delta Lake change data feed is read (it now goes through the object-storage file iterator) and touches only data-lake and object-storage code. ClickBench and TPC-H read MergeTree tables and never execute that code. The one flagged query, clickbench Q28 (-5.1%, 997.5 ms vs 1051.0 ms), stays not_sure: the result is borderline, the two tests disagree, and the baseline runs were noisy. There are no envelope-suppressed rows to check, and the era-split instability on clickbench Q22 and Q32 does not involve any flagged query. clickbenchFlagged queries (1 of 43)
Change = percent below ×2; the ratio of medians (×N faster/slower) beyond, where percent understates the scale. q-value = BH-FDR adjusted p; smaller is stronger evidence. MIRAI flags a query when q < fdr_q (default 0.10) — the value the verdict is based on. tpch_adapted_1_official🟢 No significant changes Debug info
|
Conflict in `DeltaLakeMetadataDeltaKernel::getTableChanges`: master added the session check (`checkSessionMayUseServerIdentityIgnoringSharedFlag`) to it, while this branch made the method private and removed its `context` argument. Kept the signature of the branch: all the callers (`getTableSchema`, `iterate`, `buildStorageMetadataFromState`) are entrypoints that do the check themselves. Removed the direct call of the now private method from `gtest_delta_kernel`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
…el predicate delta-kernel splits the name of a column of the predicate by dots into a path of struct fields, and the scan of the change data feed throws `Predicate references unknown column: birthday.null` for a filter on the null map of a `Nullable` column. `EnginePredicate` now gets the logical schema of the table and references a column only if it is a column of the table or a field of its struct; a comparison with any other subcolumn (`c.null`, `arr.size0`, `m.keys`) is visited as an untranslated (unknown) predicate, so it does not prune anything. The same applies to the scan of a snapshot, where the error was only logged and the whole predicate was lost. The scan of the change data feed also honors `delta_lake_enable_engine_predicate`. Co-Authored-By: Claude Fable 5.2 <[email protected]>
The test was added on master and pins `DeltaLakeScannedFiles = 0` for the change data feed, because delta-kernel-rs read its files by itself. In this branch they are read as the data files of a snapshot and counted: one file is scanned (the one with the inverted stats is not skipped, the other is pruned), as in the same query without `delta_lake_snapshot_start_version`. CI report: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130062&sha=04e8d56dc35708a72aa5b64d0ed1ca24b8c847f6&name_0=PR&name_1=Stateless%20tests%20%28amd_debug%2C%20parallel%29 PR: #130062 Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged
@groeneai, investigate the failure: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130062&sha=04e8d56dc35708a72aa5b64d0ed1ca24b8c847f6&name_0=PR&name_1=Performance%20Comparison%20%28arm_release%2C%20master_head%2C%207%2F8%29 and provide a fix in a separate PR. If the fix is already in progress, link it here. |
|
Acknowledged. I'm investigating the |
|
I agree that
So the query and the function have nothing to fix. A build becomes slow whenever its layout puts this code at that offset, which is 1 of the 64 possible offsets of a 64-byte aligned function in a 4 KiB page. The PR's diff only shifted where its build's code landed. The dashboard blocked this at a 2.0% threshold, while master's own builds of this query differ by about 8%. No fixing PR will follow. There has been no perf rerun yet: on e4f6811, |
Conflicts: - `DeltaLake/TableChanges.cpp`, `DeltaLake/TableChanges.h`: master dropped the `ffi` namespace of the `delta-kernel-rs` header (e3e07c4) in the code which this branch replaces. Kept the rewritten `TableChanges` of this branch and adapted it: the kernel names are global now, and the callback of `table_changes_scan_files_next` takes the transform as a nullable pointer instead of an `OptionalValue`. - `prepareReadingFromFormat.h`: kept both the new `hasDefaultOfColumnOrParent` / `defaultsDependOnTheirBlock` of master and `columns_added_after_format` of this branch. Co-Authored-By: Claude Fable 5.2 <[email protected]>
`readability-container-contains` failed the `arm_tidy` build: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130062&sha=e4f6811dd098a9539d492efb115051f7596832ed&name_0=PR&name_1=Build%20%28arm_tidy%2C%202%2F4%29 #130062 Co-Authored-By: Claude Fable 5.2 <[email protected]>
… schema inference too `DeltaLakeMetadataDeltaKernel::getTableSchema` opened a range without an end version through the latest commit, while `iterate`, `prepareReadingFromFormat` and `buildStorageMetadataFromState` end it at the pinned snapshot. With `delta_lake_snapshot_version` selecting a version before a commit which changes the schema, the query failed with `Start and end version schemas are different`. Use the same end version there. Co-Authored-By: Claude Fable 5.2 <[email protected]>
|
🕵 Merged
Checked locally on the merged tree: |
The change data feed of a Delta Lake table (
delta_lake_snapshot_start_version/delta_lake_snapshot_end_version) was read by delta-kernel-rs itself:table_changes_scan_executeread the data files withparquet-rsand the kernel's own object store client, in a single stream, andReadFromDeltaLakeTableChangesStepconverted the Arrow batches. This was the only place where the kernel read table data rather than metadata.Now delta-kernel-rs only lists the data files of the change data feed and resolves their deletion vectors (new FFI
table_changes_scan_files_*in the fork, ClickHouse/delta-kernel-rs#21). The files are read like the data files of a snapshot, byReadFromObjectStorageStep: in parallel, with our Parquet reader, filesystem cache and metadata caches, and with virtual columns such as_pathand_file.ReadFromDeltaLakeTableChangesStepis removed.Each file comes with the transform from the kernel, which adds the partition values and the
_change_type,_commit_versionand_commit_timestampcolumns:ExpressionVisitorsupports the "replace" and "drop" field transforms, used for_change_typeof CDC files, where it is a physical column.DataLakeObjectMetadata::additional_file_columns: CDC files read_change_typefrom the file, while other data files do not have it. It is read only when the query needs it, because a column not consumed by the schema transform would pass through it.DataLakeObjectMetadata::selected_rows: a pair of add/remove deletion vectors selects the changed rows instead of excluding the deleted ones;DeletionVectorTransformsupports both. Such files do not use the trivial count optimization.The change data feed is still not distributed between parallel replicas: the new per-file fields are not sent to replicas (sending an object with them throws a
LOGICAL_ERRORexception).This is the first step to move the metadata processing of Delta Lake out of delta-kernel-rs. The submodule points to the merge of ClickHouse/delta-kernel-rs#21 with the cbindgen target platform fix from master cherry-picked on top (branch
cdf-scan-files-cbindgen-targetof the fork). It is not the tip ofClickHouse/v0.23.0, because that branch now buildsdelta_kernel_ffionly as a plain lib, while ClickHouse still links its staticlib through corrosion.Subcolumns (e.g.
struct_col.field,t.x.null) are supported with the schema transform of a data lake object, also for a partitioned snapshot, which lifts the limitation oftype_widening_nestedin05560_delta_lake_corpus: the transform outputs the column in storage of a requested column, passes it through if the format reads it by itself, or extracts it from the longest column or subcolumn that the transform outputs or the format reads. With column mapping, the struct fields in the transform have physical names, as in the columns read from the files.Also fixed on the way:
ExpressionVisitorswapped the halves of aDecimal128literal (aDecimal(25, 2)partition value1.23was read as22689495210662748487.68), and a CDC file, whose header has the additional_change_typecolumn, now has its own copy of the filter info (the key condition refers to columns by position). The TopN query condition cache is not used for the change data feed, because the pinned snapshot does not identify the data files of a range of versions.Performance: a Delta Lake table with the change data feed enabled, 32 data files of 1M rows each (584 MB, written by ClickHouse), on local disk with the page cache warm,
clickhouse-localon a 96-core aarch64 machine shared with other builds; querySELECT count(), sum(v), uniqExact(s), countIf(_change_type = 'insert') FROM deltaLakeLocal(...) SETTINGS delta_lake_snapshot_start_version = 0, three runs each:max_threadsmax_threads = 1The results are the same. The old reader did not depend on
max_threads, because it read the files in one stream.Tested locally: all
clickhouse-localDelta Lake stateless tests pass, including05530_delta_lake_kernel_cdf, which covers the change data feed of 18 tables of the kernel test data (inserts, updates, deletes by deletion vectors and CDC files, partitions, column mapping innameandidmodes).05565_delta_lake_change_data_feed_parallel_replicas(needs MinIO and a cluster) was not run locally.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
The change data feed of Delta Lake tables (
delta_lake_snapshot_start_version) is read by ClickHouse's own Parquet reader, in parallel and with caches; delta-kernel-rs is used only to list the data files. Virtual columns such as_pathand_fileare available for it.🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/130062]