Support IN UNNEST(expression) (#426)

* feat: support `IN UNNEST(expression)`

* Add test for NOT IN UNNEST
This commit is contained in:
Yoshiyuki Komazaki 2022-03-01 22:53:01 +09:00 committed by GitHub
parent 2ebe18a94e
commit 0d1c5d1205
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 50 additions and 0 deletions

View file

@ -903,6 +903,27 @@ fn parse_in_subquery() {
);
}
#[test]
fn parse_in_unnest() {
fn chk(negated: bool) {
let sql = &format!(
"SELECT * FROM customers WHERE segment {}IN UNNEST(expr)",
if negated { "NOT " } else { "" }
);
let select = verified_only_select(sql);
assert_eq!(
Expr::InUnnest {
expr: Box::new(Expr::Identifier(Ident::new("segment"))),
array_expr: Box::new(verified_expr("expr")),
negated,
},
select.selection.unwrap()
);
}
chk(false);
chk(true);
}
#[test]
fn parse_string_agg() {
let sql = "SELECT a || b";