Skip to content

Iceberg read optimization returns NULL for columns without manifest stats (partial column metrics, e.g. Databricks UniForm >32 columns) #2525

Closed

Description

@BorisTyshkevich

Describe the bug

With allow_experimental_iceberg_read_optimization = 1, Iceberg columns that have no per-column statistics in the manifest read as constant NULL. Their data in the Parquet file is never read. This silently returns wrong results: WHERE col IS NOT NULL returns nothing, and sum(col) returns NULL/0.

This is the partial-stats variant of #1545. #1991 added a columns_info.empty() guard, so it covers only manifests with no stats at all. When a manifest has stats for some columns, every nullable column without stats is still treated as "absent from the file" and replaced with NULL.

Iceberg column metrics are optional per column, so this is a common case:

  • Databricks UniForm / Delta → Iceberg: stats exist only for the first 32 columns (delta.dataSkippingNumIndexedCols, default 32).
  • Spark/Java writers: write.metadata.metrics.max-inferred-column-defaults (default 100), write.metadata.metrics.default=none, write.metadata.metrics.column.<col>=none.

Observed in production (26.6.4.20001.altinityantalya, Databricks Unity Catalog via DataLakeCatalog, UniForm table with 40 columns, 463 data files):

-- every data file: column_sizes = {}, value_counts = {}, null_value_counts has field ids 1..32 only
SELECT arraySort(mapKeys(null_value_counts)) ids, length(mapKeys(value_counts)), length(mapKeys(column_sizes)), count()
FROM system.iceberg_files WHERE database = '<db>' AND table = '<table>' GROUP BY ALL;
-- [1..32]  0  0  463
column (position) allow_experimental_iceberg_read_optimization SELECT c ... WHERE c IS NOT NULL LIMIT 5
col #16 (has stats) 1 5 rows
col #38 (no stats) 1 0 rows
col #38 (no stats) 0 5 rows

Root cause

StorageObjectStorageSource::createReader, antalya-26.6:

if (!file_meta_data.value()->columns_info.empty())
{
    for (const auto & column : requested_columns_list)
    {
        if (file_meta_data.value()->columns_info.contains(column_name))
            continue;
        ...
        /// Column is nullable and absent in file
        constant_columns_with_values[...] = {..., Field()};

columns_info is built in DataFileMetaInfo::DataFileMetaInfo (IDataLakeMetadata.cpp) only from the field ids found in value_counts / column_sizes / null_value_counts (AvroForIcebergDeserializer.cpp). A column missing from those maps is not necessarily missing from the file. Missing stats can't tell you whether the column is present.

Proposed fix

Base "absent in file" on the file's schema (file_schema_id, already passed to the DataFileMetaInfo constructor), not on whether stats are present. For example, in DataFileMetaInfo::DataFileMetaInfo, add an empty ColumnInfo entry for every table column whose field id exists in the file schema. Then createReader only replaces columns that really were added after the file was written. Both toJson and the binary serialize already round-trip entries with no fields set, so *Cluster tasks keep working.

Workaround

SET allow_experimental_iceberg_read_optimization = 0

Expected behavior

Columns without stats are read from the data file.

Related: #1545, #1991, #1669

Activity

  1. self-assigned this
    on Oct 9, 2026
  2. ianton-ru commented on Nov 4, 2026

    @ianton-ru

    Solved in #2527

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

Metadata

Metadata

Assignees

Labels

antalyaantalya-26.6bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions