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

karan pushed a commit to branch 27.0.0
in repository https://gitbox.apache.org/repos/asf/druid.git


The following commit(s) were added to refs/heads/27.0.0 by this push:
     new 2de86d2f18 Adding null fix for rows and col stats information. (#14617)
2de86d2f18 is described below

commit 2de86d2f18f0262a8eac189240ab2fd867d01446
Author: Karan Kumar <[email protected]>
AuthorDate: Wed Jul 19 21:16:05 2023 +0530

    Adding null fix for rows and col stats information. (#14617)
    
    * Adding null fix for rows and col stats information.
    
    * Null handling test case fix
    
    (cherry picked from commit ae168c4559edc86b79d682ab7a794a7be610bea6)
---
 .../msq/sql/resources/SqlStatementResource.java    |  4 +-
 .../msq/sql/SqlMSQStatementResourcePostTest.java   | 85 ++++++++++++++++++++++
 2 files changed, 87 insertions(+), 2 deletions(-)

diff --git 
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/resources/SqlStatementResource.java
 
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/resources/SqlStatementResource.java
index 7b92872ee6..f5268bd8fb 100644
--- 
a/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/resources/SqlStatementResource.java
+++ 
b/extensions-core/multi-stage-query/src/main/java/org/apache/druid/msq/sql/resources/SqlStatementResource.java
@@ -536,8 +536,8 @@ public class SqlStatementResource
         rows = 0L;
         size = 0L;
         for (PageInformation pageInformation : pageList.get()) {
-          rows += pageInformation.getNumRows();
-          size += pageInformation.getSizeInBytes();
+          rows += pageInformation.getNumRows() != null ? 
pageInformation.getNumRows() : 0L;
+          size += pageInformation.getSizeInBytes() != null ? 
pageInformation.getSizeInBytes() : 0L;
         }
       }
 
diff --git 
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/sql/SqlMSQStatementResourcePostTest.java
 
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/sql/SqlMSQStatementResourcePostTest.java
index 70ac5386ba..4f96b132ef 100644
--- 
a/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/sql/SqlMSQStatementResourcePostTest.java
+++ 
b/extensions-core/multi-stage-query/src/test/java/org/apache/druid/msq/sql/SqlMSQStatementResourcePostTest.java
@@ -23,6 +23,7 @@ package org.apache.druid.msq.sql;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMap;
 import org.apache.calcite.sql.type.SqlTypeName;
+import org.apache.druid.common.config.NullHandling;
 import org.apache.druid.error.DruidException;
 import org.apache.druid.java.util.common.StringUtils;
 import org.apache.druid.msq.indexing.MSQControllerTask;
@@ -336,6 +337,90 @@ public class SqlMSQStatementResourcePostTest extends 
MSQTestBase
     )));
   }
 
+  @Test
+  public void testInsert()
+  {
+    Response response = resource.doPost(new SqlQuery(
+        "insert into foo1 select  __time, dim1 , count(*) as cnt from foo 
where dim1 is not null group by 1, 2 PARTITIONED by day clustered by dim1",
+        null,
+        false,
+        false,
+        false,
+        defaultAsyncContext(),
+        null
+    ), SqlStatementResourceTest.makeOkRequest());
+    Assert.assertEquals(Response.Status.OK.getStatusCode(), 
response.getStatus());
+
+    SqlStatementResult actual = (SqlStatementResult) response.getEntity();
+
+
+    SqlStatementResult expected = new SqlStatementResult(
+        actual.getQueryId(),
+        SqlStatementState.SUCCESS,
+        MSQTestOverlordServiceClient.CREATED_TIME,
+        null,
+        MSQTestOverlordServiceClient.DURATION,
+        new ResultSetInformation(NullHandling.sqlCompatible() ? 6L : 5L, 0L, 
null, "foo1", null, null),
+        null
+    );
+    Assert.assertEquals(expected, actual);
+
+    Response getResponse = resource.doGetStatus(actual.getQueryId(), 
SqlStatementResourceTest.makeOkRequest());
+    Assert.assertEquals(Response.Status.OK.getStatusCode(), 
getResponse.getStatus());
+    Assert.assertEquals(expected, getResponse.getEntity());
+
+    Response resultsResponse = resource.doGetResults(
+        actual.getQueryId(),
+        null,
+        SqlStatementResourceTest.makeOkRequest()
+    );
+    Assert.assertEquals(Response.Status.OK.getStatusCode(), 
resultsResponse.getStatus());
+    Assert.assertNull(resultsResponse.getEntity());
+  }
+
+
+  @Test
+  public void testReplaceAll()
+  {
+    Response response = resource.doPost(new SqlQuery(
+        "replace into foo1 overwrite all select  __time, dim1 , count(*) as 
cnt from foo where dim1 is not null group by 1, 2 PARTITIONED by day clustered 
by dim1",
+        null,
+        false,
+        false,
+        false,
+        defaultAsyncContext(),
+        null
+    ), SqlStatementResourceTest.makeOkRequest());
+    Assert.assertEquals(Response.Status.OK.getStatusCode(), 
response.getStatus());
+
+    SqlStatementResult actual = (SqlStatementResult) response.getEntity();
+
+
+    SqlStatementResult expected = new SqlStatementResult(
+        actual.getQueryId(),
+        SqlStatementState.SUCCESS,
+        MSQTestOverlordServiceClient.CREATED_TIME,
+        null,
+        MSQTestOverlordServiceClient.DURATION,
+        new ResultSetInformation(NullHandling.sqlCompatible() ? 6L : 5L, 0L, 
null, "foo1", null, null),
+        null
+    );
+    Assert.assertEquals(expected, actual);
+
+    Response getResponse = resource.doGetStatus(actual.getQueryId(), 
SqlStatementResourceTest.makeOkRequest());
+    Assert.assertEquals(Response.Status.OK.getStatusCode(), 
getResponse.getStatus());
+    Assert.assertEquals(expected, getResponse.getEntity());
+
+    Response resultsResponse = resource.doGetResults(
+        actual.getQueryId(),
+        null,
+        SqlStatementResourceTest.makeOkRequest()
+    );
+    Assert.assertEquals(Response.Status.OK.getStatusCode(), 
resultsResponse.getStatus());
+    Assert.assertNull(resultsResponse.getEntity());
+  }
+
+
   private static Map<String, Object> defaultAsyncContext()
   {
     Map<String, Object> context = new HashMap<String, Object>();


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

Reply via email to