[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of Polars.
Reproducible example
import polars as pl
from io import StringIO
my_csv = StringIO(
"""
"run_id","taxi_color","ride_time"
1,Red,2024-05-13 08:30:00
2,Yellow,2024-05-13 10:45:00
3,Green,2024-05-13 13:15:00
4,Blue,2024-05-13 16:20:00
5,Blue,2025-05-13 16:20:00
"""
)
df = pl.read_csv(my_csv, try_parse_dates=True)
ctx = pl.SQLContext(register_globals=True, eager_execution=False)
ctx.register("taxis", df)
query = """SELECT count(*) as total,
EXTRACT(YEAR FROM ride_time) AS yr
from taxis group by yr;
"""
sql_result = ctx.execute(query)
sql_result_collected = sql_result.collect()
print(sql_result_collected)
Log output
Traceback (most recent call last):
File "/Users/vishnuch/work/gitcode/duckberg/polar2.py", line 20, in <module>
sql_result = ctx.execute(query)
File "/Users/vishnuch/work/utils/mamba/envs/duckberg/lib/python3.10/site-packages/polars/sql/context.py", line 269, in execute
res = wrap_ldf(self._ctxt.execute(query))
polars.exceptions.ColumnNotFoundError: yr
Issue description
when we apply a function on a column and try to do group by on that projection, we get column not found.
Checks
Reproducible example
Log output
Issue description
when we apply a function on a column and try to do group by on that projection, we get column not found.
Expected behavior
the query should return:
ps: the query works in postgres and duckdb
Installed versions