For LazyFrames, we can support Expr.filter so long as it's followed by an aggregation. This should already be validated at the Narwhals level, I don't think anything needs changing there
For spark-like, Column.filter doesn't exist, but we can use F.expr to accomplish the same:
from sqlframe.duckdb import DuckDBSession
import sqlframe.duckdb.functions as F
df = DuckDBSession().createDataFrame(pd.DataFrame({'a': [1,1,2], 'b': [4,5,6]}))
df = df.select(
F.expr('sum(b) filter (where a==1)').alias('c'),
F.expr('sum(b) filter (where a!=1)').alias('d'),
)
df.show()
+---+---+
| c | d |
+---+---+
| 9 | 6 |
+---+---+
If anyone fancies implementing Expr.filter for _spark_like using the above, then my hope is that it will "just work", similar to how it currently works for Dask
For LazyFrames, we can support
Expr.filterso long as it's followed by an aggregation. This should already be validated at the Narwhals level, I don't think anything needs changing thereFor spark-like,
Column.filterdoesn't exist, but we can useF.exprto accomplish the same:If anyone fancies implementing
Expr.filterfor_spark_likeusing the above, then my hope is that it will "just work", similar to how it currently works for Dask