gortiz commented on code in PR #16966:
URL: https://github.com/apache/pinot/pull/16966#discussion_r2409676759


##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/NullHandlingIntegrationTest.java:
##########
@@ -459,4 +459,29 @@ public Object[][] nullLiteralQueries() {
         {String.format("SELECT tan(null) FROM %s", getTableName()), "null"}
     };
   }
+
+  /// This test ensures IS_TRUE can be trimmed off on leaf stage
+  @Test(dataProvider = "useBothQueryEngines")
+  public void testFilteredAggregationNoScanInFilter(boolean 
useMultiStageQueryEngine)
+      throws Exception {
+    setUseMultiStageQueryEngine(useMultiStageQueryEngine);
+
+    String query = "SELECT city, COUNT(*), COUNT(*) FILTER(WHERE description = 
'unknown') FROM mytable GROUP BY city";
+
+    // MSE will insert IS_TRUE to the aggregate filter
+    if (useMultiStageQueryEngine) {
+      explainLogical(query,
+          "Execution Plan\n"
+              + "PinotLogicalAggregate(group=[{0}], agg#0=[COUNT($1)], 
agg#1=[COUNT($2)], aggType=[FINAL])\n"
+              + "  PinotLogicalExchange(distribution=[hash[0]])\n"
+              + "    PinotLogicalAggregate(group=[{0}], agg#0=[COUNT()], 
agg#1=[COUNT() FILTER $1], aggType=[LEAF])\n"
+              + "      LogicalProject(city=[$5], $f1=[IS TRUE(=($7, 
_UTF-8'unknown'))])\n"

Review Comment:
   > And we don't want to preserve the IS_TRUE predicate because our 
implementation of = doesn't return null?
   
   `IS_TRUE(x)` never returns null (in SQL). It is semantically equal to `x = 
true and x is not null`, which always evaluate to true or false.
   
   I think this IS_TRUE is added by Calcite to filter out nulls on the 
predicate, as it should be evaluated to true or false. Am I right Jackie?



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to