Skip to content

Commit

Permalink
revert: Remove _readers._filter
Browse files Browse the repository at this point in the history
Feature has been adopted upstream in narwhals-dev/narwhals#1417
  • Loading branch information
dangotbanned committed Nov 24, 2024
1 parent c907dc5 commit a3b38c4
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions altair/datasets/_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def _scan_metadata(
) -> nw.LazyFrame:
frame = nw.from_native(self.scan_fn(_METADATA)(_METADATA)).lazy()
if predicates or constraints:
return _filter(frame, *predicates, **constraints)
return frame.filter(*predicates, **constraints)
return frame

@property
Expand Down Expand Up @@ -392,26 +392,6 @@ def pa_read_json(source: Any, /, **kwds) -> pa.Table:
self._scan_fn = {".parquet": pa_read_parquet}


def _filter(
frame: FrameT, *predicates: OneOrSeq[IntoExpr], **constraints: Unpack[Metadata]
) -> FrameT:
"""
``narwhals`` only accepts ``filter(*predicates)``.
So we convert each item in ``**constraints`` here as::
col("column_name") == literal_value
- https://github.com/narwhals-dev/narwhals/issues/1383
- https://github.com/narwhals-dev/narwhals/pull/1417
"""
return frame.filter(
nw.all_horizontal(
*chain(predicates, (nw.col(name) == v for name, v in constraints.items()))
)
)


def _extract_constraints(
name: Dataset | LiteralString, suffix: Extension | None, tag: Version | None, /
) -> Metadata:
Expand Down

0 comments on commit a3b38c4

Please sign in to comment.