risingwavelabs/risingwave · error
Expect Array Type
Error message
Expect Array Type
What it means
When building SOME/ALL (e.g. array containment) expressions, the builder requires the right-hand child's return type to be a list (array) so the element type can be extracted for the inner comparison expression. If the right side is a scalar or any non-list type, it bails with 'Expect Array Type'.
Source
Thrown at src/expr/core/src/expr/expr_some_all.rs:242
let outer_expr_type = prost.get_function_type().unwrap();
let (outer_children, outer_return_type) = get_children_and_return_type(prost)?;
ensure!(matches!(outer_return_type, DataType::Boolean));
let mut inner_expr_type = outer_children[0].get_function_type().unwrap();
let (mut inner_children, mut inner_return_type) =
get_children_and_return_type(&outer_children[0])?;
let mut stack = vec![];
while inner_children.len() != 2 {
stack.push((inner_expr_type, inner_return_type));
inner_expr_type = inner_children[0].get_function_type().unwrap();
(inner_children, inner_return_type) = get_children_and_return_type(&inner_children[0])?;
}
let left_expr = build_child(&inner_children[0])?;
let right_expr = build_child(&inner_children[1])?;
let DataType::List(right_list_type) = right_expr.return_type() else {
bail!("Expect Array Type");
};
let right_expr_return_type = right_list_type.into_elem();
let eval_func = {
let left_expr_input_ref = ExprNode {
function_type: Type::Unspecified as i32,
return_type: Some(left_expr.return_type().to_protobuf()),
rex_node: Some(RexNode::InputRef(0)),
};
let right_expr_input_ref = ExprNode {
function_type: Type::Unspecified as i32,
return_type: Some(right_expr_return_type.to_protobuf()),
rex_node: Some(RexNode::InputRef(1)),
};
let mut root_expr_node = ExprNode {
function_type: inner_expr_type as i32,
return_type: Some(inner_return_type.to_protobuf()),
rex_node: Some(RexNode::FuncCall(FunctionCall {View on GitHub (pinned to 6469eb736d)
Solutions
- Rewrite the query so the right operand of ANY/ALL is an array (e.g. use ARRAY[...] or an array column)
- Check the right-hand column's schema type — it may have changed from List to scalar
- Cast the right side to the expected array type if the planner allows
- If the types look correct, check the planner for a type-inference bug
Example fix
-- before SELECT * FROM t WHERE id = ANY(1); -- after SELECT * FROM t WHERE id = ANY(ARRAY[1,2,3]);
Defensive patterns
Strategy: validation
Validate before calling
-- Ensure the right operand of ANY/ALL is an array SELECT * FROM t WHERE x = ANY(ARRAY[1,2]); -- not ANY(1)
Type guard
fn is_list_type(dt: &DataType) -> bool { matches!(dt, DataType::List(_)) } Try / catch
match build_expr(node) { Err(e) if e.to_string().contains("Expect Array Type") => hint_user_to_use_array(&e), Err(e) => return Err(e), Ok(v) => v } Prevention
- Verify array-ness of columns used with ANY/ALL in queries
- Re-check column types after schema migrations
- Cast scalars explicitly with ARRAY[...] when needed
When it happens
Trigger: Writing a query where the right operand of SOME/ALL operators (like = ANY(...)) is not an array — e.g. `x = ANY(5)` or a column that resolved to a non-List type.
Common situations: Typos in queries passing a scalar instead of an array; schema changes turning an array column into scalar; planner bugs mis-typing the right operand.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- Type mismatched between else and case.
- Type mismatched between when clause and condition
- Join key types are not aligned: LHS: {outer_type:?}, RHS: {i
- Join key types are not aligned: LHS: {outer_type:?}, RHS: {i
- partition_spec_id should be a u64
AI-assisted analysis of risingwavelabs/risingwave@6469eb736d (2026-09-11).
Data as JSON: /api/errors/5d9773755752efa9.
Report an issue: GitHub.