calcite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jh...@apache.org
Subject calcite git commit: [CALCITE-1324] Druid metadata query throws exception if there are non-standard aggregators (Martin Karlsch)
Date Mon, 25 Jul 2016 17:59:47 GMT
Repository: calcite
Updated Branches:
  refs/heads/master d1f4f885c -> 6002cd280


[CALCITE-1324] Druid metadata query throws exception if there are non-standard aggregators
(Martin Karlsch)

Close apache/calcite#259


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

Branch: refs/heads/master
Commit: 6002cd2809250cdfa095235fe79a30c41218b6b6
Parents: d1f4f88
Author: Martin Karlsch <martin@karlsch.com>
Authored: Thu Jul 21 12:53:15 2016 +0200
Committer: Julian Hyde <jhyde@apache.org>
Committed: Mon Jul 25 10:09:50 2016 -0700

----------------------------------------------------------------------
 .../adapter/druid/DruidConnectionImpl.java      | 23 +++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/calcite/blob/6002cd28/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 02069df..3e4afd3 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
@@ -30,6 +30,7 @@ import org.apache.calcite.util.Holder;
 import com.fasterxml.jackson.core.JsonFactory;
 import com.fasterxml.jackson.core.JsonParser;
 import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationFeature;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.type.CollectionType;
 
@@ -341,6 +342,19 @@ class DruidConnectionImpl implements DruidConnection {
     };
   }
 
+  private boolean isSupportedType(String type) {
+    if (type.startsWith("long")) {
+      return true;
+    }
+    if (type.startsWith("double")) {
+      return true;
+    }
+    if (type.equals("hyperUnique")) {
+      return true;
+    }
+    return false;
+  }
+
   /** Reads segment metadata, and populates a list of columns and metrics. */
   void metadata(String dataSourceName, List<String> intervals,
       Map<String, SqlTypeName> fieldBuilder, Set<String> metricNameBuilder) {
@@ -353,7 +367,8 @@ class DruidConnectionImpl implements DruidConnection {
     }
     try (InputStream in0 = post(url, data, requestHeaders, 10000, 1800000);
          InputStream in = traceResponse(in0)) {
-      final ObjectMapper mapper = new ObjectMapper();
+      final ObjectMapper mapper = new ObjectMapper()
+          .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
       final CollectionType listType =
           mapper.getTypeFactory().constructCollectionType(List.class,
               JsonSegmentMetadata.class);
@@ -361,11 +376,17 @@ class DruidConnectionImpl implements DruidConnection {
       in.close();
       for (JsonSegmentMetadata o : list) {
         for (Map.Entry<String, JsonColumn> entry : o.columns.entrySet()) {
+          if (!isSupportedType(entry.getValue().type)) {
+            continue;
+          }
           fieldBuilder.put(entry.getKey(), entry.getValue().sqlType());
         }
         if (o.aggregators != null) {
           for (Map.Entry<String, JsonAggregator> entry
               : o.aggregators.entrySet()) {
+            if (!isSupportedType(entry.getValue().type)) {
+              continue;
+            }
             fieldBuilder.put(entry.getKey(), entry.getValue().sqlType());
             metricNameBuilder.add(entry.getKey());
           }


Mime
View raw message