Repository navigation
[BUGFIX] clickhouse: only skip FORMAT JSON for a trailing FORMAT clause and surface query errors - #867
Open
Yash121l wants to merge 1 commit into
Open
[BUGFIX] clickhouse: only skip FORMAT JSON for a trailing FORMAT clause and surface query errors#867Yash121l wants to merge 1 commit into
Yash121l wants to merge 1 commit into
Conversation
…se and surface query errors Signed-off-by: Yash Lunawat <yash.lunawat@rtp.vc>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #842
Two problems in the ClickHouse client made panels fail without saying why.
FORMAT JSONwhenever "format" appeared anywhere in the query, so a column, alias or string literal namedformatmade ClickHouse answer in its default TSV and the JSON parse failed. It now skips the append only when the query ends with aFORMAT <name>clause (case-insensitive, optional trailing;), and not when the last words areformat ASCorformat DESCfrom an ORDER BY. FORMAT is the last clause of a ClickHouse SELECT, so the end of the query is the only place a real one can be.{ status: 'error', data: [] }. Neither caller readsstatus, so a syntax or permission error showed as "No data". The client now throws with the HTTP status and the ClickHouse message, the same way the Loki and Splunk clients do, and the panel shows the error.I left the
body.data || bodyfallback from the issue alone. #844's row normalisation already handles a non-arraydataon the series path, and changing it here would touch the logs path too.New unit tests in
click-house-client.test.tsuse a stubbed fetch: five query shapes for the FORMAT check and a 400 response that must reject with the ClickHouse message. They failed before the change.npm run test,lintandtype-checkfor the clickhouse workspace andnpm run format:checkpass.Screenshots
None, no UI changes.
Checklist
[<catalog_entry>] <commit message>naming convention using one of the followingcatalog_entryvalues:FEATURE,ENHANCEMENT,BUGFIX,BREAKINGCHANGE,DOC,IGNORE.