Skip to content

test: cover a native Iceberg read of a data file that omits an optional nested field - #7359

Open
yunchipang wants to merge 2 commits into
apache:mainfrom
yunchipang:test/iceberg-omitted-optional-nested-field
Open

yunchipang wants to merge 2 commits into
apache:mainfrom
yunchipang:test/iceberg-omitted-optional-nested-field

Conversation

@yunchipang

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #7033.

Rationale for this change

The native Iceberg scan failed with Incorrect number of arrays for StructArray fields, expected 2 got 1 when a data file omitted an optional nested field without a schema change. The iceberg-rust bump in #7028 fixed this, since iceberg-rust now matches nested fields by field id and fills in missing ones with NULLs. Nothing tested this case.

What changes are included in this PR?

A test in CometIcebergNativeSuite that writes a data file without s.b and l.element.y, using write.spark.accept-any-schema. It then checks that the native scan matches Spark, with nested schema pruning on and off.

How are these changes tested?

The new test passes on main. On the parent of #7028, it fails with the error from the issue.

@github-actions github-actions Bot added enhancement New feature or request test Testing related area:Iceberg labels Oct 31, 2026

@sunchao sunchao left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The new regression passed on Spark 4.1.3 with Iceberg 1.11. I inspected the Parquet footers produced by the same fixture and confirmed that the narrow files omit both nested leaves. One assertion would preserve that coverage as the writer changes.

SELECT 3, CAST(NULL AS STRUCT<a: INT>), CAST(NULL AS ARRAY<STRUCT<x: INT>>)
""")
.writeTo(table)
.append()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Could the test check that at least one appended Parquet file lacks both s.b and the list element’s y leaf? If a writer upgrade materializes them as all-null columns, both Spark comparisons and the native-plan assertion will still pass, and the test will stop exercising #7033. This suite already reads file_path from the Iceberg files table and opens its footer with ParquetFileReader.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

thanks! added a footer check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Iceberg enhancement New feature or request test Testing related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Native Iceberg scan fails when a data file omits an optional nested field

2 participants