influxdata/influxdb · error
Error computing AND
Error message
Error computing AND
What it means
This panic fires when the DataFusion boolean AND kernel returns an error while reducing per-row boolean arrays into a single mask inside the test helper. Since all inputs are BooleanArrays produced by expression evaluation, the AND kernel is expected to always succeed; an error signals an unexpected array type or internal state.
Solutions
- Confirm every expression being reduced evaluates to a Boolean array (cast or assert result type before reducing)
- Check that as_boolean_array succeeded on both accumulator and next array
- Verify the predicate rewrite only produces boolean predicates (comparison/logical expressions)
- Test against the pinned DataFusion version; kernel error behavior can differ between releases
Example fix
// before
let bool_array = kernels::boolean::and(as_boolean_array(&acc), as_boolean_array(&arr)).expect("Error computing AND");
// after
let bool_array = kernels::boolean::and(as_boolean_array(&acc), as_boolean_array(&arr))
.unwrap_or_else(|e| panic!("AND kernel failed; check expressions are boolean: {e}")); Defensive patterns
Strategy: type-guard
Validate before calling
// Rust: confirm arrays are boolean before AND reduction
fn all_boolean(arrs: &[ArrayRef]) -> bool {
arrs.iter().all(|a| a.data_type() == &DataType::Boolean)
} Type guard
fn as_bool(arr: &ArrayRef) -> Option<&BooleanArray> { arr.as_any().downcast_ref::<BooleanArray>() } Try / catch
let bool_array = kernels::boolean::and(as_boolean_array(&acc), as_boolean_array(&arr))
.unwrap_or_else(|e| panic!("AND kernel error: {e} - verify all predicates are boolean")); Prevention
- Ensure every predicate expression evaluates to DataType::Boolean before reduction
- Downcast with as_boolean_array and handle None explicitly instead of relying on kernel errors
- Unit-test each rewrite rule's output type
- Run the boolean-reduction path against DataFusion upgrades
When it happens
Trigger: add_to_predicate's reduce step calls kernels::boolean::and on arrays that are not actually boolean (as_boolean_array failed earlier or an expression evaluated to a non-boolean type), producing an Err from the kernel.
Common situations: A rewrite rule lets a non-boolean expression (numeric/string comparison result) through to the AND reduction; a DataFusion version change alters and()'s behavior on nulls or chunked arrays.
Understand the failure class
Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.
Related errors
- Expected scalar value
- Unexpected err evaluating
- datafusion error
- error while executing plan
- Expected array value
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/91c57e2dc3ab9887.
Report an issue: GitHub.
Appendix: source
Thrown at core/predicate/src/rpc_predicate/field_rewrite.rs:186
Ok(ColumnarValue::Scalar(s)) => {
s.to_array_of_size(batch.num_rows()).unwrap_or_else(|e| {
panic!("Unexpected err converting scalar result from evaluating {expr:?} against {batch:?}: {e}")
})
}
Err(e) => panic!("Unexpected err evaluating {expr:?} against {batch:?}: {e}"),
})
// Now combine the arrays using AND to get a single output
// boolean array. For the example above, we would get
// ┌─────────┐
// │ true │
// │ false │
// │ false │
// └─────────┘
.reduce(|acc, arr| {
// apply boolean AND
let bool_array =
kernels::boolean::and(as_boolean_array(&acc), as_boolean_array(&arr))
.expect("Error computing AND");
Arc::new(bool_array) as ArrayRef
})
.unwrap();
assert_eq!(matching.len(), field_names.len());
// now find all field names with a 'true' entry in the
// corresponding row. From our example above:
// ┌──────┐
// │_field│
// │ ---- ├─────────┐
// │ "f1" │ true ◀─┼─────f1 matches
// │ "f2" │ false │
// │ "f3" │ false │
// └──────┴─────────┘
let new_fields = as_boolean_array(&matching)
.iter()
.zip(as_string_array(&field_names).iter())View on GitHub (pinned to 06200ef96b)