pola-rs/polars · error
expected by arguments on both sides
Error message
expected by arguments on both sides
What it means
Join implementation error raised when the `by`/join-key columns expected by the join arguments are missing or mismatched on one side of the join (e.g. in _join_asof dispatch when 'on'/'left_on'/'right_on' resolution yields keys not present in both frames). The message means the join predicate cannot be satisfied on both DataFrames.
Source
Thrown at crates/polars-ops/src/frame/join/mod.rs:356
args.slice,
should_coalesce,
options.allow_eq,
options.check_sortedness,
),
(None, None) => left_df._join_asof(
other,
s_left,
s_right,
options.strategy,
options.tolerance.map(|v| v.into_value()),
args.suffix,
args.slice,
should_coalesce,
options.allow_eq,
options.check_sortedness,
),
_ => {
panic!("expected by arguments on both sides")
},
},
#[cfg(feature = "iejoin")]
JoinType::IEJoin | JoinType::Range => {
unreachable!()
},
JoinType::Cross => {
unreachable!()
},
};
}
let (lhs_keys, rhs_keys) = if (left_df.height() == 0 || other.height() == 0)
&& matches!(&args.how, JoinType::Inner)
{
// Fast path for empty inner joins.
// Return 2 dummies so that we don't row-encode.
let a = Series::full_null("".into(), 0, &DataType::Null);
(a.clone(), a)View on GitHub (pinned to 68506541d2)
Solutions
- Provide `by`/`left_by`/`right_by` key columns on both sides of the (asof) join.
- Check that the by-columns exist in both frames and are named correctly.
Defensive patterns
Strategy: validation
When it happens
Trigger: This panic/expect fires when execution reaches an unguarded state described by: "expected by arguments on both sides". 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 ("expected by arguments on both sides"). 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@68506541d2 (2026-08-19).
Data as JSON: /api/errors/c0d8d5a8865c6bfe.
Report an issue: GitHub.