feat: backend dropdown for /query view#3093
feat: backend dropdown for /query view#3093msmithstubbs wants to merge 13 commits intoLogflare:mainfrom
Conversation
78fe512 to
54cf2f0
Compare
4ab1b8c to
ab3be59
Compare
| expect(ClickHouseAdaptor, :execute_query, fn _backend, query, _opts -> | ||
| assert {~S|SELECT now() AS "my_time"|, _, _, %{language: :ch_sql}} = query | ||
|
|
||
| {:ok, [%{"my_time" => "123"}]} | ||
| end) |
There was a problem hiding this comment.
shouldn't stub if can, ideally we run it against the test CH backend with test setup for it.
| test "?sql= with backend_id uses backend's language", %{conn: conn, user: user} do | ||
| backend = insert(:backend, user: user, type: :clickhouse) | ||
|
|
||
| expect(ClickHouseAdaptor, :execute_query, fn _backend, query, _opts -> |
lib/logflare/endpoints.ex
Outdated
| @spec validate_backend_sources(Query.t(), Backend.t(), String.t()) :: :ok | {:error, String.t()} | ||
| defp validate_backend_sources(%Query{backend_id: nil}, _backend, _query_string), do: :ok | ||
|
|
||
| defp validate_backend_sources( |
There was a problem hiding this comment.
i think instead of validating, since this can become quite complex, we just let the error propagate to the user as an error message, either as a flash or an alert (which might be more readable).
if a table doesn't exist then it should be quite self-explanatory that something is not configured right.
There was a problem hiding this comment.
Removed, and query run error is now rendered under the form.
Ziinc
left a comment
There was a problem hiding this comment.
overall changes look good, just hesitant on the validation logic, looks very heavy for what we need.
1220945 to
ed361c0
Compare
| {"lib/logflare_web/controllers/stripe_controller.ex", :pattern_match_cov}, | ||
| {"lib/logflare_web/live/billingaccount_live/payment_method_component.ex", :call}, | ||
| {"lib/logflare_web/live/monaco_editor_component.ex", :pattern_match}, | ||
| {"lib/logflare_web/live/endpoints/endpoints_live.ex", :unused_fun}, |
There was a problem hiding this comment.
Added to get test typings to pass.
Just pass backend adaptor error to UI.
ed361c0 to
3902ecf
Compare
c110a15 to
5935667
Compare
|
will need to put this on hold until #3035 is in, as we now have some customer backends and we can't allow non-admins to execute adhoc queries on non-permitted backends. |
Allows users to select which backend to run a query again.
/api/queryaccept an optionalbackend_id.backend_idandsqlparams are used the sql dialect will be inferred from the selected backend.ch_sql,pg_sql, orbq_sqlparam this determines the sql dialect used.Error messages
An backend error from running a query is rendered in the UI under the form. Format is slightly different depending on how the backend returns errors: