Query definition succeeds but model returns error


I am creating a model from a MongoDB. It works well if I run the query manually. However, after saving the model, if I look at it in my collection I get an error: "There was a problem with your question"

Input to trim-sql-query does not match schema: e[0;33m [nil (named (not (instance? java.lang.String a-clojure.lang.PersistentArrayMap)) query-str)] e[0m

If I save it as a "question" (not a model) then I can not re-use this question in a following query and it returns the same error.

It seems caused by a "bad input value" but I am not sure how to debug/fix that.


My query:



 :card_id 101,
 :context :ad-hoc,
 "Input to trim-sql-query does not match schema: \n\n\t   [nil (named (not (instance? java.lang.String a-clojure.lang.PersistentArrayMap)) query-str)]  \n\n",
 :row_count 0,
 :running_time 0,
 :preprocessed nil,
 {:type :schema.core/error,
   {:collection "task",
    :query "[\n   {\n      \"$project\":{\n         \"_id\":\"$_id\",\n      }\n   },\n   { $limit: 10 }\n]"}],
  :error [nil (named (not (instance? java.lang.String a-clojure.lang.PersistentArrayMap)) query-str)]},
 :data {:rows [], :cols []}}

@nicolasrannou Same issue reported Error while referring mongodb native query in another question - Get Help - Metabase Discussion

Also the issue is reported on github too.

@Luiggi This issue seems a major blocker for folks working with MongoDB native queries. Please prioritise accordingly.

1 Like

Thanks for the pointers!

In my case I think it is somehow related to the Input table somehow because it only happens with a specific one, but I have no clue how to best debug it / fix it because I can not do much about the data I have to work with and that's were I hope models can help with (convert data to something easy to use)

@Luiggi @TonyC @flamber Any update on resolution of native queries issue?

just put a P1 on it so our team can pick it up when they find some bandwidth