Skip to content

Nested macros silently broken in 4.19.0 — macro-as-argument no longer expands #781

Description

@slaughtlaught

Summary

As of 4.19.0, queries that pass one macro as an argument to another — e.g. $__timeInterval($__fromTime) — are broken.
This worked in versions prior to 4.19.0 and now fails at runtime with a ClickHouse UNKNOWN_IDENTIFIER (HTTP 404).
There was no deprecation notice, no changelog warning about a macro-expansion behavior change, and no error at query-build time — the breakage
only surfaces when ClickHouse rejects the query.

Severity

This is fairly critical for us. It's a silent, runtime-only break shipped in a minor version bump: dashboards and alert queries that ran for months
suddenly return no data (hard 404) with nothing failing at build/validation time. Because nothing errors until ClickHouse rejects the query, it's very easy to roll out and only discover in production. It affected a whole set of our alert queries at once. Our only remedy so far has been to pin back below 4.19.0.

Environment

  • grafana-clickhouse-datasource: 4.19.0
  • Grafana: 12.4.5
  • ClickHouse: 26.3.13.31

Minimal reproduction

Query:

SELECT $__timeInterval($__fromTime) AS from_time

Expected

Inner macro expands first, then the outer one:

SELECT toStartOfInterval(toDateTime(1752580800), toIntervalSecond(60)) AS from_time

Actual (4.19.0)

The outer macro expands but the inner $__fromTime is left verbatim and quoted
as an identifier:

SELECT toStartOfInterval(toDateTime(`$__fromTime`), toIntervalSecond(60)) AS from_time
→ Code: 47. DB::Exception: Unknown expression or function identifier '$__fromTime' ... (UNKNOWN_IDENTIFIER)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions