pola-rs/polars · error

with not set

Error message

with not set

What it means

In the lazy join builder, finish() resolves the right-hand frame via self.other.expect("with not set in join builder"); calling finish (or join_where which relies on the builder state) before setting `other` with .with(...) makes the Option unwrap fail and panics with this message.

Solutions

  1. Set the `with` argument (the other frame/keys) on the join builder before finishing.
  2. Verify the builder chain includes `.with(...)` prior to `.build()`/`.finish()`.
Defensive patterns

Strategy: validation

When it happens

Trigger: This panic/expect fires when execution reaches an unguarded state described by: "with not set". Typical triggers: unsupported dtype or feature-gated code path reached at runtime, invalid user input or environment variable value, calling API methods in the wrong order or on mismatched types, or data (lengths, offsets, ranges) violating the function's preconditions.

Common situations: Encountered when input data or configuration does not meet the preconditions of the throwing code path ("with not set"). Common cases: missing Cargo feature flags, mismatched dtypes/lengths between arrays or series, out-of-range temporal values, malformed environment variables, or operations on unsupported/complex nested types.


AI-assisted analysis of pola-rs/polars@5d8ebabf11 (2026-08-19). Data as JSON: /api/errors/3520fe2047b3fd7a. Report an issue: GitHub.

Appendix: source

Thrown at crates/polars-lazy/src/frame/mod.rs:2276

            .join(
                other.logical_plan,
                self.left_on,
                self.right_on,
                JoinOptions {
                    allow_parallel: self.allow_parallel,
                    force_parallel: self.force_parallel,
                    args,
                }
                .into(),
            )?
            .build();
        Ok(LazyFrame::from_logical_plan(lp, opt_state))
    }

    // Finish with join predicates
    pub fn join_where(self, predicates: Vec<Expr>) -> LazyFrame {
        let opt_state = self.lf.opt_state;
        let other = self.other.expect("with not set");

        // Decompose `And` conjunctions into their component expressions
        fn decompose_and(predicate: Expr, expanded_predicates: &mut Vec<Expr>) {
            if let Expr::BinaryExpr {
                op: Operator::And,
                left,
                right,
            } = predicate
            {
                decompose_and((*left).clone(), expanded_predicates);
                decompose_and((*right).clone(), expanded_predicates);
            } else {
                expanded_predicates.push(predicate);
            }
        }
        let mut expanded_predicates = Vec::with_capacity(predicates.len() * 2);
        for predicate in predicates {
            decompose_and(predicate, &mut expanded_predicates);

View on GitHub (pinned to 5d8ebabf11)