clintropolis commented on a change in pull request #10084:
URL: https://github.com/apache/druid/pull/10084#discussion_r446487510
##########
File path: core/src/test/java/org/apache/druid/math/expr/ParserTest.java
##########
@@ -172,6 +173,43 @@ public void testMixed()
validateFlatten("min(1, max(3, 4))", "(min [1, (max [3, 4])])", "1");
}
+ @Test
+ public void testBitwiseOps()
+ {
+ validateFlatten("3 & 1", "(& 3 1)", "1");
+ validateFlatten("3 & 1", "(& 3 1)", "1");
+ validateFlatten("2 & 1", "(& 2 1)", "0");
+ validateFlatten("3 | 1", "(| 3 1)", "3");
+ validateFlatten("2 | 1", "(| 2 1)", "3");
+ validateFlatten("(~1) & 7", "(& ~1 7)", "6");
+
+ validateFlatten("'2' & '1'", "(& 2 1)", "0");
+ validateFlatten("'3' | '1'", "(| 3 1)", "3");
+ validateFlatten("(~'1') & 7", "(& ~1 7)", "6");
+
+ validateFlatten("'notanumber' & '1'", "(& notanumber 1)", null);
+ validateFlatten("'3' | 'notanumber'", "(| 3 notanumber)", null);
+ validateFlatten("~'notanumber'", "~notanumber", null);
+ validateFlatten("(~'notanumber') & '7'", "(& ~notanumber 7)", null);
+ validateFlatten("(~'notanumber') | '7'", "(| ~notanumber 7)", null);
Review comment:
```'notanumber' & 1``` actually has the same problem of ending up as
`evalDouble` and exploding, so it's not _strictly_ the null constant, but
`'notanumber'` ends up as a `null` so it's the same-ish problem.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]