Can I get the login information of the current user in this file? For example, whether the current user is an administrator or the ID of the current user
Hi @zsk
All the user information comes from the API request /api/user/current
- it contains the ID, if theyâre Admin and much more.
I donât want to call the back-end interface anymore. Can I get the userâs information at the front-end?
@zsk All information only comes from the backend. The frontend does not have any information, it gets all the data from the backend.
Well, thank you very much. Thank you for your help.
Hello, I have a new question for youïŒHope to get your help.
In our metabase code, a large number of SQL statements are spliced as follows
I can understand SQL as follows:
But I want to write some more complex SQL statements, like the SQL statement below. How can I reflect it in the code? I tried many writing methods, but they were not implemented. I hope to get your help.
user_id_who_create_link is a field name I added to the table permission.
@zsk Thatâs called MBQL. You can read more about it here:
https://github.com/metabase/metabase/wiki/(Incomplete)-MBQL-Reference
Iâm not sure how to do sub-query, but maybe you just add another {:select ...}
Hello, I read the relevant documents, and did not explain the sub query. I try to write like this, but it's still wrong
@zsk Iâm not sure how to write a sub-query - thereâs a couple of tests with ... (SELECT ...
, but I donât know how to write them in MBQL.
Looking through some files, it seems like you should be looking at {:source-query {:native ... }}
https://github.com/metabase/metabase/blob/master/test/metabase/driver/sql/query_processor_test.clj#L161-L170
Can I only write mbql in this place?
If not, which easier SQL language can I write. What kind of specification does this simple SQL language have?
@zsk If you change it to :native
, then it has to be SQL syntax supported by your metadata database (H2, Postgres or MySQL). But I have no idea what other consequences that might have. I am not a Clojure developer.
To avoid unknown errors, Iâd better try to write mbql.
Do you have Engineer clojure over there? Maybe we can get a better answer from him. After all, after reading some data, there is no sub-query about mbql
@zsk From what I can see, you should use :source-query
for sub-queries, like I linked to.
Or you can try asking in the developer chat: https://gitter.im/metabase/metabase
@camsaul How do you make a sub-query in MBQL?
Hi @flamber @zsk. Iâm not really active on the Gitter chat, this is a better place to reach me.
If you want to make a sub-query in MBQL you can use :source-query
, which would look something like:
{:database 1
:type :query
:query {:source-query {:source-table 2
:aggregation [[:stddev [:field-id 3]]]
:breakout [[:field-id 4]]
:order-by [[[:aggregation 0] :descending]]}
:aggregation [[:avg [:field-literal "stddev" :type/Integer]]]}}
The tests in this namespace have some more examples of how source queries should look in MBQL. The $field
and similar symbols in that namespace are just a convenience macro for writing tests so we can write MBQL using table/field names instead of IDs, so replace them in your head with [:field-id ...]
forms and the like.
@flamber Hello, when I call the / api / database /: id interface (I use postman), if the session information I passed in is a normal user, the returned JSON does not have the details attribute, but the session information I passed in is an administrator, and the returned information has the details attribute
I want to know where this is controlled? What is the intention of doing soïŒ
@zsk The /api/database/:id is used in Admin > Databases, so that information is only for admins.
I would highly recommend that you use your browser developer Network-tab and browse around in the Metabase GUI. Itâs the best way to learn the API.
You can also check the source for the APIs:
https://github.com/metabase/metabase/tree/master/src/metabase/api
@flamber Hello, I compiled and packaged based on this branchïŒhttps://github.com/metabase/metabase/tree/release-0.33.xïŒ
But when I click the sign up button, an extra request is sent in the logïŒI donât think this request is necessaryïŒ
1-28 20:43:09 DEBUG middleware.log :: DELETE /api/session 204 4.8 ms (3 DB calls) Jetty threads: 5/50 (1 idle, 0 queued) (379 total active threads) Queries in flight: 0
11-28 20:43:10 ERROR middleware.log :: GET /api/database 500 5.7 ms (1 DB calls)
{:value [nil #{"/db/2/"}],
:error [(named (not (set? nil)) permissions-set) nil],
:message âInput to set-has-partial-permissions-for-set? does not match schema: \n\n\t [(named (not (set? nil)) permissions-set) nil] \n\nâ,
:type clojure.lang.ExceptionInfo,
:stacktrace
("â> models.permissions$fn__27148$set_has_partial_permissions_for_set_QMARK___27153.invoke(permissions.clj:232)"
âmodels.interface$make_perms_check_fn$_has_perms_QMARK___25924.invoke(interface.clj:252)â
âmodels.interface$make_perms_check_fn$_has_perms_QMARK___25924.invoke(interface.clj:250)â
âmodels.interface$fn__25847$fn__25856$G__25850__25865.invoke(interface.clj:184)â
âapi.database$dbs_list.invokeStatic(database.clj:148)â
âapi.database$dbs_list.invoke(database.clj:147)â
âapi.database$fn__51530.invokeStatic(database.clj:160)â
âapi.database$fn__51530.invoke(database.clj:153)â
âroutes$fn__65543$fn__65544.doInvoke(routes.clj:56)â
âmiddleware.exceptions$catch_uncaught_exceptions$fn__64265.invoke(exceptions.clj:104)â
âmiddleware.exceptions$catch_api_exceptions$fn__64262.invoke(exceptions.clj:92)â
âmiddleware.log$log_api_call$fn__65917$fn__65918.invoke(log.clj:170)â
âmiddleware.log$log_api_call$fn__65917.invoke(log.clj:164)â
âmiddleware.security$add_security_headers$fn__64228.invoke(security.clj:122)â
âmiddleware.json$wrap_json_body$fn__65622.invoke(json.clj:61)â
âmiddleware.json$wrap_streamed_json_response$fn__65640.invoke(json.clj:97)â
âmiddleware.session$bind_current_user$fn__60792$fn__60793.invoke(session.clj:209)â
âmiddleware.session$do_with_current_user.invokeStatic(session.clj:184)â
âmiddleware.session$do_with_current_user.invoke(session.clj:177)â
âmiddleware.session$bind_current_user$fn__60792.invoke(session.clj:208)â
âmiddleware.session$wrap_current_user_id$fn__60777.invoke(session.clj:161)â
âmiddleware.session$wrap_session_id$fn__60762.invoke(session.clj:123)â
âmiddleware.auth$wrap_api_key$fn__64174.invoke(auth.clj:27)â
âmiddleware.misc$maybe_set_site_url$fn__65944.invoke(misc.clj:56)â
âmiddleware.misc$bind_user_locale$fn__65947.invoke(misc.clj:72)â
âmiddleware.misc$add_content_type$fn__65932.invoke(misc.clj:28)â
âmiddleware.misc$disable_streaming_buffering$fn__65955.invoke(misc.clj:87)â)}
11-28 20:43:11 WARN middleware.log :: GET /api/user/current 404 870.0 ”s (0 DB calls)
@zsk I do not understand what you are asking or trying to do. And I donât know what âclick the sign up buttonâ means.
Besides that. Can you create a new topic? Since it sounds like whatever youâre asking now has nothing to do with the original topic.