Skip to content

Commit

Permalink
Fix the problem where LinkedHashMap wasn't mapped correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
kawasima committed Jun 3, 2019
1 parent 49926c9 commit 0d1b8de
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/metabase/driver/gremlin/query_processor.clj
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,16 @@
(for [col columns]
(get m col)))

(defn- unnested-seq [s]
(if (and (seq? s) (= (count s) 1) (seq? (first s)))
(first s)
s))

(defn gremlin-query-results [query]
(let [result-seq (-> (.submit *gremlin-client* query)
.iterator
iterator-seq)
; _ (map println result-seq)
results (->> result-seq
(map #(condp instance? (.getObject %)
String {"item" (.getString %)}
Expand All @@ -37,10 +43,11 @@
Boolean {"item" (.getBoolean %)}
Edge (element->map (.getEdge %))
Vertex (element->map (.getVertex %))
java.util.Map (let [m (.getObject %)
k (first (.keySet m))]
{"item" k, "count" (.get m k)})
java.util.Map (let [m (.getObject %)]
(for [k (.keySet m)]
{"item" k, "count" (.get m k)}))
(.getObject %)))
unnested-seq
vec)

columns (->> results
Expand Down

0 comments on commit 0d1b8de

Please sign in to comment.