adasari commented on code in PR #18334:
URL: https://github.com/apache/pinot/pull/18334#discussion_r3694718328


##########
pinot-core/src/test/java/org/apache/pinot/core/query/aggregation/DefaultAggregationExecutorTest.java:
##########
@@ -120,6 +120,59 @@ public void setUp()
    */
   @Test
   void testAggregation() {
+    TransformBlock transformBlock = nextTransformBlock();
+    AggregationFunction[] aggregationFunctions = 
_queryContext.getAggregationFunctions();
+    assert aggregationFunctions != null;
+    AggregationExecutor aggregationExecutor = new 
DefaultAggregationExecutor(aggregationFunctions);
+    aggregationExecutor.aggregate(transformBlock);
+    List<Object> result = aggregationExecutor.getResult();
+    for (int i = 0; i < result.size(); i++) {
+      double actual = (double) result.get(i);
+      double expected = computeAggregation(AGGREGATION_FUNCTIONS[i], 
_inputData[i]);
+      Assert.assertEquals(actual, expected,
+          "Aggregation mis-match for function " + AGGREGATION_FUNCTIONS[i] + 
", Expected: " + expected + " Actual: "
+              + actual);
+    }
+  }
+
+  /**
+   * Verifies that functions with a pre-aggregated result are not re-computed 
by scanning: the injected value is
+   * returned as-is, while functions with a {@code null} pre-aggregated entry 
are still computed from the scanned block.
+   */
+  @Test
+  void testPreAggregatedResultsSkipScan() {
+    TransformBlock transformBlock = nextTransformBlock();
+    AggregationFunction[] aggregationFunctions = 
_queryContext.getAggregationFunctions();
+    assert aggregationFunctions != null;
+
+    // Pre-aggregate only the first function (index 0 -> SUM); the rest fall 
back to scan-based execution.
+    Object[] preAggregatedResults = new Object[aggregationFunctions.length];
+    double injectedSum = 12345.0;
+    preAggregatedResults[0] = injectedSum;

Review Comment:
   metadata based aggregation check is done before populating the 
pre-aggregated result. current test case verifying the result is matching with 
pre-aggregated result when it is not null.
   
   To avoid confusion, updated the test case for max agg function.



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