JustinBinber opened a new issue, #1837:
URL: https://github.com/apache/datafusion-python/issues/1837

   ## Describe the bug
   
   `DataFrame.select_exprs()` returns the native binding's DataFrame rather 
than the documented public Python DataFrame. Chaining a normal public 
expression or a SQL-string predicate onto its result raises `TypeError`, even 
though the same filter works after `select()`.
   
   ## Reproduction
   
   ```python
   from datafusion import SessionContext, col
   
   ctx = SessionContext()
   df = ctx.from_pydict({"a": [1, 2, 3], "b": [4, 5, 6]})
   projected = df.select_exprs("a + b AS total")
   projected.filter(col("total") > 6).to_pydict()
   ```
   
   Actual:
   
   ```text
   TypeError: 'Expr' object is not an instance of 'RawExpr'
   while processing 'predicate'
   ```
   
   `projected.filter("total > 6")` also raises `TypeError` for `str`.
   
   Expected: both filters work through the public DataFrame API and return 
`{'total': [7, 9]}`. Collecting the projection alone succeeds, which is why the 
existing `select_exprs` test does not catch the broken composition.
   
   ## Cause and proposed fix
   
   The Python method returns `self.df.select_exprs(*args)` directly, while the 
Rust method returns a native `PyDataFrame`. Sibling methods such as `select()` 
and `alias()` wrap their results with `DataFrame(...)`, enabling the 
Python-level argument coercion needed by chained operations.
   
   I can contribute the same wrapper correction, regressions exercising 
public-expression and SQL-string filter chains, and a runnable docstring 
example. Native conversion methods already exist; this report is specifically 
about preserving the public chaining contract.
   
   ## Environment
   
   Reproduced on released Python package **55.0.0**, and on current Python 
sources at **878e5d3b8d373bca19671af43e49dfb1890f8da2** using that release's 
native wheel. Windows, Python **3.11.7**, PyArrow **26.0.1**. The engine 
reports **Apache DataFusion 55.2.0**, matching the version in current 
`Cargo.lock`. No external services are required.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to