Repository navigation
Fix issue with the write to Iceberg via the glue catalog - #126924
Conversation
… create/commit/alter Tables created or written through DataLakeCatalog(glue) had an empty column list in Glue, which made them unreadable by Athena (COLUMN_NOT_FOUND: Relation contains no accessible columns). Translate the Iceberg schema into Glue columns (Hive type strings plus the iceberg.field.* parameters, as Apache Iceberg Glue catalog does), preserve the existing table definition on UpdateTable instead of replacing it, and record previous_metadata_location on each commit.
|
Workflow [PR], commit [aad80eb] Summary: ✅
AI ReviewSummaryPR #126924 populates Glue columns from Iceberg schemas, preserves table attributes during commits, and adds optimistic conflict handling. Reviewed head The empty-schema output reaches Missing context / blind spots
Findings❌ Blockers
Final Verdict
|
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Object file sizes25 object files changed (-567.73 KiB total), 0 added.
711 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only Slowest function optimization changes (ThinLTO)Median per-function time ratio to the master baseline:
Compile time of recompiled translation units129 translation units recompiled, 1205 s compile time in total, 129 of them have a recent master baseline. |
arsenmuk
left a comment
There was a problem hiding this comment.
I find both bot's findings valid.
And I think we should extend tests/integration/test_database_glue/test.py to cover the new functionality and some edge cases addressed by the findings
# Conflicts: # src/Databases/DataLake/GlueCatalog.cpp # src/Databases/DataLake/GlueCatalog.h
`createObjectStorageForEarlyTableAccess` used `storage_endpoint` verbatim and dropped the bucket parsed from the `s3://` location. With an endpoint without the bucket (e.g. `http://minio1:9001`), `metadata.json` was read from the wrong bucket, and since the schema is now always read from `metadata.json`, `SHOW CREATE TABLE`, `SELECT` and `INSERT` failed for every Glue table. Build the endpoint with `TableMetadata::getLocationWithEndpoint`, the same way `DatabaseDataLake::getStorageEndpointForTable` does for the table itself. Related: ClickHouse#126924 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
A v1 top-level `schema` may omit `schema-id`. `getCurrentSchema` returned it anyway, and building the cached ClickHouse schema then threw on the missing `schema-id`, even when `schemas` had a valid entry for `current-schema-id`. That made such Glue tables inaccessible, although the regular Iceberg reader (`IcebergMetadata::parseTableSchema`) handles this layout. Use the top-level v1 `schema` only when it has `schema-id`, otherwise select the `schemas` entry, as `IcebergMetadata::parseTableSchema` does. Related: ClickHouse#126924 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…cached schema The schema cache built `IcebergSchemaProcessor` with geo parsing always enabled, so `SHOW CREATE TABLE` could show `Geometry` columns that the storage itself rejects without `allow_geo_types_in_iceberg`. Use the setting, as `IcebergMetadata` does. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`GlueCatalog::createObjectStorageForEarlyTableAccess` stripped only the `s3://` prefix, so for `s3a://warehouse/t/...` it took `s3a:` as the bucket and failed to read the metadata. Because the Glue schema is now always read from `metadata.json`, this broke `SHOW CREATE TABLE`, `SELECT` and `INSERT` for every table registered with an `s3a://` location, while the table storage itself supports this scheme. Strip any `<scheme>://` prefix, as `TableMetadata::setLocation` does. The parsing is moved into the static `GlueCatalog::resolveEarlyAccessLocation` to cover it with a unit test. Review: ClickHouse#126924 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
`GlueCatalog::createObjectStorageForEarlyTableAccess` added the bucket to `storage_endpoint` with `S3UriStyle::AUTO`, while the table storage uses the database setting `storage_uri_style` in `DatabaseDataLake::getStorageEndpointForTable`. With `storage_uri_style = 'virtual_hosted'`, the metadata read went to a path-style URL, which such endpoints reject. Because the Glue schema is now always read from `metadata.json`, this broke every table of such a database. Pass `storage_uri_style` to the catalog in `CatalogSettings` and use it for the early metadata reads. Review: ClickHouse#126924 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
`GlueCatalog` is constructed with the global context, so the schema read from `metadata.json` checked the server default of `allow_geo_types_in_iceberg` instead of the query settings. A Glue table with a `geometry` or `geography` column threw during schema discovery even when the query enabled the setting. The result is also cached by metadata location for all queries, so it must not depend on the settings of one query. Parse geo types in the catalog, as the Glue type conversion did before this PR, and leave the check with the query settings to `IcebergMetadata`. Review: ClickHouse#126924 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
`GlueCatalog::getCurrentSchema` returned the top-level v1 `schema` when it had an ID, even if `schemas` and `current-schema-id` referenced a newer schema. `IcebergMetadata::parseTableSchema` and Apache Iceberg prefer `schemas` whenever it is present, because writers that evolve the schema may leave `schema` stale. So `SHOW CREATE TABLE` could show dropped or renamed columns, and filling an empty Glue column list could publish the obsolete schema. Use `parseTableSchemaV2Method`, as `IcebergMetadata::parseTableSchema` does, whenever `schemas` is present, and the top-level `schema` only otherwise. The unit test asserted the obsolete schema; it now expects the schema referenced by `current-schema-id`. Review: ClickHouse#126924 (comment) Co-Authored-By: Claude Opus 5.5 <[email protected]>
`GlueCatalog::updateMetadata` and `GlueCatalog::updateSchema` did a blind `GetTable` + `UpdateTable`: they never returned `false` on a conflict, and a commit by another engine (Spark, Trino, pyiceberg) between the base read and our `UpdateTable` was silently overwritten. An SDK retry of an `UpdateTable` that had already landed could also move `metadata_location` back and restore stale columns. Both now go through `GlueCatalog::commitTableUpdate`, which: - passes the `VersionId` from `GetTable` to `UpdateTable`, and on `ConcurrentModificationException` re-reads the table and retries a bounded number of times; - returns `true` if Glue already points to our file (an earlier attempt landed); - returns `false` if `metadata_location` no longer has the base version of the new file, before any `UpdateTable` was sent; - after an `UpdateTable` was sent, returns `true` if the newer commit names our file as `previous_metadata_location`, and throws otherwise, because the files may already be referenced and must not be cleaned up. Why `false` is safe here: the new `vN.metadata.json` is published before the catalog call, but a catalog-backed writer takes its base only from the Glue pointer (`getLatestMetadataFileAndVersionWithCatalog`), derives `N` from its parsed version, and the `If-None-Match` write lets only one writer publish `vN`. So while Glue does not point to our file, no committed metadata references it, and the cleanups of the callers (manifest list, attempt-local manifests and data files) only remove files of this attempt. Comparing the parsed version instead of the full path avoids an `ICatalog` signature change and path normalization (`s3://` vs `s3a://`); external Iceberg writers always move the pointer to a file with a different version. `expire_snapshots` threw a `LOGICAL_ERROR` on `false`, which only Glue reaches there; it now retries, since nothing is deleted before the commit. The new test pauses an `INSERT` before its commit, moves the Glue pointer to an Iceberg Java style file, and checks that the `INSERT` is rebuilt on top of it. moto 5.1.5 ignores `VersionId` and never raises `ConcurrentModificationException`, so that path is not covered by tests. Related: ClickHouse#126924 Co-Authored-By: Claude Opus 5.5 <[email protected]>
218d024
Resolve the conflicts of the backport of #126924 to 26.10: - `DatabaseDataLake::getCreateTableQueryImpl`: 26.10 has no `getTableSchema` helper, so the columns are taken from `table_metadata.getSchema` before the fallback to the table storage. - `GlueCatalog::resolveMetadataPathFromTableLocation`: 26.10 has no `resolve_context` with `iceberg_list_only_v_prefixed_metadata_files`, so `getContext` is kept; only the structured binding gets the new `catalog_metadata_location` member. - `GlueCatalog.cpp` includes: the `CurrentMetrics`/`unit.h` includes are removed together with the schema cache, and the `CurrentThread`/`ThreadStatus` includes of master are not needed. - `RestCatalog.h`: 26.10 has no `createTableAtDefaultLocation`, only the `updateMetadata` signature changes. - `IcebergMetadata`: `getMetadataLogEntries` and `IcebergGetTableStateMicroseconds` do not exist in 26.10; the remaining three-element binding in `getRelevantState` is extended. - `AlterDropPartitionExecutor`: `getRelevantState` has no `ignore_metadata_pointer_overrides` argument in 26.10. - `glue_fault_proxy.py` does not exist in 26.10 (the Glue fault proxy was added on master later), so it is dropped along with `test_writes_rebuild_after_glue_version_id_conflict`, the only test that needs it. Co-Authored-By: Claude Fable 5.2 <[email protected]>
Cherry pick #126924 to 26.10: Fix issue with the write to Iceberg via the glue catalog
…-commit-state-unknown Master's ClickHouse#126924 rewrote the Glue commit into a VersionId-guarded loop. The unknown-outcome handling is re-applied inside it: a proven rejection keeps the old error and cleanup, and any other UpdateTable failure reads the pointer back before reporting UNKNOWN_STATUS_OF_TRANSACTION. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The backport of #126924 brought the `metadata_version` helper, which uses `re.match`, but the `import re` line is not present in the `26.10` version of the test. This failed the `ruff` style check (`F821 Undefined name`) and three tests with `NameError: name 're' is not defined`. https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=133355&sha=432f8223bf8a95c47aed468832cb6923ef6ecd83&name_0=BackportPR&name_1=Style%20check #133355 Co-Authored-By: Claude Fable 5.2 <[email protected]>
Backport #126924 to 26.10: Fix issue with the write to Iceberg via the glue catalog
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Iceberg tables created or written through
DataLakeCatalogwithcatalog_type = 'glue'now register their columns in the Glue table definition, so they can be queried by Athena and other Glue consumers. Previously the Glue entry had an empty column list and Athena failed withCOLUMN_NOT_FOUND: Relation contains no accessible columns.Documentation entry for user-facing changes
No new settings or syntax.
Details
GlueCatalog::createTable/updateMetadata/updateSchemaonly setLocation,metadata_locationandtable_type. This PR:DataLake::icebergTypeToGlueType, the inverse of the existinggetTypereader, mapping Iceberg types to Hive type strings as Apache Iceberg's Glue catalog does;StorageDescriptor.Columns(withiceberg.field.id/optional/currentparameters) onCreateTableand on schema changes;UpdateTableread-modify-write so commits preserve existing columns and other attributes instead of replacing the whole definition, and recordsprevious_metadata_location.Verified against real AWS Glue + Athena: create, insert, repeated inserts,
ALTER TABLE ADD COLUMN, nestedarray/map/struct, decimals and timestamps are all readable from Athena afterwards. Unit tests insrc/Databases/DataLake/tests/gtest_glue_schema_columns.cpp.Workflow [PR]
Sync PR [sync-upstream/pr/126924]
Version info
26.11.1.2153-master(included in26.11and later)26.10.12.10