Skip to content

[C++][Python] Allow creating a UnionDataset from filtered datasets #55447

Open

Description

@adamreeve

Describe the enhancement requested

Trying to create a dataset as a union of filtered datasets currently raises an error:

from pathlib import Path
import tempfile
import pyarrow as pa
import pyarrow.compute as pc
import pyarrow.dataset as ds


with tempfile.TemporaryDirectory() as temp_dir:
    temp_path = Path(temp_dir)

    t1 = pa.table({"x": [1, 1, 2, 2], "y": [1, 2, 3, 4]})
    ds.write_dataset(t1, temp_path / "t1", format="parquet")
    ds1 = ds.dataset(temp_path / "t1", format="parquet")

    t2 = pa.table({"x": [1, 1, 2, 2], "y": [5, 6, 7, 8]})
    ds.write_dataset(t2, temp_path / "t2", format="parquet")
    ds2 = ds.dataset(temp_path / "t2", format="parquet")

    ds1f = ds1.filter(pc.field("x") > 1)
    ds2f = ds2.filter(pc.field("x") < 2)

    union = ds.dataset([ds1f, ds2f])

Raises:

ValueError: Creating an UnionDataset from filtered or projected Datasets is currently not supported. Union the unfiltered datasets and apply the filter to the resulting union.

The suggested workaround is only valid if the filter applied to each dataset is the same. If the filters are different, or not all datasets are filtered, then there's currently no way to create a dataset that represents the union of these datasets.

This limitation seems to be present because the filter is only stored on the Python Dataset object, but creating a union dataset happens in C++.

Component(s)

C++, Python

Activity

  1. self-assigned this
    on Nov 9, 2026
  2. changed the title [-]Allow creating a UnionDataset from filtered datasets[/-] [+][C++][Python] Allow creating a UnionDataset from filtered datasets[/+] on Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions