adamreeve opened a new issue, #55447:
URL: https://github.com/apache/arrow/issues/55447

   ### Describe the enhancement requested
   
   Trying to create a dataset as a union of filtered datasets currently raises 
an error:
   
   ```python
   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


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to