mayankshriv commented on a change in pull request #5070: Support non-literal
expressions for right-side operand in predicate comparison
URL: https://github.com/apache/incubator-pinot/pull/5070#discussion_r384123795
##########
File path:
pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java
##########
@@ -118,6 +118,56 @@ public void testFilterCaluses() {
Assert.assertEquals(func.getOperands().get(4).getLiteral().getLongValue(),
17L);
}
+ @Test
+ public void testFilterCalusesWithRightExpression() {
+ PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery("select *
from vegetables where a > b");
+ Function func = pinotQuery.getFilterExpression().getFunctionCall();
+ Assert.assertEquals(func.getOperator(), SqlKind.GREATER_THAN.name());
+
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperator(),
"MINUS");
+
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
"a");
+
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(),
"b");
+ Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(),
0L);
+ pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from
vegetables where 0 < a-b");
+ func = pinotQuery.getFilterExpression().getFunctionCall();
+ Assert.assertEquals(func.getOperator(), SqlKind.GREATER_THAN.name());
+
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperator(),
"MINUS");
+
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(0).getIdentifier().getName(),
"a");
+
Assert.assertEquals(func.getOperands().get(0).getFunctionCall().getOperands().get(1).getIdentifier().getName(),
"b");
+ Assert.assertEquals(func.getOperands().get(1).getLiteral().getLongValue(),
0L);
+
+
+ pinotQuery = CalciteSqlParser.compileToPinotQuery("select * from
vegetables where b < 100 + c");
Review comment:
Does the code handle more complex expressions such as `foo1(bar1(a-b)) <=
foo2(bar2(c/d-e)`? If so, let's add tests for those. If not, what's the plan
there? Would it ever support those cases?
----------------------------------------------------------------
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]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]