Repository: calcite
Updated Branches:
  refs/heads/master 5be0f0b04 -> 97ccd6ded


[CALCITE-1430] In Druid adapter, pagingIdentifiers might have more than one 
value (Jiarong Wei)

Requires the latest calcite-test-dataset.

Close apache/calcite#302


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

Branch: refs/heads/master
Commit: aad03def2ab2995dfdfedfe8f62605a43c7d2858
Parents: 5be0f0b
Author: Jiarong Wei <vca...@gmail.com>
Authored: Tue Oct 11 22:59:13 2016 +0800
Committer: Julian Hyde <jh...@apache.org>
Committed: Tue Oct 18 16:33:01 2016 -0700

----------------------------------------------------------------------
 .../adapter/druid/DruidConnectionImpl.java        | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/aad03def/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 f8e3431..839d2c9 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
@@ -186,16 +186,15 @@ class DruidConnectionImpl implements DruidConnection {
             if (parser.nextToken() == JsonToken.FIELD_NAME
                 && parser.getCurrentName().equals("pagingIdentifiers")
                 && parser.nextToken() == JsonToken.START_OBJECT) {
-              switch (parser.nextToken()) {
-              case FIELD_NAME:
+              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();
                 }
-                expect(parser, JsonToken.END_OBJECT);
-                break;
-              case END_OBJECT:
+                token = parser.nextToken();
               }
+              expect(token, JsonToken.END_OBJECT);
             }
             if (parser.nextToken() == JsonToken.FIELD_NAME
                 && parser.getCurrentName().equals("events")
@@ -325,9 +324,12 @@ class DruidConnectionImpl implements DruidConnection {
   }
 
   private void expect(JsonParser parser, JsonToken token) throws IOException {
-    final JsonToken t = parser.nextToken();
-    if (t != token) {
-      throw new RuntimeException("expected " + token + ", got " + t);
+    expect(parser.nextToken(), token);
+  }
+
+  private void expect(JsonToken token, JsonToken expected) throws IOException {
+    if (token != expected) {
+      throw new RuntimeException("expected " + expected + ", got " + token);
     }
   }
 

Reply via email to