Skip to content

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

Open
@rivol

Description

@rivol

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    Incoming

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions