bug: resolving chained mutations using deferred expressions fails
What happened?
Problem
Minimal reproducible example:
import ibis
from ibis.common.deferred import _
import pandas as pd
df = pd.DataFrame({'a': [1, 2, 3], 'b': [4, 5, 6]})
table = ibis.memtable(df)
expr = _.mutate(c=_.a + _.b).mutate(d=_.c * 2)
result = expr.resolve(table)Error:
AttributeError: 'Table' object has no attribute 'c'Details
One would expect that _.mutate(...).mutate(...).resolve(table) would behave the same as table.mutate(...).mutate(...), but the former fails while the latter works.
Deferred expression generally are underdocumented. .resolve(...) method for deferred expressions is not documented at all.
Commentary
My understanding of deferred expressions is the primary purpose is to eliminate unnecessary usage of lambda functions and intermediate variables, making expression chaining easier. There is a second, perhaps unintended, usage for building general-purpose reusable data transformations, not tied to a specific table. This second usage is affected most by this.
What version of ibis are you using?
11.0.0
What backend(s) are you using, if any?
ibis.memtable (but applies to any backend)
Relevant log output
AttributeError: 'Table' object has no attribute 'c'Code of Conduct
- I agree to follow this project's Code of Conduct
Source: ibis-project/ibis