polars icon indicating copy to clipboard operation
polars copied to clipboard

rust-analyzer not resolving `col` and other `Expr`

Open EdmundsEcho opened this issue 1 year ago • 3 comments

Polars version checks

  • [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.

Issue description

The code compiles. However, when working with the rust-analyzer it seems like the array of Expr expressions are not resolved. Here is a screenshot where we see how LazyFrame is resolved, but the collection (array) of Expr aren't (highlighted in red).

Screenshot 2023-07-08 at 10 10 49 AM

I'm not sure whether this is a rust-analyzer issue, or whether polars needs to include information to help resolve it.

Reproducible example

let summary = df.lazy().groupby(["subject_idx"]).agg([
    col("prop_score_bin").first(),
    col("subject_idx_ctrl").count().alias("micro_pool_size"),
]);

Expected behavior

The rust-analyzer should have a way to resolve this code.

EdmundsEcho avatar Jul 08 '23 14:07 EdmundsEcho

That's something that's up for rust-analyzer.

ritchie46 avatar Jul 08 '23 15:07 ritchie46

To help describe the issue, I have the following series of references to find col located in the dsl module:

polars::prelude::* -> polars_lazy::prelude::*  -> crate::dsl::*

Is that how you would describe it?

EdmundsEcho avatar Jul 08 '23 16:07 EdmundsEcho

This probably isn't the best solution, but for now I have been directly installing polars_plan and sourcing with use polars_plan::dsl::col;

jacobaclarke avatar Jan 03 '24 19:01 jacobaclarke

In general this may be a case of pathological cascading public modules. pub use::* and use super::* are all over the place. It compiles, but its obviously confusing for Rust Analyzer, not to mention anyone new browsing the code base trying to figure out what's actually in scope without navigating to dozens of ::* imports.

WIGGLES-dev avatar Jun 19 '24 14:06 WIGGLES-dev