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

Column names are not quoted, causing SQL syntax errors #1040

Open
rivol opened this issue Oct 31, 2024 · 0 comments
Open

Column names are not quoted, causing SQL syntax errors #1040

rivol opened this issue Oct 31, 2024 · 0 comments
Labels
datasource/ClickHouse type/bug Something isn't working

Comments

@rivol
Copy link

rivol commented Oct 31, 2024

What happened:
my database has column names that include colons, e.g verification:id. the Query Builder mode in Grafana does not quote them, resulting in invalid SQL ala:
SELECT verification:id FROM "default"."verifications" LIMIT 1000
and syntax errors:

error querying the database: code: 62, message: Syntax error: failed at position 24 ('FROM'): FROM "default"."verifications" LIMIT 1000. Expected one of: token, Dot, OR, AND, IS NOT DISTINCT FROM, IS NULL, IS NOT NULL, BETWEEN, NOT BETWEEN, LIKE, ILIKE, NOT LIKE, NOT ILIKE, REGEXP, IN, NOT IN, GLOBAL IN, GLOBAL NOT IN, MOD, DIV

What you expected to happen:
the column names should be quoted. switching to SQL Editor mode and manually quoting the column name fixes the issue:
SELECT "verification:id" FROM "default"."verifications" LIMIT 1000

How to reproduce it (as minimally and precisely as possible):

  1. create table with a problematic column name in ClickHouse:
CREATE TABLE "default"."test" (
    "my:name" String
) 
ENGINE MergeTree()
ORDER BY tuple()
  1. go to Explore mode in Grafana
  2. try and query the table, including the my:name column. the error occurs.

Environment:

  • Grafana version: Grafana v11.3.0 (d9455ff7db) (running via Docker)
  • Plugin version: 4.0.2
  • OS Grafana is installed on: Docker on MacOS
@rivol rivol added datasource/ClickHouse type/bug Something isn't working labels Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datasource/ClickHouse type/bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant