-
Notifications
You must be signed in to change notification settings - Fork 75
feat: backend dropdown for /query view #3093
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
feat: backend dropdown for /query view #3093
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't stub if can, ideally we run it against the test CH backend with test setup for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done,
| 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 -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and done.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed, and query run error is now rendered under the form.
Ziinc
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
overall changes look good, just hesitant on the validation logic, looks very heavy for what we need.
d7ef484 to
1220945
Compare
Just pass backend adaptor error to UI.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added to get test typings to pass.
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: