Polars Stream Failing (0.54.4) Failing
⚓ Rust 📅 2026-07-19 👤 surdeus 👁️ 2A noob Rust developer, interested in quantitative trading and trying to basically write a parquet file containing mock Tick data. This is how the code looks like.
use polars::prelude::{Column, DataFrame, ParquetWriter};
use quant_data_platform::tick::{Side, Tick, TimestampNs};
use std::error::Error;
use std::fs;
use std::path::Path;
const DEFAULT_ROWS: usize = 10u32.pow(7) as usize;
fn main() -> Result<(), Box<dyn Error>> {
let rows: usize = DEFAULT_ROWS;
let mut instruments: Vec<u8> = Vec::with_capacity(rows);
let mut sides: Vec<&str> = Vec::with_capacity(rows);
let mut prices: Vec<u32> = Vec::with_capacity(rows);
let mut volumes: Vec<u8> = Vec::with_capacity(rows);
let mut timestamps_ns: Vec<TimestampNs> = Vec::with_capacity(rows);
for _ in 0..rows {
let tick: Tick = Tick::get_random_tick();
instruments.push(tick.instrument);
sides.push(match tick.side {
Side::BUY => "BUY",
Side::SELL => "SELL",
});
prices.push(tick.price);
volumes.push(tick.volume);
timestamps_ns.push(tick.ts);
}
let mut df: DataFrame = DataFrame::new_infer_height(vec![
Column::new("instrument".into(), instruments),
Column::new("side".into(), sides),
Column::new("price".into(), prices),
Column::new("volume".into(), volumes),
Column::new("ts_ns".into(), timestamps_ns),
])?;
let filename: String = String::from("data_dump/mock_data.parquet");
if let Some(parent) = Path::new(&filename).parent() {
fs::create_dir_all(parent)?;
}
let file: fs::File = fs::File::create(&filename)?;
let bytes: u64 = ParquetWriter::new(file).finish(&mut df)?;
println!("wrote {rows} ticks to file {output} of {bytes} bytes");
Ok(())
}
And this is Cargo.toml.
[package]
name = "quant-data-platform"
version = "0.1.0"
edition = "2024"
[dependencies]
chrono = "0.4.45"
polars = { version = "0.54.4", features = ["parquet", "dtype-u8", "lazy"] }
rand = "0.10.2"
The error I am facing seems to be coming right out of polars, rather than my own code. Here is the stacktrace.
error[E0599]: no variant, associated function, or constant named `StringExpr` found for enum `polars_plan::plans::IRFunctionExpr` in the current scope
--> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/polars-stream-0.54.4/src/physical_plan/lower_expr.rs:1533:37
|
1533 | IRFunctionExpr::StringExpr(IRStringFunction::Strptime(ref dtype, ref options)),
| ^^^^^^^^^^ variant, associated function, or constant not found in `polars_plan::plans::IRFunctionExpr`
|
help: there is a variant with a similar name
|
1533 - IRFunctionExpr::StringExpr(IRStringFunction::Strptime(ref dtype, ref options)),
1533 + IRFunctionExpr::StructExpr(IRStringFunction::Strptime(ref dtype, ref options)),
|
error[E0433]: cannot find type `IRStringFunction` in this scope
--> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/polars-stream-0.54.4/src/physical_plan/lower_expr.rs:1533:48
|
1533 | IRFunctionExpr::StringExpr(IRStringFunction::Strptime(ref dtype, ref options)),
| ^^^^^^^^^^^^^^^^ use of undeclared type `IRStringFunction`
|
help: an enum with a similar name exists
|
1533 - IRFunctionExpr::StringExpr(IRStringFunction::Strptime(ref dtype, ref options)),
1533 + IRFunctionExpr::StringExpr(IRStructFunction::Strptime(ref dtype, ref options)),
|
Some errors have detailed explanations: E0433, E0599.
For more information about an error, try `rustc --explain E0433`.
error: could not compile `polars-stream` (lib) due to 2 previous errors
Does it mean a bug with the polars library itself? I have used polars extensively for data engineering with Python, but this is the first time I am trying this with Rust. So far as I see, the error points to the library code rather than my own.
1 post - 1 participant
🏷️ Rust_feed