Skip to content

[Data][Delta DSv2 features][5/5] Read type-widened Delta tables on DataSource V2 - #68508

Draft
abhishekverma-ray wants to merge 1 commit into
abhishek/delta-features-4-deletion-vectorsfrom
abhishek/delta-features-5-type-widening
Draft

abhishekverma-ray wants to merge 1 commit into
abhishek/delta-features-4-deletion-vectorsfrom
abhishek/delta-features-5-type-widening

Conversation

@abhishekverma-ray

Copy link
Copy Markdown
Contributor

Summary

The Delta DataSourceV2 reader now reads type-widened tables. Delta's type widening lets a column's type grow (int to long, float to double, a decimal's precision and scale, date to timestamp_ntz, ...) without rewriting the files written before, which keep the narrow type.

Before

read_delta raised for the typeWidening reader feature. deltalake 1.6.6 can't query these tables either.

After

The V2 reader needs no deltalake support for this:

  • It reads the Parquet files itself and scans each with the table schema pinned, which casts an old file's narrow columns to the wider type.
  • A filter on a column whose file type differs from the table type is already applied after that cast.
  • deltalake opens these tables and parses their statistics in the wide types.

So typeWidening and its preview name join the supported reader features.

flowchart TD
    subgraph Before
        subgraph BS[Subsystem: IO]
            B0["check_delta_table_is_readable"] -->|typeWidening| BX["NotImplementedError"]
        end
    end
    subgraph After
        subgraph AS[Subsystem: IO]
            A0["check_delta_table_is_readable: typeWidening supported"] --> A1["DeltaFileReader: scan with the table schema pinned (casts narrow files)"]
        end
    end
    classDef removed fill:#ffcdd2,stroke:#c62828,color:#000
    classDef changed fill:#fff9c4,stroke:#f9a825,color:#000
    class BX removed
    class A0 changed
Loading

Subsystems

IO (formats/delta/delta_datasource_v2.py); docs in the read_delta docstring.

Not a duplicate

No open PR adds type widening to read_delta (searched open PRs for "delta type widening").

Testing

Local: pyenv with deltalake 1.5.0 and pyarrow 23.

  • write_type_widened_table writes the log by hand, as Databricks does: the reader feature, and each column's delta.typeChanges. The first file is in the narrow types, the second in the wide ones.
  • test_reads_type_widened_columns checks the schema, the values, and a filter on each widened column: int to long, float to double, decimal(5,2) to decimal(10,4), date to timestamp_ntz.
  • pytest over test_delta.py, test_delta_v2.py and test_write_delta.py: 253 passed. tests/unit/datasource_v2/ and tests/unit/datasource/: 1591 passed.
  • 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

@abhishekverma-ray
abhishekverma-ray removed this pull request from stack #68509 November 24, 2026 08:43
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-features-5-type-widening branch from 171258d to ab7bbc8 Compare November 25, 2026 02:54
Delta's type widening lets a column's type grow (int to long, float to
double, a decimal's precision and scale, date to timestamp_ntz, ...)
without rewriting the files written before, which keep the narrow type.
Databricks turns it on for some tables. read_delta raised for the
typeWidening reader feature, and deltalake 1.6.6 can't query such tables.

The DataSourceV2 reader needs no deltalake support for it: it reads the
Parquet files itself and scans each with the table schema pinned, which
casts an old file's narrow columns to the wider type. A filter on a column
whose file type differs from the table type is already applied after that
cast. deltalake opens these tables and parses their statistics in the wide
types. So typeWidening and its preview name join the supported reader
features.

Tests write the log by hand, as Databricks does (the reader feature and each
column's delta.typeChanges), with a first file in the narrow types and a
second in the wide ones, and check the schema, the values and a filter on
each widened column.

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-4-deletion-vectors branch from 18f3b8c to efe962e Compare November 26, 2026 03:34
@abhishekverma-ray
abhishekverma-ray force-pushed the abhishek/delta-features-5-type-widening branch from ab7bbc8 to cf19ef8 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