Support bitwise and, or, xor (#181)

Operator precedence is coming from:

https://cloud.google.com/bigquery/docs/reference/standard-sql/operators
This commit is contained in:
Daniël Heres 2020-06-03 18:02:05 +02:00 committed by GitHub
parent 00dc490f72
commit b4699bd4a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 66 additions and 5 deletions

View file

@ -680,6 +680,27 @@ fn parse_string_agg() {
);
}
#[test]
fn parse_bitwise_ops() {
let bitwise_ops = &[
("^", BinaryOperator::BitwiseXor),
("|", BinaryOperator::BitwiseOr),
("&", BinaryOperator::BitwiseAnd),
];
for (str_op, op) in bitwise_ops {
let select = verified_only_select(&format!("SELECT a {} b", &str_op));
assert_eq!(
SelectItem::UnnamedExpr(Expr::BinaryOp {
left: Box::new(Expr::Identifier(Ident::new("a"))),
op: op.clone(),
right: Box::new(Expr::Identifier(Ident::new("b"))),
}),
select.projection[0]
);
}
}
#[test]
fn parse_between() {
fn chk(negated: bool) {