Jackie-Jiang commented on code in PR #16966:
URL: https://github.com/apache/pinot/pull/16966#discussion_r2411587362


##########
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:
   Pinot leaf stage (SSE) is able to handle this within filter clause. There 
are 3 possible values for predicate: `true`, `false`, `null` (unknown). SSE 
will keep records evaluated to `true` only, thus this `IS_TRUE` is redundant
   
   `EQUALS` can evaluate to `null` when either the left hand side or right hand 
side is `null`



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