Skip to content

[Data][Delta DSv2 features][2/5] Read column-mapped Delta tables (name mode) on DataSource V2 - #68505

Draft
abhishekverma-ray wants to merge 1 commit into
abhishek/delta-features-1-min-versionfrom
abhishek/delta-features-2-column-mapping-name
Draft

abhishekverma-ray wants to merge 1 commit into
abhishek/delta-features-1-min-versionfrom
abhishek/delta-features-2-column-mapping-name

Conversation

@abhishekverma-ray

@abhishekverma-ray abhishekverma-ray commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The Delta DataSourceV2 reader now reads tables with column mapping in the name mode. These tables' data files name every column, nested fields included, by a physical name such as col-5f4a..., which only the Delta log maps to the table's column name. Part of #64854.

Before

read_delta raised NotImplementedError for column-mapped tables: reading the files by the table's column names returns nulls.

After

  • Mapping. DeltaColumnMapping holds the table schema; each field's metadata carries its physical name.
  • Reading. DeltaFileReader scans each file by physical names: the projected columns, the pinned schema (nested fields included) and the pushed-down filter, so Parquet statistics still prune row groups. It relabels the result to the logical names without copying (Array.view). A filter on a column with nested fields may name those fields logically, so it runs after the rename.
  • Statistics. deltalake reports the add actions' statistics under physical names (min.col-..., nested fields as dotted paths) but partition values under logical ones. load_add_actions renames the statistics, so log-statistics skipping is unchanged. The footer reads get the filter and projection in physical names.
  • Handled as Databricks writes these tables:
    • columns the files hold but the table doesn't (materialized row-tracking columns) are never read;
    • the partition column, which Databricks also writes into the files, is ignored, as its values come from the log;
    • files written before a column was added get nulls, as for any file missing a column.
  • The id mode still raises here; [Data][Delta DSv2 features][3/5] Read column-mapped Delta tables (id mode) on DataSource V2 #68506 adds it. The V1 reader still raises for any mode.
flowchart TD
    subgraph Before
        subgraph BS[Subsystem: IO]
            subgraph BC[Component: formats/delta]
                B0["check_delta_table_is_readable"] -->|column mapping| BX["NotImplementedError"]
            end
        end
    end
    subgraph After
        subgraph AS[Subsystem: IO]
            subgraph AC[Component: formats/delta]
                A1["load_add_actions: rename statistics to logical names"] --> A2["DeltaFileIndexer: footer filter in physical names"]
                A2 --> A3["DeltaFileReader: scan by physical names, then view as logical"]
            end
        end
    end
    classDef removed fill:#ffcdd2,stroke:#c62828,color:#000
    classDef added fill:#c8e6c9,stroke:#2e7d32,color:#000
    classDef changed fill:#fff9c4,stroke:#f9a825,color:#000
    class BX removed
    class A1,A3 added
    class A2 changed
Loading

Subsystems

IO (_internal/datasource_v2/formats/delta/, new delta_column_mapping.py); docs in the read_delta docstring.

Not a duplicate

Issue #64854 asks for column mapping; no open PR implements it (searched open PRs for "delta column mapping").

Testing

Local: pyenv with deltalake 1.5.0 and pyarrow 23.

  • Each module in its own pytest process: test_delta.py 68, test_delta_v2.py 64, tests/datasource_v2/test_delta_footer_listing.py 3, unit/datasource_v2/test_delta_file_indexer.py and test_delta_datasource_v2.py 55, test_delta_file_pruning.py 52 and test_pickle_gate_coverage.py 117, all passed.
  • deltalake can't write column mapping, so write_mapped_table writes the log by hand, shaped like a Databricks table: physical names, a nested field, the partition column and a row-tracking column in the files, a column missing from the older file, and physical-name statistics.
  • test_reads_a_mapped_table covers all rows, a filter, a partition filter, a filter on the nested column and a projection. All five fail with the reader's translation turned off.
  • test_name_mapped_statistics_skip_files (in tests/datasource_v2/test_delta_footer_listing.py, which lists the table as read_delta does) checks the statistics come back under logical names (fails without the rename) and that the listing skips the file the filter rules out. test_name_mapped_table_counts_from_the_log checks count().
  • test_delta_read_column_mapping: V1 still raises; V2 reads the name mode.
  • delta_column_mapping.py joins the pickle-gate allowlist: its only .to_arrow() converts the log's schema.
  • pre-commit passes; pyrefly as CI runs it reports no errors in the changed files.

AI assistance was used (Claude Code); every line has been reviewed by the submitter.

🤖 Generated with Claude Code

A column-mapped Delta table's data files name every column, nested fields
too, by a physical name such as `col-5f4a...`; only the log maps it to the
table's column name. read_delta raised for these tables (DATA-3770's guard),
because reading the files by the logical names returns nulls.

The DataSourceV2 reader now reads the name mode:
- DeltaColumnMapping holds the table schema, whose field metadata carries
  each physical name.
- The reader scans each file by physical names: the projected columns, the
  pinned schema (nested fields included) and the pushed-down filter, so
  Parquet statistics still prune row groups. It relabels the result to the
  logical names without copying (Array.view). A filter on a column with
  nested fields may name those fields logically, so it runs after the rename.
- deltalake reports the add actions' statistics under physical names
  (min.col-..., nested as dotted paths) but partition values under logical
  ones. load_add_actions renames the statistics, so log-statistics skipping
  is unchanged. The footer reads get the filter and projection in physical
  names.
- Columns the files hold but the table doesn't (materialized row-tracking
  columns) are never read; the partition column Databricks also writes into
  the files is ignored, as its values come from the log; files written
  before a column was added get nulls, as for any file missing a column.

The id mode still raises, and so does the V1 reader for any mode.

Tests use a hand-written log (write_mapped_table) shaped like a Databricks
table: physical names, a nested field, the partition column and a
row-tracking column in the files, a column missing from the older file, and
physical-name statistics.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Abhishek Verma <[email protected]>
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-features-1-min-version branch from 38f3321 to 198fec0 Compare November 26, 2026 03:34
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-features-2-column-mapping-name branch from ee5cc6f to 56f7081 Compare November 26, 2026 03:34

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant