Skip to content

fix(query): name the fix when a TIMESTAMPTZ literal meets a TIMESTAMPTZ_NS column - #365

Merged
vishr merged 2 commits into
mainfrom
fix/sql-timestamptz-literal
Oct 20, 2026
Merged

vishr merged 2 commits into
mainfrom
fix/sql-timestamptz-literal

Conversation

@vishr

@vishr vishr commented Oct 20, 2026

Copy link
Copy Markdown
Member

Problem

Panel SQL that compares a time column with a TIMESTAMPTZ literal is rejected: the engine does not cast between TIMESTAMPTZ_NS and microsecond TIMESTAMPTZ implicitly, and its message calls the column timestamp. Agents naturally write that literal; one building a before/after comparison during an incident hit this and lost a turn (#364).

Change

  • When panel SQL fails with that binder error, the problem carries a hint: compare time columns with TIMESTAMP 'YYYY-MM-DD HH:MM:SS' (UTC), or cast the literal with ::TIMESTAMPTZ_NS. The hint survives repeated presentation at each publication boundary.
  • The panel sql field, the dashboard spec guide and get_telemetry_schema state the same rule; generated MCP tool docs are regenerated.
  • Comparison semantics are unchanged; no SQL is rewritten.

Verification

  • TestSQLTimestampComparisonsReturnRepairHintOrExactResults against the real engine: the rejected literal in both operand orders gets the hint; TIMESTAMP '…' and explicit casts, including an offset literal, return exact counts at nanosecond boundaries.
  • MCP preview and presentation tests keep the hint.
  • just check, just docs-generate-check

Fixes #364

https://claude.ai/code/session_018HfyEXHyGD1utmKF4CQtyQ

vishr added 2 commits October 20, 2026 12:37
…TZ_NS column

Panel SQL that compares a time column with a TIMESTAMPTZ literal is rejected
by the engine, which does not cast between TIMESTAMPTZ_NS and microsecond
TIMESTAMPTZ implicitly, and its message calls the column "timestamp". Agents
naturally write that literal and lose a turn.

When panel SQL fails with that binder error, the problem now carries a hint:
compare time columns with TIMESTAMP 'YYYY-MM-DD HH:MM:SS' (UTC), or cast the
literal with ::TIMESTAMPTZ_NS. The panel sql field, the dashboard spec guide
and get_telemetry_schema state the same rule. Comparison semantics are
unchanged.

Fixes #364

Claude-Session: https://claude.ai/code/session_018HfyEXHyGD1utmKF4CQtyQ
The pinned engine reports a BETWEEN over a TIMESTAMPTZ_NS column and
TIMESTAMPTZ literals as "Cannot mix values of type ... in BETWEEN clause",
which the comparison pattern missed. Recognize it for the same type pair in
either order, with the same hint.

Claude-Session: https://claude.ai/code/session_018HfyEXHyGD1utmKF4CQtyQ
@vishr
vishr force-pushed the fix/sql-timestamptz-literal branch from 464610b to 43e8e52 Compare October 20, 2026 19:37
@vishr
vishr merged commit e75a4cb into main Oct 20, 2026
17 checks passed
@vishr
vishr deleted the fix/sql-timestamptz-literal branch October 20, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(query): TIMESTAMPTZ literals in panel SQL fail against TIMESTAMPTZ_NS columns

1 participant