snleee commented on a change in pull request #5825: URL: https://github.com/apache/incubator-pinot/pull/5825#discussion_r466860397
########## File path: pinot-common/src/test/java/org/apache/pinot/sql/parsers/CalciteSqlCompilerTest.java ########## @@ -1804,4 +1819,199 @@ public void testInvalidNonAggregationGroupBy() { throw e; } } -} \ No newline at end of file + + @Test + public void testFlattenAndOr() { + { + String query = "SELECT * FROM foo WHERE col1 > 0 AND (col2 > 0 AND col3 > 0) AND col4 > 0"; + PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(query); + Function functionCall = pinotQuery.getFilterExpression().getFunctionCall(); + Assert.assertEquals(functionCall.getOperator(), SqlKind.AND.name()); + List<Expression> operands = functionCall.getOperands(); + Assert.assertEquals(operands.size(), 4); + for (Expression operand : operands) { + Assert.assertEquals(operand.getFunctionCall().getOperator(), SqlKind.GREATER_THAN.name()); + } + + BrokerRequest brokerRequest = BROKER_REQUEST_CONVERTER.convert(pinotQuery); + FilterQueryTree filterQueryTree = RequestUtils.generateFilterQueryTree(brokerRequest); + Assert.assertEquals(filterQueryTree.getOperator(), FilterOperator.AND); + List<FilterQueryTree> children = filterQueryTree.getChildren(); + Assert.assertEquals(children.size(), 4); + for (FilterQueryTree child : children) { + Assert.assertEquals(child.getOperator(), FilterOperator.RANGE); + } + } + + { + String query = "SELECT * FROM foo WHERE col1 <= 0 OR col2 <= 0 OR (col3 <= 0 OR col4 <= 0)"; + PinotQuery pinotQuery = CalciteSqlParser.compileToPinotQuery(query); + Function functionCall = pinotQuery.getFilterExpression().getFunctionCall(); + Assert.assertEquals(functionCall.getOperator(), SqlKind.OR.name()); + List<Expression> operands = functionCall.getOperands(); + Assert.assertEquals(operands.size(), 4); + for (Expression operand : operands) { + Assert.assertEquals(operand.getFunctionCall().getOperator(), SqlKind.LESS_THAN_OR_EQUAL.name()); + } + + BrokerRequest brokerRequest = BROKER_REQUEST_CONVERTER.convert(pinotQuery); + FilterQueryTree filterQueryTree = RequestUtils.generateFilterQueryTree(brokerRequest); + Assert.assertEquals(filterQueryTree.getOperator(), FilterOperator.OR); + List<FilterQueryTree> children = filterQueryTree.getChildren(); + Assert.assertEquals(children.size(), 4); + for (FilterQueryTree child : children) { + Assert.assertEquals(child.getOperator(), FilterOperator.RANGE); + } + } + + { + String query = + "SELECT * FROM foo WHERE col1 > 0 AND col2 > 0 AND col3 > 0 AND (col1 <= 0 OR col2 <= 0 OR (col3 <= 0 OR col4 <= 0)) AND col4 > 0"; Review comment: We can add `A OR B ( C AND D) OR E` for completeness. You covered the following: 1. `A AND B ( C AND D) AND E` 2. `A OR B ( C OR D) OR E` 3. `A AND B ( C OR D) AND E` ########## File path: pinot-core/src/test/java/org/apache/pinot/queries/InterSegmentAggregationMultiValueQueriesTest.java ########## @@ -157,7 +157,7 @@ public void testCastCountMV() { Assert.assertEquals(brokerResponse.getResultTable().getDataSchema().getColumnName(0), "cnt_column6"); brokerResponse = getBrokerResponseForSqlQueryWithFilter(query); - QueriesTestUtils.testInterSegmentResultTable(brokerResponse, 62480L, 874176L, 62480L, 400000L, Review comment: Why this value get changed? Did we change the underlying data or query? ---------------------------------------------------------------- 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: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org