fix(python): Allow DataTypeExpr in pl.lit()#26740
fix(python): Allow DataTypeExpr in pl.lit()#26740nameexhaustion merged 3 commits intopola-rs:mainfrom
DataTypeExpr in pl.lit()#26740Conversation
|
I think this is the wrong solution and would break on even the most trivial of pl.lit(1, pl.dtype_of(pl.col.a))I laid out some possible solutions in #26644. |
|
@coastalwhite Thanks! Will check out the issue. Wasn't sure if this was the proper fix myself |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #26740 +/- ##
==========================================
+ Coverage 81.72% 81.74% +0.01%
==========================================
Files 1806 1806
Lines 248702 248705 +3
Branches 3132 3133 +1
==========================================
+ Hits 203257 203295 +38
+ Misses 44640 44605 -35
Partials 805 805 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
nameexhaustion
left a comment
There was a problem hiding this comment.
IIUC this used to work with a cast - can we just add this casting back when we get a DataTypeExpr?
39b14cc to
8862d3d
Compare
|
Updated it to call |
Resolves #26644.
Implemented the fix on the Python side since the Rust function
pub fn lit(...)incrates/polars-python/src/functions/lazy.rsdoes not contain an equivalentdtypeargument.Used
DataTypeExpr.collect_dtype()to resolve theDataTypeExprinto a concreteDataTypeprior to running the rest of the function. Passed an empty schema ({}) to.collect_dtype()since it seems like it can resolve itself (there were many examples of just passing{}to.collect_dtype()in the method docstrings located inClass DataTypeExpr).