{"record":{"id":"91c57e2dc3ab9887","repo":"influxdata/influxdb","slug":"error-computing-and","errorCode":null,"errorMessage":"Error computing AND","messagePattern":"Error computing AND","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/predicate/src/rpc_predicate/field_rewrite.rs","lineNumber":186,"sourceCode":"                Ok(ColumnarValue::Scalar(s)) => {\n                    s.to_array_of_size(batch.num_rows()).unwrap_or_else(|e| {\n                        panic!(\"Unexpected err converting scalar result from evaluating {expr:?} against {batch:?}: {e}\")\n                    })\n                }\n                Err(e) => panic!(\"Unexpected err evaluating {expr:?} against {batch:?}: {e}\"),\n            })\n            // Now combine the arrays using AND to get a single output\n            // boolean array. For the example above, we would get\n            // ┌─────────┐\n            // │  true   │\n            // │  false  │\n            // │  false  │\n            // └─────────┘\n            .reduce(|acc, arr| {\n                // apply boolean AND\n                let bool_array =\n                    kernels::boolean::and(as_boolean_array(&acc), as_boolean_array(&arr))\n                        .expect(\"Error computing AND\");\n                Arc::new(bool_array) as ArrayRef\n            })\n            .unwrap();\n\n        assert_eq!(matching.len(), field_names.len());\n\n        // now find all field names with a 'true' entry in the\n        // corresponding row. From our example above:\n        // ┌──────┐\n        // │_field│\n        // │ ---- ├─────────┐\n        // │ \"f1\" │  true ◀─┼─────f1 matches\n        // │ \"f2\" │  false  │\n        // │ \"f3\" │  false  │\n        // └──────┴─────────┘\n        let new_fields = as_boolean_array(&matching)\n            .iter()\n            .zip(as_string_array(&field_names).iter())","sourceCodeStart":168,"sourceCodeEnd":204,"githubUrl":"https://github.com/influxdata/influxdb/blob/06200ef96ba82c5f6727e5038a83af8e722c6875/core/predicate/src/rpc_predicate/field_rewrite.rs#L168-L204","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nlet bool_array = kernels::boolean::and(as_boolean_array(&acc), as_boolean_array(&arr)).expect(\"Error computing AND\");\n// after\nlet bool_array = kernels::boolean::and(as_boolean_array(&acc), as_boolean_array(&arr))\n    .unwrap_or_else(|e| panic!(\"AND kernel failed; check expressions are boolean: {e}\"));","handlingStrategy":"type-guard","validationCode":"// Rust: confirm arrays are boolean before AND reduction\nfn all_boolean(arrs: &[ArrayRef]) -> bool {\n    arrs.iter().all(|a| a.data_type() == &DataType::Boolean)\n}","typeGuard":"fn as_bool(arr: &ArrayRef) -> Option<&BooleanArray> { arr.as_any().downcast_ref::<BooleanArray>() }","tryCatchPattern":"let bool_array = kernels::boolean::and(as_boolean_array(&acc), as_boolean_array(&arr))\n    .unwrap_or_else(|e| panic!(\"AND kernel error: {e} - verify all predicates are boolean\"));","preventionTips":["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"],"tags":["rust","datafusion","test-panic","boolean-kernel"],"backgroundTag":"internal-invariant-violation","analyzedSha":"06200ef96ba82c5f6727e5038a83af8e722c6875","analyzedAt":"2026-09-19T12:55:30.003Z","contentChangedAt":"2026-09-19T12:55:30.003Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}