You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by jl...@apache.org on 2019/06/24 21:14:03 UTC

[incubator-pinot] branch fix-pretty-print-response created (now 8d01dd0)

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

jlli pushed a change to branch fix-pretty-print-response
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git.


      at 8d01dd0  Fix NPE when there is no aggregation results in prettyPrintResponse method

This branch includes the following new commits:

     new 8d01dd0  Fix NPE when there is no aggregation results in prettyPrintResponse method

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



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


[incubator-pinot] 01/01: Fix NPE when there is no aggregation results in prettyPrintResponse method

Posted by jl...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

jlli pushed a commit to branch fix-pretty-print-response
in repository https://gitbox.apache.org/repos/asf/incubator-pinot.git

commit 8d01dd0748fe22c95c78a7d5b3ee61a982955c8b
Author: jackjlli <jl...@linkedin.com>
AuthorDate: Mon Jun 24 14:13:42 2019 -0700

    Fix NPE when there is no aggregation results in prettyPrintResponse method
---
 .../main/java/org/apache/pinot/tools/Quickstart.java    | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/pinot-tools/src/main/java/org/apache/pinot/tools/Quickstart.java b/pinot-tools/src/main/java/org/apache/pinot/tools/Quickstart.java
index ea50eeb..724763d 100644
--- a/pinot-tools/src/main/java/org/apache/pinot/tools/Quickstart.java
+++ b/pinot-tools/src/main/java/org/apache/pinot/tools/Quickstart.java
@@ -34,6 +34,8 @@ public class Quickstart {
 
   private static final String TAB = "\t\t";
   private static final String NEW_LINE = "\n";
+  private static final String SELECTION_RESULTS_FIELD = "selectionResults";
+  private static final String AGGREGATION_RESULTS_FIELD = "aggregationResults";
 
   public enum Color {
     RESET("\u001B[0m"), GREEN("\u001B[32m"), YELLOW("\u001B[33m"), CYAN("\u001B[36m");
@@ -53,14 +55,14 @@ public class Quickstart {
     StringBuilder responseBuilder = new StringBuilder();
 
     // Selection query
-    if (response.has("selectionResults")) {
-      JsonNode columns = response.get("selectionResults").get("columns");
+    if (response.has(SELECTION_RESULTS_FIELD)) {
+      JsonNode columns = response.get(SELECTION_RESULTS_FIELD).get("columns");
       int numColumns = columns.size();
       for (int i = 0; i < numColumns; i++) {
         responseBuilder.append(columns.get(i).asText()).append(TAB);
       }
       responseBuilder.append(NEW_LINE);
-      JsonNode rows = response.get("selectionResults").get("results");
+      JsonNode rows = response.get(SELECTION_RESULTS_FIELD).get("results");
       int numRows = rows.size();
       for (int i = 0; i < numRows; i++) {
         JsonNode row = rows.get(i);
@@ -73,8 +75,11 @@ public class Quickstart {
     }
 
     // Aggregation only query
-    if (!response.get("aggregationResults").get(0).has("groupByResult")) {
-      JsonNode aggregationResults = response.get("aggregationResults");
+    if (!response.has(AGGREGATION_RESULTS_FIELD)) {
+      return responseBuilder.toString();
+    }
+    JsonNode aggregationResults = response.get(AGGREGATION_RESULTS_FIELD);
+    if (!aggregationResults.get(0).has("groupByResult")) {
       int numAggregations = aggregationResults.size();
       for (int i = 0; i < numAggregations; i++) {
         responseBuilder.append(aggregationResults.get(i).get("function").asText()).append(TAB);
@@ -88,7 +93,7 @@ public class Quickstart {
     }
 
     // Aggregation group-by query
-    JsonNode groupByResults = response.get("aggregationResults");
+    JsonNode groupByResults = response.get(AGGREGATION_RESULTS_FIELD);
     int numGroupBys = groupByResults.size();
     for (int i = 0; i < numGroupBys; i++) {
       JsonNode groupByResult = groupByResults.get(i);


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