librasteve
librasteve

Reputation: 7571

lazy() method not found in `polars::prelude::DataFrame`

I am writing an extern lib for Polars in Rust (for consumption by Raku::Dan) and would like to get out an opaque container for a LazyFrame object by calling df.lazy().

use polars::prelude::*;//{CsvReader, DataType, DataFrame, Series};
use polars::prelude::{Result as PolarResult};
use polars_lazy::prelude::*;

// LazyFrame Container

pub struct LazyFrameC {
    lf: LazyFrame,
}

impl LazyFrameC {
    fn new(ptr: *mut DataFrameC) -> LazyFrameC {
        LazyFrameC {
            lf: (*ptr).df.lazy(),
        }
    }
}
// extern functions for LazyFrame Container
#[no_mangle]
pub extern "C" fn lf_new(ptr: *mut DataFrameC) -> *mut LazyFrameC {
    let df_c = unsafe {
        assert!(!ptr.is_null());
        &mut *ptr
    };

    Box::into_raw(Box::new(LazyFrameC::new(ptr)))
}

Does not work, gives the error:

error[E0599]: no method named `lazy` found for struct `polars::prelude::DataFrame` in the current scope
   --> src/lib.rs:549:27
    |
549 |             lf: (*ptr).df.lazy(), 
    |                           ^^^^ method not found in `polars::prelude::DataFrame`

Here's my Cargo.toml (edit)...

[package]
name = "dan"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
libc = "0.2.126"
polars = "0.21.1"
polars-core = "0.22.7"
polars-lazy = "0.22.7"

[lib]
name = "dan"
path = "src/lib.rs"
crate-type = ["cdylib"

Any steer on pinning down the correct library would be much appreciated!

Upvotes: 8

Views: 2173

Answers (1)

Cory Grinstead
Cory Grinstead

Reputation: 651

Dataframe::lazy is feature flagged behind the lazy feature

try changing your cargo.toml from polars = "0.22.1" to polars = {version = "0.22.1", features = ["lazy"]}

Upvotes: 4

Related Questions