Skip to content

Don't check empty schema in SchemaProcessor - #108945

Merged
scanhex12 merged 1 commit into
ClickHouse:masterfrom
scanhex12:fix-iceberg-empty-manifest-schema
Jun 30, 2026
Merged

scanhex12 merged 1 commit into
ClickHouse:masterfrom
scanhex12:fix-iceberg-empty-manifest-schema

Conversation

@scanhex12

@scanhex12 scanhex12 commented Jun 30, 2026 •

Copy link
Copy Markdown
Member

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Version info

  • Merged into: 26.7.1.304 (included in 26.7 and later)
  • Backported to: 26.5.6.8, 26.3.17.14, 25.8.29.36

@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [ebe72b8]

Summary: ❌

job_name test_name status info comment
Unit tests (tsan, function_prop_fuzzer) FAIL
FunctionsStress.stress FAIL cidb
AllTests FAIL cidb
Stress test (arm_tsan) FAIL
Hung check failed, possible deadlock found FAIL cidb, issue
Upgrade check (amd_release) FAIL
Error message in clickhouse-server.log (see upgrade_error_messages.txt) FAIL cidb
Stress test (amd_tsan) ERROR

AI Review

Summary

This PR makes IcebergSchemaProcessor ignore schemas with missing or empty fields, intended to tolerate Databricks UniForm manifest placeholder schemas while the real schema lives in metadata.json. The intent is reasonable, but the skip is implemented in the shared schema-registration path and is broader than the invariant described in the comment, so it can silently drop schemas that are not safe to ignore.

Findings

⚠️ Majors

  • [src/Storages/ObjectStorage/DataLakes/Iceberg/SchemaProcessor.cpp:216] addIcebergTableSchema is used for schemas from both metadata.json and manifest headers, but the new early return ignores any missing or empty fields schema without checking that the real schema for that schema-id was already registered. That means an empty or malformed current metadata schema, or a manifest placeholder for an ID not yet registered, is accepted without populating iceberg_table_schemas_by_ids / clickhouse_table_schemas_by_ids; later reads can fail with an unknown schema from getClickhouseTableSchemaById or lose schema-evolution/pruning information.
    Suggested fix: keep the skip scoped to manifest placeholders with a known real schema, for example return only when iceberg_table_schemas_by_ids.contains(schema_id) is true, or move the placeholder handling to the manifest caller after metadata schemas have been loaded. Otherwise preserve the previous registration failure for invalid or unknown schemas.
Tests
  • ⚠️ Add a focused regression test for the intended Databricks UniForm case: register a real metadata schema, then process a manifest schema with the same schema-id and empty fields, and verify the real schema remains available. The same test should cover that an empty schema for an unregistered ID is not silently accepted.
Final Verdict

Status: ⚠️ Request changes

Minimum required actions: scope the empty-schema skip to already-known manifest placeholders, and add focused regression coverage for both the accepted placeholder case and the unknown-schema case.

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Jun 30, 2026

/// Databricks UniForm writes a degenerate placeholder schema (e.g. {"schema-id":0,"fields":[]})
/// into manifest files, while the real schema with the same schema-id lives in metadata.json.
if (!schema_ptr->isArray(f_fields) || schema_ptr->getArray(f_fields)->size() == 0)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This skips any schema with missing or empty fields, but addIcebergTableSchema is the shared registration path for schemas read from metadata.json as well as manifest headers. The comment's safety condition only holds when this object is a Databricks manifest placeholder and the real schema for the same schema-id has already been registered from metadata. If an empty or malformed current schema comes from metadata, or a manifest placeholder is seen for an ID that was not registered yet, we now accept the ID without registering iceberg_table_schemas_by_ids / clickhouse_table_schemas_by_ids; later reads then fail with an unknown schema from getClickhouseTableSchemaById or lose schema-evolution/pruning info. Please keep the skip scoped to manifest placeholders with a known real schema, for example only return when iceberg_table_schemas_by_ids.contains(schema_id) is true, or move this guard to the manifest caller after metadata schemas have been loaded. Otherwise preserve the previous registration failure for invalid or unknown schemas.

@clickhouse-gh

clickhouse-gh Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

LLVM Coverage Report

Metric Baseline Current Δ
Lines 85.50% 85.40% -0.10%
Functions 92.70% 92.70% +0.00%
Branches 77.70% 77.70% +0.00%

Changed lines: Changed C/C++ lines covered: 5/6 (83.33%) · Uncovered code

Full report · Diff report

@scanhex12
scanhex12 added this pull request to the merge queue Jun 30, 2026
Merged via the queue into ClickHouse:master with commit feae75b Jun 30, 2026
169 of 174 checks passed
@scanhex12
scanhex12 deleted the fix-iceberg-empty-manifest-schema branch June 30, 2026 21:51
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Jun 30, 2026
@scanhex12 scanhex12 self-assigned this Jul 1, 2026
@scanhex12 scanhex12 added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Jul 1, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jul 1, 2026
@robot-clickhouse-ci-2 robot-clickhouse-ci-2 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jul 1, 2026
scanhex12 added a commit that referenced this pull request Jul 1, 2026
Backport #108945 to 26.5: Don't check empty schema in SchemaProcessor
scanhex12 added a commit that referenced this pull request Jul 1, 2026
Backport #108945 to 26.3: Don't check empty schema in SchemaProcessor
alexey-milovidov added a commit that referenced this pull request Jul 29, 2026
Backport #108945 to 25.8: Don't check empty schema in SchemaProcessor
joelynch pushed a commit to aiven/ClickHouse that referenced this pull request Aug 17, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 24, 2026
zeekay pushed a commit to hanzoai/datastore that referenced this pull request Sep 11, 2026
…-manifest-schema

Don't check empty schema in SchemaProcessor
arsenmuk pushed a commit to melvynator/ClickHouse that referenced this pull request Nov 8, 2026
…is unknown"

An Iceberg table whose schema has an empty `fields` array (valid per the
spec; PyIceberg writes one for `create_table(schema=Schema())`) failed with
`Schema with id 0 is unknown. (BAD_ARGUMENTS)`, although metadata.json
defines the schema.

`addIcebergTableSchema` returned early for every schema with an empty
`fields` array. The skip was added in ClickHouse#108945 for the Databricks UniForm
placeholder `{"schema-id":0,"fields":[]}` that is written into manifest
headers while metadata.json holds the real schema 0; at that time the
function did not know where a schema came from. So a metadata.json schema
without fields was never registered, and the table structure lookup
reported a known schema as unknown.

Limit the skip to schemas from manifest files, and reject a schema without
fields in `getClickHouseTableSchemaById` with EMPTY_LIST_OF_COLUMNS_PASSED,
the code used when a table would get no columns. Every caller of that
function builds a table or read structure (current schema, format version 1
`schema`, a snapshot schema selected with `iceberg_snapshot_id`, the sorting
key, the REST catalog), so all of them get the clear error, and the schema
inference fallback for an empty structure is never reached. An old schema
without fields does not prevent reading the table with a later schema.

Related: ClickHouse#130002

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants