Hi,
I'm using Metabase v0.46.2, and I'm trying to make a new native query linked to a MongoDB collection.
I have defined a new filter of type "dropdown list", that contains 3 values :
However, it seems impossible to retrieve the value form the filter in order to use it in the query. I also tried by adding quotes around the {{period}} in the query, or even around the values of the list, but I always get the same error :
Here's the complete log .
For info, it seems that the error is similar to the one that I had described here, but I don't know if the root cause is the same.
{:database_id 2,
:started_at #t "2023-06-12T13:58:43.285845Z[GMT]",
:json_query
{:type "native",
:native
{:collection "net_banking_income",
:query
"[\n {\n $addFields: {\n period: {{period}}\n }\n },\n {\n \"$project\": {\n \"period\": 1,\n \"_id\": 1\n }\n }\n]",
:template-tags
{:period {:id "5c0da2c6-0f7f-b0a5-419c-dbdc8408cb9e", :name "period", :display-name "Period", :type "text"}}},
:database 2,
:parameters
[{:id "5c0da2c6-0f7f-b0a5-419c-dbdc8408cb9e",
:type "category",
:value ["week"],
:target ["variable" ["template-tag" "period"]]}],
:middleware {:js-int-to-string? true, :add-default-userland-constraints? true}},
:status :failed,
:class com.mongodb.MongoCommandException,
:stacktrace
["com.mongodb.internal.connection.ProtocolHelper.getCommandFailureException(ProtocolHelper.java:175)"
"com.mongodb.internal.connection.InternalStreamConnection.receiveCommandMessageResponse(InternalStreamConnection.java:302)"
"com.mongodb.internal.connection.InternalStreamConnection.sendAndReceive(InternalStreamConnection.java:258)"
"com.mongodb.internal.connection.UsageTrackingInternalConnection.sendAndReceive(UsageTrackingInternalConnection.java:99)"
"com.mongodb.internal.connection.DefaultConnectionPool$PooledConnection.sendAndReceive(DefaultConnectionPool.java:450)"
"com.mongodb.internal.connection.CommandProtocolImpl.execute(CommandProtocolImpl.java:72)"
"com.mongodb.internal.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:226)"
"com.mongodb.internal.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:269)"
"com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:131)"
"com.mongodb.internal.connection.DefaultServerConnection.command(DefaultServerConnection.java:123)"
"com.mongodb.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:343)"
"com.mongodb.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:334)"
"com.mongodb.operation.CommandOperationHelper.executeCommandWithConnection(CommandOperationHelper.java:220)"
"com.mongodb.operation.CommandOperationHelper$5.call(CommandOperationHelper.java:206)"
"com.mongodb.operation.OperationHelper.withReadConnectionSource(OperationHelper.java:463)"
"com.mongodb.operation.CommandOperationHelper.executeCommand(CommandOperationHelper.java:203)"
"com.mongodb.operation.AggregateOperationImpl.execute(AggregateOperationImpl.java:200)"
"com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:333)"
"com.mongodb.operation.AggregateOperation.execute(AggregateOperation.java:42)"
"com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:199)"
"com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:180)"
"com.mongodb.DBCollection.aggregate(DBCollection.java:1530)"
"com.mongodb.DBCollection.aggregate(DBCollection.java:1488)"
"com.mongodb.DBCollection.aggregate(DBCollection.java:1473)"
"--> driver.mongo.execute$aggregate.invokeStatic(execute.clj:142)"
"driver.mongo.execute$aggregate.invoke(execute.clj:136)"
"driver.mongo.execute$execute_reducible_query.invokeStatic(execute.clj:179)"
"driver.mongo.execute$execute_reducible_query.invoke(execute.clj:173)"
"driver.mongo$fn__120607$f__119429__auto____120608.invoke(mongo.clj:308)"
"driver.mongo.util$do_with_mongo_connection$fn__119417.invoke(util.clj:230)"
"util.ssh$do_with_ssh_tunnel.invokeStatic(ssh.clj:141)"
"util.ssh$do_with_ssh_tunnel.invoke(ssh.clj:130)"
"driver.mongo.util$do_with_mongo_connection.invokeStatic(util.clj:224)"
"driver.mongo.util$do_with_mongo_connection.invoke(util.clj:219)"
"driver.mongo$fn__120607.invokeStatic(mongo.clj:307)"
"driver.mongo$fn__120607.invoke(mongo.clj:305)"
"query_processor.context$executef.invokeStatic(context.clj:60)"
"query_processor.context$executef.invoke(context.clj:49)"
"query_processor.context.default$default_runf.invokeStatic(default.clj:68)"
"query_processor.context.default$default_runf.invoke(default.clj:66)"
"query_processor.context$runf.invokeStatic(context.clj:46)"
"query_processor.context$runf.invoke(context.clj:40)"
"query_processor.reducible$identity_qp.invokeStatic(reducible.clj:15)"
"query_processor.reducible$identity_qp.invoke(reducible.clj:12)"
"query_processor.middleware.cache$maybe_return_cached_results$maybe_return_cached_results_STAR___69172.invoke(cache.clj:224)"
"query_processor.middleware.permissions$check_query_permissions$fn__64644.invoke(permissions.clj:126)"
"query_processor.middleware.mbql_to_native$mbql__GT_native$fn__68063.invoke(mbql_to_native.clj:24)"
"query_processor$fn__70691$combined_post_process__70696$combined_post_process_STAR___70697.invoke(query_processor.clj:243)"
"query_processor$fn__70691$combined_pre_process__70692$combined_pre_process_STAR___70693.invoke(query_processor.clj:240)"
"query_processor.middleware.resolve_database_and_driver$resolve_database_and_driver$fn__69083$fn__69088.invoke(resolve_database_and_driver.clj:36)"
"driver$do_with_driver.invokeStatic(driver.clj:90)"
"driver$do_with_driver.invoke(driver.clj:86)"
"query_processor.middleware.resolve_database_and_driver$resolve_database_and_driver$fn__69083.invoke(resolve_database_and_driver.clj:35)"
"query_processor.middleware.fetch_source_query$resolve_card_id_source_tables$fn__64953.invoke(fetch_source_query.clj:310)"
"query_processor.middleware.store$initialize_store$fn__65131$fn__65132.invoke(store.clj:12)"
"query_processor.store$do_with_store.invokeStatic(store.clj:47)"
"query_processor.store$do_with_store.invoke(store.clj:41)"
"query_processor.middleware.store$initialize_store$fn__65131.invoke(store.clj:11)"
"query_processor.middleware.normalize_query$normalize$fn__69372.invoke(normalize_query.clj:25)"
"query_processor.middleware.constraints$add_default_userland_constraints$fn__66309.invoke(constraints.clj:54)"
"query_processor.middleware.process_userland_query$process_userland_query$fn__69308.invoke(process_userland_query.clj:150)"
"query_processor.middleware.catch_exceptions$catch_exceptions$fn__69685.invoke(catch_exceptions.clj:171)"
"query_processor.reducible$async_qp$qp_STAR___59455$thunk__59457.invoke(reducible.clj:103)"
"query_processor.reducible$async_qp$qp_STAR___59455.invoke(reducible.clj:109)"
"query_processor.reducible$async_qp$qp_STAR___59455.invoke(reducible.clj:94)"
"query_processor.reducible$sync_qp$qp_STAR___59467.doInvoke(reducible.clj:129)"
"query_processor$process_userland_query.invokeStatic(query_processor.clj:362)"
"query_processor$process_userland_query.doInvoke(query_processor.clj:358)"
"query_processor$fn__70739$process_query_and_save_execution_BANG___70748$fn__70751.invoke(query_processor.clj:373)"
"query_processor$fn__70739$process_query_and_save_execution_BANG___70748.invoke(query_processor.clj:366)"
"query_processor$fn__70784$process_query_and_save_with_max_results_constraints_BANG___70793$fn__70796.invoke(query_processor.clj:385)"
"query_processor$fn__70784$process_query_and_save_with_max_results_constraints_BANG___70793.invoke(query_processor.clj:378)"
"api.dataset$run_query_async$fn__86545.invoke(dataset.clj:73)"
"query_processor.streaming$streaming_response_STAR_$fn__54305$fn__54306.invoke(streaming.clj:166)"
"query_processor.streaming$streaming_response_STAR_$fn__54305.invoke(streaming.clj:165)"
"async.streaming_response$do_f_STAR_.invokeStatic(streaming_response.clj:69)"
"async.streaming_response$do_f_STAR_.invoke(streaming_response.clj:67)"
"async.streaming_response$do_f_async$task__36922.invoke(streaming_response.clj:88)"],
:card_id nil,
:context :ad-hoc,
:error
"Command failed with error 16020 (Location16020): 'Invalid $addFields :: caused by :: Expression $in takes exactly 2 arguments. 1 were passed in.' on server dxp-pm2dev-db-mongodb-shard-00-02.autgf.mongodb.net:27017. The full response is {\"ok\": 0.0, \"errmsg\": \"Invalid $addFields :: caused by :: Expression $in takes exactly 2 arguments. 1 were passed in.\", \"code\": 16020, \"codeName\": \"Location16020\", \"$clusterTime\": {\"clusterTime\": {\"$timestamp\": {\"t\": 1686578321, \"i\": 1}}, \"signature\": {\"hash\": {\"$binary\": \"GoqfBU6Mg+IpOwhVifrW2b8AhSw=\", \"$type\": \"00\"}, \"keyId\": {\"$numberLong\": \"7185157227357929478\"}}}, \"operationTime\": {\"$timestamp\": {\"t\": 1686578321, \"i\": 1}}}",
:row_count 0,
:running_time 0,
:data {:rows [], :cols []}}
[b7c3585c-b0d1-405e-b9a7-f9f771a0031e] 2023-06-12T15:58:43+02:00 DEBUG metabase.server.middleware.log POST /api/dataset 202 [ASYNC: completed] 321.5 ms (4 DB calls) App DB connections: 0/15 Jetty threads: 2/50 (5 idle, 0 queued) (144 total active threads) Queries in flight: 0 (0 queued)