Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/eql-mapper/src/inference/infer_type_impls/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -436,18 +436,13 @@ impl<'ast> InferType<'ast, Expr> for TypeInferencer<'ast> {
self.unify_node_with_type(this_expr, elem_ty)?;
}

Expr::Array(Array { elem, named: false }) => {
Expr::Array(Array { elem, named: _ }) => {
// Constrain all elements of the array to be the same type.
let elem_ty = self.unify_all_with_type(elem, self.fresh_tvar())?;
let array_ty = Type::array(elem_ty);
self.unify_node_with_type(this_expr, array_ty)?;
}

Expr::Array(Array {
elem: _,
named: true,
}) => Err(TypeError::UnsupportedSqlFeature("named arrays".to_string()))?,

// interval is unmapped, value is unmapped
Expr::Interval(interval) => {
self.unify_node_with_type(this_expr, Type::any_native())?;
Expand Down
12 changes: 12 additions & 0 deletions packages/eql-mapper/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1351,4 +1351,16 @@ mod test {
Err(err) => panic!("type check failed: {err}"),
}
}

#[test]
fn supports_named_arrays() {
let schema = resolver(schema! {
tables: {
}
});

let statement = parse("SELECT ARRAY[1, 2, 3]");

type_check(schema, &statement).expect("named arrays should be supported");
}
}