You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@calcite.apache.org by jc...@apache.org on 2017/04/10 08:23:57 UTC

calcite git commit: [CALCITE-1734] Fix select query result parsing with druid 0.9.2 (Nishant Bangarwa)

Repository: calcite
Updated Branches:
  refs/heads/master 95c691846 -> 9f87b6669


[CALCITE-1734] Fix select query result parsing with druid 0.9.2 (Nishant Bangarwa)

Close apache/calcite#416


Project: http://git-wip-us.apache.org/repos/asf/calcite/repo
Commit: http://git-wip-us.apache.org/repos/asf/calcite/commit/9f87b666
Tree: http://git-wip-us.apache.org/repos/asf/calcite/tree/9f87b666
Diff: http://git-wip-us.apache.org/repos/asf/calcite/diff/9f87b666

Branch: refs/heads/master
Commit: 9f87b666976181d7946aa9c6c4fefef01c53858c
Parents: 95c6918
Author: Nishant Bangarwa <ni...@gmail.com>
Authored: Mon Apr 10 09:22:31 2017 +0100
Committer: Jesus Camacho Rodriguez <jc...@apache.org>
Committed: Mon Apr 10 09:23:07 2017 +0100

----------------------------------------------------------------------
 .../adapter/druid/DruidConnectionImpl.java      | 59 +++++++++++---------
 1 file changed, 32 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/9f87b666/druid/src/main/java/org/apache/calcite/adapter/druid/DruidConnectionImpl.java
----------------------------------------------------------------------
diff --git a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidConnectionImpl.java b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidConnectionImpl.java
index 036a2e1..b9b860a 100644
--- a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidConnectionImpl.java
+++ b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidConnectionImpl.java
@@ -188,36 +188,41 @@ class DruidConnectionImpl implements DruidConnection {
           if (parser.nextToken() == JsonToken.FIELD_NAME
               && parser.getCurrentName().equals("result")
               && parser.nextToken() == JsonToken.START_OBJECT) {
-            if (parser.nextToken() == JsonToken.FIELD_NAME
-                && parser.getCurrentName().equals("pagingIdentifiers")
-                && parser.nextToken() == JsonToken.START_OBJECT) {
-              JsonToken token = parser.nextToken();
-              while (parser.getCurrentToken() == JsonToken.FIELD_NAME) {
-                page.pagingIdentifier = parser.getCurrentName();
-                if (parser.nextToken() == JsonToken.VALUE_NUMBER_INT) {
-                  page.offset = parser.getIntValue();
+            while (parser.nextToken() == JsonToken.FIELD_NAME) {
+              if (parser.getCurrentName().equals("pagingIdentifiers")
+                  && parser.nextToken() == JsonToken.START_OBJECT) {
+                JsonToken token = parser.nextToken();
+                while (parser.getCurrentToken() == JsonToken.FIELD_NAME) {
+                  page.pagingIdentifier = parser.getCurrentName();
+                  if (parser.nextToken() == JsonToken.VALUE_NUMBER_INT) {
+                    page.offset = parser.getIntValue();
+                  }
+                  token = parser.nextToken();
                 }
-                token = parser.nextToken();
-              }
-              expect(token, JsonToken.END_OBJECT);
-            }
-            if (parser.nextToken() == JsonToken.FIELD_NAME
-                && parser.getCurrentName().equals("events")
-                && parser.nextToken() == JsonToken.START_ARRAY) {
-              while (parser.nextToken() == JsonToken.START_OBJECT) {
-                expectScalarField(parser, "segmentId");
-                expectScalarField(parser, "offset");
-                if (parser.nextToken() == JsonToken.FIELD_NAME
-                    && parser.getCurrentName().equals("event")
-                    && parser.nextToken() == JsonToken.START_OBJECT) {
-                  parseFields(fieldNames, fieldTypes, posTimestampField, rowBuilder, parser);
-                  sink.send(rowBuilder.build());
-                  rowBuilder.reset();
-                  page.totalRowCount += 1;
+                expect(token, JsonToken.END_OBJECT);
+              } else if (parser.getCurrentName().equals("events")
+                  && parser.nextToken() == JsonToken.START_ARRAY) {
+                while (parser.nextToken() == JsonToken.START_OBJECT) {
+                  expectScalarField(parser, "segmentId");
+                  expectScalarField(parser, "offset");
+                  if (parser.nextToken() == JsonToken.FIELD_NAME
+                      && parser.getCurrentName().equals("event")
+                      && parser.nextToken() == JsonToken.START_OBJECT) {
+                    parseFields(fieldNames, fieldTypes, posTimestampField, rowBuilder, parser);
+                    sink.send(rowBuilder.build());
+                    rowBuilder.reset();
+                    page.totalRowCount += 1;
+                  }
+                  expect(parser, JsonToken.END_OBJECT);
+                }
+                parser.nextToken();
+              } else if (parser.getCurrentName().equals("dimensions")
+                  || parser.getCurrentName().equals("metrics")) {
+                expect(parser, JsonToken.START_ARRAY);
+                while (parser.nextToken() != JsonToken.END_ARRAY) {
+                  // empty
                 }
-                expect(parser, JsonToken.END_OBJECT);
               }
-              parser.nextToken();
             }
           }
         }