Repository navigation
Add Iceberg tables from the DuckDB Iceberg extension tests - #130010
alexey-milovidov wants to merge 12 commits into
Conversation
The tables of `data/persistent` of https://github.com/duckdb/duckdb-iceberg at b57f45c2c78965c71f699aa23ae73c292923668e (MIT License) with the expected results of its sqllogictest files: identity partitions of all types, equality deletes, deletion vectors, `initial-default`, name mapping, data files that don't match the schema, deprecated v1 metadata, row lineage, time travel and invalid metadata. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [6f06a72] Summary: ⏳
AI ReviewSummaryThe PR adds six stateless Iceberg interoperability tests using fixtures and expected results from a pinned DuckDB Iceberg extension revision. No new code findings remain, and the previous oversized Tests
Final VerdictStatus: Complete the documented prerequisite fixes and obtain passing CI results for all six new tests. No new inline comments or thread changes are needed. |
The snapshot id 9876543210123456789 of `equality_delete_cross_partition` and `equality_delete_extra_column` does not fit the type `long` of the Iceberg spec, so `vfinal.metadata.json` has to be refused (DuckDB accepts it). The table `equality_delete_extra_column` before the delete is still read. Related: #130002 Related: #130019 Related: #130020 Related: #130021 Related: #128304 Co-Authored-By: Claude Opus 5.5 <[email protected]>
…the data file The `nested_source` table of the DuckDB Iceberg extension tests is partitioned by identity on `address.country`, and its data file stores only `address.city`, so the value is only in the manifest. `SELECT *`, an explicit PREWHERE over `address` and a post-reader filter over `address` returned NULL for it. The table files are byte-identical to those of ClickHouse#130010 at the same path. Closes ClickHouse#129995 Co-Authored-By: Claude Opus 5.5 <[email protected]>
`SchemaConverter::processSubtreeMap` dropped the MAP interpretation of a Parquet group for any requested `Tuple`, so that the literal shape of the schema tree, `Tuple(key_value Array(Tuple(key, value)))`, stays readable. `processSubtreeTuple` then matched the requested elements to the group's children by name. The only child is the repeated `key_value` group, so a Tuple such as `Tuple(value String)` matched nothing, every element became a missing column, and the read returned defaults (`NULL` for the Iceberg case) instead of the data or an error. With `input_format_parquet_allow_missing_columns = 0` it failed with `THERE_IS_NO_COLUMN`, which is not a type error either. This is how an Iceberg table whose schema has `payload struct<value: string>` read a data file that stores `payload` as a map (ClickHouse#130020): the requested type comes from the table schema, the file has no field ids, and the column is matched by name. Plain `file()` with an explicit structure shows the same in every nesting position (top level, list element, map value, struct field). Keep the literal fallback only for a Tuple that describes the map's tree: an unnamed Tuple (matched by position), or a named Tuple that has an element named like the repeated group, matched as `processSubtreeTuple` matches it (column mapper + `case_insensitive_column_matching`). Any other Tuple now reaches the existing `parquet type is Map, requested type is ...` `TYPE_MISMATCH`, the same error every other kind mismatch in this reader raises. A query that does not read the column is unaffected. The check runs after the structure checks, so a MAP-annotated group without the MAP structure keeps the literal fallback for any request. A generic "a named Tuple that matches no child is an error" rule in `processSubtreeTuple` would be wrong for structs: Iceberg schema evolution (drop one field, add another) legitimately produces it and NULL is the right answer there. Only the map case is a kind mismatch. The test adds the `map_to_struct` table of the DuckDB Iceberg extension tests (duckdb/duckdb-iceberg b57f45c2c78965c71f699aa23ae73c292923668e), at the same path and with the same content as ClickHouse#130010. Closes ClickHouse#130020 Co-Authored-By: Claude Opus 5.5 <[email protected]>
A row's `_row_id` is the value stored in the data file, or `first_row_id` plus its position where the file stores NULL; `_last_updated_sequence_number` falls back to the data sequence number the same way. The manifest-level pruning used the declared bounds of a lineage column only when the column has no nulls, and otherwise the range `[0, first_row_id + record_count - 1]` (`[0, sequence number]`), which assumes a stored value is below the inherited block. Files that store values above it (compaction or copy-on-write keeping row ids, or other writers) were skipped and their rows lost: `WHERE _row_id > 1000` on the parquetry `iceberg-row-lineage/materialized` table returned nothing instead of ids 6 and 8, and the DuckDB `row_lineage_stored_columns` table (no statistics at all) lost the rows with stored `_row_id` 100/103 and sequence numbers 7/9. A file is now pruned by a lineage column only when its manifest declares bounds for it; when some rows may store NULL the range is the hull of the declared bounds and the inherited range. Without declared bounds (absent, undecodable or inverted) the file is not pruned by that column. The early returns for a missing `first_row_id`, an empty file, a negative sequence number and a block that does not fit in UInt64 stay as they were. The new test vendors both tables unmodified, at the paths used by ClickHouse#130017 and ClickHouse#130010. Closes ClickHouse#130022 Co-Authored-By: Claude Opus 5.5 <[email protected]>
The README carries the provenance and the MIT notice of the copied fixture; ClickHouse#130010 adds a README at the same path with a superset of this content (whichever lands second keeps ClickHouse#130010's). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict in `tests/queries/0_stateless/data_iceberg/duckdb/README.md`: master added the same DuckDB tables `mapping_failures/map_to_struct` and `row_lineage_stored_columns` (identical files) with a shorter README. Kept the README of this PR and mentioned the tests of master that use them.
The style check `test_numbers_check` failed with `Gap (5567, 5710) > 100`: https://s3.amazonaws.com/clickhouse-test-reports/praktika.html?PR=130010&sha=6b7203ddb41d944cead75b297d25e8d304ae3bc5&name_0=PR&name_1=Style%20check PR: #130010 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Address review: the two data files of `lineitem_iceberg` are 1.4 MB and 1.2 MB, which exceeds the size limit for test data. The table was used only by `05626_iceberg_duckdb_lineitem_time_travel`; time travel is covered by other Iceberg tests. The README lists the table among those not included. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged |
An Iceberg field added with an `initial-default` must read as that default in
every data file written before it was added (spec, "Column Projection"). The
key was never parsed, so such rows read as NULL, filters on the column missed
them, and a required field added with a default made the table unreadable.
A field absent from a data file is synthesized in two places, and both now use
the default:
- the schema evolution DAG, for a file read under its own older schema: the
constant of a new top-level field, and `AddingTransform` for a field added
inside a struct (also inside list elements and map values);
- the format reader, for a file read under the schema that has the field (its
manifest was rewritten under the newer schema and the old snapshot expired,
or a stale ClickHouse INSERT): Parquet (top level, struct elements at any
depth, requested subcolumns), ORC (top level and struct elements) and Avro
(top level), through a new `ColumnMapper` map of defaults.
The JSON single-value serialization (spec Appendix D) of every type is parsed
once in `IcebergSchemaProcessor`; a malformed default, or a non-null one for a
type that must default to null, fails with ICEBERG_SPECIFICATION_VIOLATION
instead of being ignored. A struct field's own default can only be `{}`, which
stands for the defaults of its fields.
A reader fills a field with its default only when the data file identifies
the fields at that level by field id and none of them has the field's id, the
rule ClickHouse#126879 introduced for Avro: a field missing only by name may be in the
file under another name. With that proof, ORC and Avro no longer read such a
column from a same-named field of the file (a dropped column re-added under
the same name), and ORC builds no search argument for that file, because it
resolves predicate columns by name.
The query condition cache key of UUID-less tables and the Parquet columns cache
identity now include the defaults, since the value read for an absent field
depends on them. A metadata.json schema replaces an identical copy registered
from a manifest header, which does not carry `initial-default`.
The new test reads the Apache Impala and DuckDB Iceberg tables of ClickHouse#130028 and
ClickHouse#130010 (identical files) as written and with their older data files bound to
the newer schema, and ClickHouse-written Parquet, ORC and Avro tables evolved
with nested, required, struct, list and malformed defaults.
Closes ClickHouse#129992
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tamp defaults A field whose value comes from an identity partition of the data file must read as that value, even when it is NULL, before its `initial-default` applies (spec, "Column Projection"). NULL identity values were skipped, so the reader filled the default instead; and a struct read as a whole got the defaults of its nested identity sources. NULL identity values are now applied, and the per-file column mapper drops the defaults of the file's identity partition columns (the shared mapper is replaced by the per-file one for such files). A `timestamp` / `timestamp_ns` default must be an ISO-8601 local date-time and a `timestamptz` / `timestamptz_ns` default the same with `+00:00`; the lenient parser accepted any offset (and shifted the value), a missing offset, a space separator. Other shapes now fail with ICEBERG_SPECIFICATION_VIOLATION. With `input_format_parquet_allow_missing_columns = 0`, a field proven absent by field id that has a default is not a missing column (ORC and Avro already exempt it). Adds the DuckDB `partition_values_missing_edge_cases/default/mixed` table of ClickHouse#130010 (identical files); it is not read by a test yet, since its `final.metadata.json` name is rejected (ClickHouse#129988). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ceberg tables The test came from master together with the tables it shares with this PR. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🕵 Merged I ran the tests locally with a binary built from this |
|
🕵 Merged |
|
🕵 Merged |
Adds 71 Iceberg tables from the DuckDB Iceberg extension tests as stateless tests, with the expected results taken from the extension's sqllogictest files.
Source:
data/persistentof https://github.com/duckdb/duckdb-iceberg/tree/b57f45c2c78965c71f699aa23ae73c292923668e/data/persistent (MIT License). Expected results come fromtest/sql/local/**/*.testat the same commit. The data is intests/queries/0_stateless/data_iceberg/duckdb/(1.5 MB). ItsREADME.mdgives the provenance, the license text, and lists what was left out and why:benchmark, the four lineitem copies (too large), the encrypted tables,big_query_error,generated_bounds,utf8_trunc_bounds,snapshot_refsandmissing_map_keys/missing_value. The upstream layoutdata/persistent/<table>is kept, because the table locations are relative and some manifest lists point into other tables. Non-standard metadata file names are kept as they are and selected withiceberg_metadata_file_path. No upstream file is modified. Tables with%in their file names are stored inspecial_paths.tar.Tests:
05620_iceberg_duckdb_identity_partitions: identity partitions of every primitive type, including decimals up todecimal(36, 23),time,timestamptz_nsandfixed. Also partition evolution, and identity sources missing from the data files, both top-level and nested.05621_iceberg_duckdb_deletes: equality deletes (unpartitioned, partitioned, across partitions, bucket-partitioned), legacy bare-blob deletion vectors, a moved deletion vector, and corrupted deletion-vector bitmaps.05622_iceberg_duckdb_schema_and_types:initial-defaultfor all types (top-level and in a struct), case-sensitive names, a data file from another directory,schema.name-mapping.default, data files with nested types that don't match the schema, map keys without field ids,uuid,timestamptz_ns,decimal(38, 38).05623_iceberg_duckdb_legacy_metadata: v1 deprecatedschema/partition-spec/embeddedmanifests, partition fields without field ids, snapshots withoutschema-id, v1 manifests without optional keys, v1EXISTINGentries, v1 tables upgraded to v3, and row lineage with and withoutfirst_row_id.05624_iceberg_duckdb_invalid_metadata: format version 4 and 0, missinglocation,last-updated-ms,schema-idorspec-id, a manifest newer than the table, malformed decimal types, and a manifest list with an unknown partition spec id.05625_iceberg_duckdb_filters:IS NULL,IS NOT NULL,IS DISTINCT FROM, a map with bounds, and aCASEexpression filter. Passes today.When ClickHouse has no specific error yet for invalid metadata, the test prints
rejectedfor any exception exceptPOCO_EXCEPTION,LOGICAL_ERROR,FILE_DOESNT_EXISTor a rejected metadata file name.Must be merged after the fixes of:
Related: #129990
Related: #129988
Related: #129991
Related: #129992
Related: #129995
Related: #129996
Related: #130002
Related: #130019
Related: #130020
Related: #130021
Related: #128304
Which tests fail until those fixes, and why:
locationprefix are resolved to mangled paths (file:/vsfile:///, relative locations, data outside the table directory) #129990):05622column_mapping(path mangled toata/persistent/...),05621deletion_vector_bitmap_count,05624manifest_newer_than_tableandmanifest_list_invalid_spec_id.vN/N-uuidare rejected, even when given iniceberg_metadata_file_path#129988):05620mixed(final.metadata.json),05621vfinal.metadata.jsonanddeletion_vector_bitmap_count,05622decimal_max_precision,05623no-*/some-*/v3-no-snapshot-schema-id,05624invalid_decimal_type/manifest_list_invalid_spec_id.schema-idis required: v1 metadata withoutschema-idand snapshots withoutschema-idcannot be read (POCO_EXCEPTION) #129991):05623legacy_v1 v1,no-snapshot-schema-id,merch_v1 v3-no-snapshot-schema-id.initial-defaultis not implemented: columns added with a default are read as NULL from older data files #129992):05622add_columns_with_defaults*,05620mixed.05620nested_source,mixed.05624manifest_list_invalid_spec_id.POCO_EXCEPTIONs for missing fields,format-version0 accepted, schema checks ofapache/iceberg-verificationdisagree #130002):05623legacy_v1 v2(embeddedmanifests, POCO_EXCEPTION),05624format version 0, missinglocation/last-updated-ms/spec-id;05621equality_delete_cross_partition/equality_delete_extra_column: the snapshot id 9876543210123456789 does not fitlong(DuckDB accepts it), it has to be refused instead of POCO_EXCEPTION "Out of range: Value too large".schema.name-mapping.defaultis ignored, data files without field ids are matched by column name #130019):05622name_mappingv3.1/v3.2/v4.1.MAPcolumn is silently read as the struct of the Iceberg schema instead of a type mismatch error #130020):05622mapping_failures/map_to_struct.first_row_id(Iceberg v3:_row_id/_last_updated_sequence_numberstored in a data file withoutfirst_row_idare returned instead of NULL #130021):05623row_lineage_stored_columns.st.xfails withNOT_FOUND_COLUMN_IN_BLOCKon data files written before any schema change #128304):05622SELECT a.col1ofadd_columns_with_defaults_in_struct.Changelog category (leave one):
🤖 Generated with Claude Code
Workflow [PR]
Sync PR [sync-upstream/pr/130010]