Skip to content

Ad hoc filters: Column names with dots in them get truncated when a query is constructed #1251

Open
@ppbrs

Description

@ppbrs

What happened?

I'm using "Ad hoc filters" on a dashboard that visualizes data taken from a ClickHouse database.

Our table (runtime_resource_usage) may look like a one having nested columns, but it is flat - there are dots in some column names, which are there historically.
Column name examples: master.max_cpu.real_time_total, master.total_size.external, ...

Grafana allows creating an adhoc filter on these columns correctly, e.g. runtime_resource_usage.master.max_cpu.real_time_total > 90. However, these filters don't work: 400 (Bad Request).
Query inspector shows that everything after master is omitted (see the last line, where ' master > \'90\' '):

SELECT
  toStartOfInterval(toDateTime(time), INTERVAL 300 second) as time,
  max("master.max_cpu.real_time_total") as "master.real_time_total",
  "device"
FROM default.runtime_resource_usage
WHERE
  (time >= toDateTime(1743116629) AND time <= toDateTime(1743721429))
GROUP BY time, "device"
ORDER BY time ASC settings additional_table_filters={'default.runtime_resource_usage' : ' master > \'90\' '}

This makes me think that column names get mistakenly truncated when constructing filter expressions.

What did you expect to happen?

I would expect the last line of the query to look like this:

ORDER BY time ASC settings additional_table_filters={'default.runtime_resource_usage' : ' master.max_cpu.real_time_total > \'90\' '}

Did this work before?

I don't know

How do we reproduce it?

  1. Create a small table in ClickHouse
DROP TABLE IF EXISTS test_dots;
CREATE TABLE test_dots (
	build_number UInt32,
	`master.max_cpu.real_time_total` Float32
)
ORDER BY build_number
INSERT INTO test_dots(
	build_number,
	`master.max_cpu.real_time_total`
)
VALUES
	(1000, 70),
	(1000, 71),
	(1000, 72),
	(1000, 73),
	(1000, 74)
  1. Add a dashboard
  2. Add variables to that dashboard:
    • Ad hoc filters, filter
    • Constant, Name: clickhouse_adhoc_query, Value: default.test_dots
  3. Add a visualization to the dashboard:
SELECT
build_number,
`master.max_cpu.real_time_total`
FROM default.test_dots
  1. Add a filter: test_dots.master.max_cpu.real_time_total = 72 and observe errors in developer's panel

Is the bug inside a dashboard panel?

No response

Environment (with versions)?

Grafana: v11.6.0 (d2fdff9ee4)
OS: Ubuntu 24
Browser: Chrome

Grafana platform?

I don't know

Datasource(s)?

ClickHouse 4.8.0 plugin

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