This is an automated email from the ASF dual-hosted git repository.

jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new fbd3e708be Fix bug with server return final aggregation result when 
null handling is enabled (#14181)
fbd3e708be is described below

commit fbd3e708be9a56f372485646ea1c4135a7226daa
Author: Yash Mayya <yash.ma...@gmail.com>
AuthorDate: Thu Oct 10 03:40:26 2024 +0530

    Fix bug with server return final aggregation result when null handling is 
enabled (#14181)
---
 .../operator/blocks/results/AggregationResultsBlock.java  |  3 ++-
 .../integration/tests/NullHandlingIntegrationTest.java    | 15 +++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git 
a/pinot-core/src/main/java/org/apache/pinot/core/operator/blocks/results/AggregationResultsBlock.java
 
b/pinot-core/src/main/java/org/apache/pinot/core/operator/blocks/results/AggregationResultsBlock.java
index 4e0a1b3063..38ac595548 100644
--- 
a/pinot-core/src/main/java/org/apache/pinot/core/operator/blocks/results/AggregationResultsBlock.java
+++ 
b/pinot-core/src/main/java/org/apache/pinot/core/operator/blocks/results/AggregationResultsBlock.java
@@ -116,7 +116,8 @@ public class AggregationResultsBlock extends 
BaseResultsBlock {
       }
       dataTableBuilder.startRow();
       for (int i = 0; i < numColumns; i++) {
-        Object result = _results.get(i);
+        Object result =
+            returnFinalResult ? 
_aggregationFunctions[i].extractFinalResult(_results.get(i)) : _results.get(i);
         if (result == null) {
           result = columnDataTypes[i].getNullPlaceholder();
           nullBitmaps[i].add(0);
diff --git 
a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/NullHandlingIntegrationTest.java
 
b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/NullHandlingIntegrationTest.java
index 765c55cc7a..cf3911a32e 100644
--- 
a/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/NullHandlingIntegrationTest.java
+++ 
b/pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/NullHandlingIntegrationTest.java
@@ -311,6 +311,21 @@ public class NullHandlingIntegrationTest extends 
BaseClusterIntegrationTestSet {
     
assertEquals(response.get("resultTable").get("rows").get(0).get(0).asInt(), 1);
   }
 
+  @Test(dataProvider = "useBothQueryEngines")
+  public void testAggregateServerReturnFinalResult(boolean 
useMultiStageQueryEngine)
+      throws Exception {
+    setUseMultiStageQueryEngine(useMultiStageQueryEngine);
+    String sqlQuery = "SET serverReturnFinalResult = true; SELECT AVG(salary) 
FROM mytable";
+    JsonNode response = postQuery(sqlQuery);
+    assertNoError(response);
+    assertEquals(5429377.34, 
response.get("resultTable").get("rows").get(0).get(0).asDouble(), 0.1);
+
+    sqlQuery = "SET serverReturnFinalResult = true; SELECT AVG(salary) FROM 
mytable WHERE city = 'does_not_exist'";
+    response = postQuery(sqlQuery);
+    assertNoError(response);
+    assertTrue(response.get("resultTable").get("rows").get(0).get(0).isNull());
+  }
+
   @Override
   protected void overrideBrokerConf(PinotConfiguration brokerConf) {
     
brokerConf.setProperty(CommonConstants.Broker.CONFIG_OF_BROKER_QUERY_ENABLE_NULL_HANDLING,
 "true");


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to