Repository navigation
Conversation
|
Backporter: cherry-pick conflicts resolved by AI Conflicted files:
Commits:
|
|
Can you add a test like the below? The reason is I also need to implement some annotated types and AI is saying that 3rd party tools can overwrite your annotation
|
@arthurpassos Added this in clickhouse-regression and ran it against this PR's build. You were right, the annotation doesn't survive. Here's what I tried:
Reading works fine. Spark and PyIceberg both see the states as binary, and if you CAST back to the AggregateFunction type in ClickHouse you get the right results. But anything that writes to the table drops the field key, since it isn't in the spec. If the type needs to survive other writers, I think it has to go somewhere they keep, like table properties. Here is the main file you would want to look at for for ths: https://github.com/Altinity/clickhouse-regression/blob/main/iceberg/tests/iceberg_engine/aggregate_states/annotation_survival.py |
Defects in #2680Head MediumAn attached Iceberg table checks Attach an Iceberg table with a LowIceberg accepts a On a LowIceberg resolves
|
The field-level `clickhouse.type` key was dropped by REST catalogs and by commits from other engines, so aggregate-state columns silently read back as `String` or their storage type. Annotations are now table properties `clickhouse.type.<field-id>.<schema-id>`; a field's type in a schema is the entry with the greatest schema id not above it, so older schemas keep theirs. - Pass annotations explicitly to `IcebergSchemaProcessor::addIcebergTableSchema` and store them per schema; re-parse a schema transactionally when they change. - Validate an annotation exactly against the field's Iceberg type. - Ignore `clickhouse.type.*` properties that are not annotation keys. - Register metadata schemas before maintenance operations walk manifests. - Send property changes with REST `updateSchema`, forward properties on create. - Move the docs sections into the engine and format `Documentation` sources. Related: #2680 (comment)
`IcebergSchemaProcessor::getFieldType` is compiled without Avro but calls `getIcebergType` and `icebergTypesEqualIgnoringIds`, which were declared and defined only under `USE_AVRO`. Neither depends on Avro, so move them out of the guard. CI report: https://altinity-build-artifacts.s3.amazonaws.com/json.html?PR=2680&sha=bf6ff058da7117bbd3c4ff1bc9bbb499b2236d38&name_0=PR&name_1=Fast%20test PR: #2680
CI triage for
|
| Check | Failing tests | Verdict |
|---|---|---|
| Integration (amd_asan_ubsan, db disk, old analyzer, 5/8) | all 21 of test_storage_iceberg_with_spark/test_export_partition_iceberg.py |
Already failing on the base branch |
| Integration (… 6/8) | 17× test_database_backup/test.py |
Already failing on the base branch |
| Integration (… 7/8) | 2× test_backward_compatibility/test_custom_s3_disk_remote_url_allow_hosts.py |
Already failing on the base branch |
| Stateless (amd_debug, parallel) | 05387_cas_publish_counts_replicated |
Flaky (CAS test, passed 16/16 reruns) |
| Regression release oauth | /oauth/access control, /oauth/groups/* |
Already failing on the base branch |
| Regression release swarms | cluster discovery/…wrong cluster name, node failure/cpu overload* |
Already failing on the base branch |
| Regression release s3_azure_1 | /s3/azure/part 1/disk/remote host filter, …/disk/syntax |
Already failing on the base branch |
How I checked: I compared against the praktika result_pr.json reports of four unrelated open PRs on antalya-26.8: #2703, #2715, #2729, #2735. All four have the same 21 test_export_partition_iceberg failures, plus the test_database_backup and test_custom_s3_disk_remote_url_allow_hosts failures in the same shards. On their GitHub checks, oauth and swarms regression fail on #2703, #2715, #2729 and #2735, and s3_azure_1 fails on #2735.
The checks that cover this feature passed: Regression iceberg_1 / iceberg_2, integration shards 1–4 and 8/8, and the rest of stateless amd_debug parallel (13638 passed). That includes the new 04673_parquet_aggregate_function_state and 05428_iceberg_… tests; the report lists only non-OK tests, and these aren't in it.
1. test_export_partition_iceberg.py (21/21): already failing on the base branch
Every test fails while setting up the table, on the CREATE TABLE … ENGINE=IcebergS3(s3, …) statement. It never gets to any export or aggregate-state code:
Code: 497. DB::Exception: default: Not enough privileges. To execute this query, it's necessary to have the grant SHOW NAMED COLLECTIONS SECRETS ON s3.
10. src/Storages/NamedCollectionsHelpers.cpp:228:18: DB::checkNamedCollectionOverride(...)
12. src/Storages/ObjectStorage/StorageObjectStorageConfiguration.cpp:114:38: DB::StorageObjectStorageConfiguration::initialize(...)
This is the named-collection override access check against the test's default user. The same 21 tests fail with the same shard layout on #2703, #2715, #2729 and #2735. To fix it on the base branch, the test user needs SHOW NAMED COLLECTIONS SECRETS on s3, or the test config needs to allow overriding the collection without it. That belongs in a separate fix on antalya-26.8, not in this PR.
2. test_database_backup/test.py (17): already failing on the base branch
The first failure is a server abort. All the others are Connection refused because the instance is dead:
<Fatal> : Logical error: 'Chosen multipart upload for an empty file. This must not happen'.
It is a CAS backup to backup_disk_s3_plain_rustfs (test_database_backup_database[cas_policy-Disk('backup_disk_s3_plain_rustfs', …)]). The same tests fail on all four comparison PRs. None of that code is in this PR.
3. test_custom_s3_disk_remote_url_allow_hosts.py (2): already failing on the base branch
Exception: Timed out while waiting for instance `node' with ip address 172.16.5.6 to start.
The same 2 tests fail on #2703, #2715, #2729 and #2735.
4. 05387_cas_publish_counts_replicated: flaky
-replicated_merge 1 0 3
+replicated_merge 0 0 3
The runner's own diagnosis: "Runs: 16, Failed: 0, Passed: 16 … The failure is not reproducible." The test checks CAS publish counters for replicated merges, which this PR doesn't touch. Safe to re-run.
5. Regression oauth / swarms / s3_azure_1: already failing on the base branch
The failing scenarios are OAuth groups/access control, swarm cluster discovery and CPU overload, and the Azure disk remote host filter / syntax. They have nothing to do with Parquet or Iceberg type mapping, and the same suites are red on #2735 (all three) and #2703, #2715, #2729 (oauth and swarms).
Other notes
- Several jobs show as
DROPPEDin the praktika report andskippingon GitHub, so they didn't run for this commit: stateless amd_debug sequential, distributed plan, CAS storage suites, Stress (amd_debug/asan), AST fuzzer, BuzzHouse, SQLLogic/SQLStorm, Install packages and Compatibility check. The report gives no reason. If you want that coverage before merging, a re-run is worth trying. - Suggested next step: nothing to change in this PR. The
test_export_partition_icebergaccess error is red on everyantalya-26.8PR, so it deserves its own fix on the base branch.
Sources: PRs/2680/d2ee51d…/result_pr.json, plus the same reports for #2703, #2715, #2729 and #2735, and the gh run view --log-failed output of the regression jobs.
|
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
ClickHouse/src/Storages/ObjectStorage/DataLakes/Iceberg/SchemaProcessor.cpp
Lines 951 to 958 in d2ee51d
When a schema evolution both changes a SimpleAggregateFunction annotation and creates a new schema ID—for example, changing sum to max while repositioning the column—the Iceberg primitive type remains identical and this branch passes the old DAG input through unchanged. Because IDataType::equals ignores the custom SimpleAggregateFunction name, old data files retain the old function/type while the new schema expects the new annotation, producing an incorrect transformed header or wrong aggregate semantics. Compare the resolved annotated types here and add a cast/retyping node whenever their custom names differ.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
Segfault reading an
|
This comment was marked as outdated.
This comment was marked as outdated.
Bounds are stored in the Iceberg encoding of the field, but were decoded with the annotated ClickHouse type: - `AggregateFunction`: `ColumnAggregateFunction::insertData` treated the bound bytes written by Spark as a state pointer, so reading the table crashed in `UniquesHashSet::write`. - `SimpleAggregateFunction` over `DateTime64(3)` or `Time`: microsecond bounds were read at the annotated scale or width, so `SELECT` returned `9999-12-31 23:59:59.000` through the min/max read optimization and min/max pruning skipped files with matching rows. `ManifestFilesPruner` and `DataFileMetaInfo` now ignore bounds of fields for which `IcebergSchemaProcessor::hasClickHouseTypeAnnotation` is true. Related: #2680 (comment)
`IcebergSchemaProcessor::addIcebergTableSchema` now requires the `ClickHouseTypeAnnotations` argument. Use the existing helper `addIcebergTableSchemasFromMetadata`, which passes annotations taken from the metadata. https://altinity-build-artifacts.s3.amazonaws.com/json.html?PR=2680&sha=latest&name_0=PR&name_1=Build%20(amd_debug) Related: #2680
This comment was marked as outdated.
This comment was marked as outdated.
|
@codex review |
This comment was marked as outdated.
This comment was marked as outdated.
|
@codex review |
|
Codex Review: Something went wrong. Try again later by commenting “@codex review”. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
This comment was marked as outdated.
This comment was marked as outdated.
| } | ||
| } | ||
|
|
||
| /// The catalog keeps the id of the equivalent schema, so the ClickHouse type annotations recorded for the new id |
There was a problem hiding this comment.
I am not sure I understand what this means, can you clarify?
| std::optional<size_t> version; | ||
|
|
||
| String getNameImpl(bool with_version) const; | ||
| String getNameImpl(bool with_version, bool always_emit_version) const; |
There was a problem hiding this comment.
Isn't there a way we can introduce a separate function instead of modifying the existing one? this will become conflicts we need to merge in the future. It is ok if there is no other easy way
There was a problem hiding this comment.
well, we always can overload, if you think this would be better
There was a problem hiding this comment.
if that allows us not to mess with upstream code in an elegant manner, let's push for that
| json.set("task_timeout_seconds", task_timeout_seconds); | ||
| json.set("write_full_path_in_iceberg_metadata", write_full_path_in_iceberg_metadata); | ||
| json.set("allow_lossy_cast", allow_lossy_cast); | ||
| json.set("allow_aggregate_function_states_in_open_formats", allow_aggregate_function_states_in_open_formats); |
There was a problem hiding this comment.
You have added logic to store this new setting in the export manifests, but nothing retrieves it from the manifest. You shall add it to
so that it takes place.Which also leads to: can you ask AI to add a simple export partition test to validate this code path?
There was a problem hiding this comment.
There was a problem hiding this comment.
Sorry, I missed it. all good then
| columns, | ||
| partition_by, | ||
| order_by="tuple()", | ||
| engine="MergeTree()", |
There was a problem hiding this comment.
no good reason actually. iirc test was failing at some point and this helped debug it. should work without this line
| node.query(f"DROP TABLE IF EXISTS {iceberg}") | ||
|
|
||
|
|
||
| def test_export_part_aggregate_function_states(cluster): |
There was a problem hiding this comment.
huh.. is this test passing? that's weird, I would not expect that
There was a problem hiding this comment.
why? the whole suite was green locally. let's wait and look at what CI has to say
There was a problem hiding this comment.
Because of #2680.
If I understand and remember correctly, you only added logic to persist this new setting into the export manifests, but you haven't added code to read it back. Meaning during export time (which happens in the background, not in the same thread the query was processed), the support_aggregate setting should be the default (which I assume defaults to false)
There was a problem hiding this comment.
your link is broken :)
but no, the export is now also wired for aggregate func
There was a problem hiding this comment.
ahh, you probably meant #2680 (comment)
sorry, my mind is single-threaded :)
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
I think I need a rather fundamental change on where does the setting belong to here, enough band-aids 😄 |
23e7ddd to
28e6af9
Compare
…te states in Parquet `allow_aggregate_function_states_in_open_formats` is enabled by default, so the Parquet output no longer fails with `UNKNOWN_TYPE`. Disable the setting for the query and expect `SUPPORT_IS_DISABLED` instead. CI report: https://altinity-build-artifacts.s3.amazonaws.com/json.html?PR=2680&sha=28e6af95bd2704c4721ff7d74b9ba338dc35b79b&name_0=PR PR: #2680
`AddFilesExecute.cpp` from the base branch called `addIcebergTableSchema` without the ClickHouse type annotations argument, which is now required. CI report: https://altinity-build-artifacts.s3.amazonaws.com/json.html?PR=2680&sha=90215bcae52a7f1b1f7a78b54fd036d650ae01d4&name_0=PR PR: #2680
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ced1fcbd25
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
With `output_format_parquet_wide_integer_as_decimal` the writer encodes `UInt128` and `Int128` as `DECIMAL(39, 0)`, which structure-less schema inference reads as `Decimal(39, 0)`. The `clickhouse.column_types` annotation check accepted only `FixedString(16)`, so such files did not round-trip. Related: #2680
…on state version `IDataType::equals` ignores the state version of `AggregateFunction`, so a version-only change was committed as an annotation-only change. All data files of the schema are read with the version of its annotation, so the existing files became unreadable. Since `MODIFY COLUMN` does not pin the current state version, re-stating the same type was enough to trigger it, e.g. for `quantileDeterministic`. Related: #2680
|
@codex review |
💡 Codex ReviewClickHouse/src/Core/FormatFactorySettings.h Line 1746 in 98313bf With the setting enabled by default, merely inferring the schema of an untrusted Parquet file or Iceberg table lets file-controlled metadata select an ClickHouse/src/Storages/ObjectStorage/DataLakes/Iceberg/SchemaProcessor.cpp Lines 501 to 502 in 98313bf When another engine evolves a field so an inherited annotation no longer matches its Iceberg type—for example, a required annotated ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
It was set to |
009655e to
abdd14c
Compare
Parquet files and Iceberg tables can now store `AggregateFunction` states and `SimpleAggregateFunction` columns, and ClickHouse reads them back with their original types. A state is stored as binary, and the ClickHouse type is recorded in the `clickhouse.column_types` Parquet file metadata or in the `clickhouse.type.<field-id>.<schema-id>` Iceberg table properties. Writing and reading `AggregateFunction` states requires the new setting `allow_aggregate_function_states_in_open_formats`, disabled by default. A table can also set it in the `SETTINGS` clause of its engine. Closes: #2206
abdd14c to
7917eed
Compare
CI triage for
|
| Check | Classification | PR-caused? |
|---|---|---|
| Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/8, 2/8, 6/8) | Slow runner: the 9000 s pytest session timeout | No (details below) |
| RegressionTestsRelease / Swarms | Pre-existing: fails the same way on other 26.8 PRs | No |
| Grype Scan (keeper, server-alpine) | Pre-existing: CVEs in the base image | No |
PR |
Summary check that aggregates the ones above | — |
Every check that ran on code this PR touches passed: Stateless amd_debug/amd_binary/asan_ubsan (including the new 04673_*, 0542x_*, 0581x_* tests), Unit tests (asan_ubsan, 26383 passed), Integration tests (amd_asan_ubsan, targeted) 0/28 failures, and integration shards 3/4/5/7/8.
1. Integration tests (amd_asan_ubsan, db disk, old analyzer, 1/8, 2/8, 6/8): session-timeout
!!!!!!! xdist.dsession.Interrupted: session-timeout: 9000.0 sec exceeded !!!!!!!
ERROR: session-timeout occurred during test execution
These shards stopped at the 9000 s cap at 83% (1/8), 74% (2/8) and 95% (6/8). No test failed for a reason related to this PR. The whole shard ran slowly, including modules the PR doesn't touch:
- Speed compared with base PR Antalya 26.8, backport of #124883: read a 64 KiB Parquet footer tail for local files #2949 on the same shards (same suite, about the same time):
- Shard 2/8, 65 min into the run: base was at 66%, this PR at 30%.
- Shard 1/8, ~100 min into the run: base had finished its parallel phase, this PR was at 69%.
- The slowdown hits every pytest worker and unrelated modules too (
test_storage_s3_queue,test_storage_nats,test_backup_restore_*), not just Iceberg/Parquet.
- Healthy shards with the same binary. Shards 3/4/5/7/8 of this PR finished in 5520–6858 s, the same as base (Antalya 26.8, backport of #124883: read a 64 KiB Parquet footer tail for local files #2949: 5277–7274 s). A slowdown caused by the binary would show up in every shard. The three slow jobs started last (22:26–22:32 UTC), which fits contended runners.
- Failures inside the slow shards, none in code this PR touches:
- 2/8:
test_storage_nats/test_nats_jet_stream.py::test_nats_overloaded_insertand::test_nats_restore_failed_connection_without_losses_on_writeeach hung untilTimeout (>900.0s) from pytest-timeout. Together they cost about 30 min of the budget. Both pass on Antalya 26.8, backport of #124883: read a 64 KiB Parquet footer tail for local files #2949's shard 2 in about 1 min. - 6/8:
test_quorum_inserts/test.py::test_insert_quorum_with_ttlfailed withREPLICA_IS_NOT_IN_QUORUM, a timing-sensitive ReplicatedMergeTree quorum test. - 6/8 also:
test_storage_delta/test.pysetup failed on a Docker image pull:manifest for altinity/clickhouse-server:25.3 not found: manifest unknown. This is an infra problem (the image is missing from the registry). It needs a fix in the test infra, not in this PR.
- 2/8:
- The PR's own integration tests passed.
test_export_partition_to_iceberg/*(138 tests, including the modifiedtest_schema_match.py) all passed on shard 2/8. They took about 2× longer than on Antalya 26.8, backport of #124883: read a 64 KiB Parquet footer tail for local files #2949, the same ratio as everything else on that runner.
Next step: re-run the three failed shards. If they time out again on a different runner, compare per-test durations (pytest_parallel.jsonl) against base before suspecting the PR.
2. RegressionTestsRelease / Swarms: pre-existing
✘ [ Fail ] '/swarms/feature/node failure/cpu overload' (5m 4s)
✘ [ Fail ] '/swarms/feature/node failure/cpu overload all swarm nodes' (5m 8s)
AssertionError
The same scenarios fail on other current antalya-26.8 PRs, for example #2949, which fails cpu overload and cpu overload all swarm nodes plus check restart swarm node. #2947 and #2958 also have Swarms red. Not related to this PR. Next step: none here; it needs fixing on the branch or in the regression suite.
3. Grype Scan (clickhouse-keeper, clickhouse-server-alpine): pre-existing
Grype Scan Completed with 5 high/critical vulnerabilities. The same two images fail with the same result on #2947, #2949 and #2958, and the non-alpine server image passes everywhere. The CVEs come from the base images, not from this PR's code. Next step: none here.
Bottom line: I found nothing that needs a code change in this PR. Re-running the three integration shards should turn them green; Swarms and Grype are red across the branch. Evidence: result_pr.json and the shard job.logs, compared with #2949's reports for the same shards.
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Closes #2206
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Parquet files and Iceberg tables can now store
AggregateFunctionstates andSimpleAggregateFunctioncolumns, and ClickHouse reads them back with their original types. Writing and readingAggregateFunctionstates requires the new settingallow_aggregate_function_states_in_open_formats, disabled by default.CI/CD Options
Exclude tests:
Regression jobs to run: