Skip to content

feat(expressions/visitor): add support for bool #2681

@HynekBlaha

Description

@HynekBlaha

Feature Request / Improvement

I came across this corner case when trying to construct filters additively.
pl.lit(True) was used as a base expression to which other filters were ANDed.

(
    pl.scan_iceberg(table, storage_options=storage_options)
    .filter(pl.lit(False))
    .explain()
)
>
python dataset: convert from arrow schema
expand_datasets(): python[IcebergDataset]: limit: None, project: all
IcebergDataset: to_dataset_scan(): snapshot ID: None, limit: None, projection: None, filter_columns: [], pyarrow_predicate: Some(<redacted>), iceberg_table_filter: Some(<redacted>), self._use_metadata_statistics: True
IcebergDataset: to_dataset_scan(): tbl.metadata.current_snapshot_id: 6267713928597070305
IcebergDataset: to_dataset_scan(): begin path expansion

File "python3.12/site-packages/pyiceberg/expressions/visitors.py", line 153, in visit
  raise NotImplementedError(f"Cannot visit unsupported expression: {obj}")
NotImplementedError: Cannot visit unsupported expression: False
(
    pl.scan_iceberg(table, storage_options=storage_options)
    .filter(pl.lit(True))
    .explain()
)
>
python dataset: convert from arrow schema
expand_datasets(): python[IcebergDataset]: limit: None, project: all
IcebergDataset: to_dataset_scan(): snapshot ID: None, limit: None, projection: None, filter_columns: [], pyarrow_predicate: Some(<redacted>), iceberg_table_filter: Some(<redacted>), self._use_metadata_statistics: True
IcebergDataset: to_dataset_scan(): tbl.metadata.current_snapshot_id: 6267713928597070305
IcebergDataset: to_dataset_scan(): begin path expansion

File "python3.12/site-packages/pyiceberg/expressions/visitors.py", line 153, in visit
  raise NotImplementedError(f"Cannot visit unsupported expression: {obj}")
NotImplementedError: Cannot visit unsupported expression: True

Version

pl.show_versions()
--------Version info---------
Polars:              1.35.1
Index type:          UInt64
Platform:            macOS-15.7.1-arm64-arm-64bit
Python:              3.12.9 (main, Feb  4 2025, 14:38:38) [Clang 16.0.0 (clang-1600.0.26.6)]
Runtime:             rt64
----Optional dependencies----
Azure CLI            2.70.0
adbc_driver_manager  <not installed>
altair               <not installed>
azure.identity       1.15.0
boto3                <not installed>
cloudpickle          <not installed>
connectorx           <not installed>
deltalake            <not installed>
fastexcel            <not installed>
fsspec               2024.3.1
gevent               <not installed>
google.auth          2.23.4
great_tables         <not installed>
matplotlib           3.10.5
numpy                2.2.0
openpyxl             3.1.2
pandas               2.3.1
polars_cloud         <not installed>
pyarrow              21.0.0
pydantic             2.4.2
pyiceberg            0.10.0
sqlalchemy           2.0.23
torch                <not installed>
xlsx2csv             <not installed>
xlsxwriter           <not installed>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions