Skip to content
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

Allow pass SETTINGS together with SQL statement. #520

Closed
araujobsd opened this issue Sep 14, 2023 · 4 comments
Closed

Allow pass SETTINGS together with SQL statement. #520

araujobsd opened this issue Sep 14, 2023 · 4 comments
Assignees

Comments

@araujobsd
Copy link

Add the possibility for AST to understand queries using SETTINGS. Without SETTINGS, it is not possible to make a QUERY to use clickhouse query_cache.

What happened:
When run an SQL query that enables query_cache, the AST can't interpret the parameter SETTINGS.

Example of query:

SELECT count(*) FROM mytable SETTINGS use_query_cache=true, query_cache_ttl=300

Using the browser Inspector it is possible to see the following error:

Failed to parse SQL statement into an AST: Error: Syntax error at line 13 col 15:

  ) AS subquery SETTINGS

What you expected to happen:
Clickhouse server will receive the parameter SETTINGS and will place the query on system.query_cache and the subsequent query would have used the query_cache instead to perform a FULL query again.

How to reproduce it (as minimally and precisely as possible):
Just add any dash and create a simple SQL query adding at the end of your SQL statement SETTINGS use_query_cache=true, query_cache_ttl=300

Anything else we need to know?:

ast

Environment:

  • Grafana version: 10.1.0
  • Plugin version: 3.2.0
  • OS Grafana is installed on: Debian 12
  • User OS & Browser: Debian 12 & Firefox
@araujobsd araujobsd added datasource/ClickHouse type/bug Something isn't working labels Sep 14, 2023
@bossinc bossinc moved this from Incoming to Backlog in Partner Datasources Sep 14, 2023
@bossinc
Copy link
Collaborator

bossinc commented Sep 14, 2023

I can reproduce this. We will have a fix soon. Thank you!

@araujobsd
Copy link
Author

Thank you for the prompt reply, if you need me test it, feel free to send patch on my way and I can do the QA :)

@SpencerTorres
Copy link
Collaborator

@bossinc do you think this would be used frequently enough to have its own switch on the query builder?

@bossinc bossinc self-assigned this Sep 28, 2023
@bossinc bossinc moved this from Backlog to In Progress in Partner Datasources Sep 28, 2023
@asimpson
Copy link
Contributor

asimpson commented Oct 4, 2023

Fixed in #530

@asimpson asimpson closed this as completed Oct 4, 2023
@github-project-automation github-project-automation bot moved this from In Progress to Done in Partner Datasources Oct 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

4 participants