Repository navigation
fix(engine): bind all files when a SQL panel windows off the footer clock - #489
Merged
Merged
Conversation
…lock SQL panels file-pruned every telemetry relation to the panel's event-time window using each signal's own footer bounds, regardless of which column the statement actually windowed on. A statement that windowed on a non-clock column (e.g. $__window(end_time) or $__window(observed_time)), or that joined a windowed rollup to an unwindowed raw relation, silently dropped rows that fell outside the default prune window, violating the read-window contract. A raw signal (spans/logs/metrics) is now event-time pruned only when the statement bounds that signal's own event-time clock. The windowed columns are captured at macro expansion, where each column is unambiguous, threaded through the panel plan, and carried to bindSnapshot via a separate context value (WithWindowColumns) so Window stays a comparable struct and allTime detection is unchanged. When no windowed column resolves to a signal's clock -- bare clock match, or a qualified reference to the signal's own relation -- that signal binds every captured file instead of dropping rows; alias qualifiers that cannot be confidently resolved stay unbounded, correct if slower. Metric-name pruning now applies only when the metrics signal is genuinely window-bounded. Non-SQL-panel reads set no windowed columns and keep their default clock-based pruning, so the common dashboard panels (spans on start_time, logs on time, metrics on time, rollups on bucket) prune exactly as before. Closes #478
vishr
enabled auto-merge
November 15, 2026 15:57
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 15, 2026
github-merge-queue
Bot
removed this pull request from the merge queue due to failed status checks
Nov 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug (#478)
SQL panels file-prune every telemetry relation in a statement to the panel's event-time window, using each signal's own event-time footer bounds — regardless of which column the statement actually windows on. A statement that windows on a non-default column (
$__window(end_time),$__window(observed_time)), or that joins a windowed rollup to an unwindowed raw relation (spans/logs/metrics), silently dropped rows that fell outside the default prune window. This violated the read-window contract ininternal/queryrows/window.go.Root cause:
bindSnapshotselected each signal's files withoverlapping(b, signal, w), which tests the signal's clock (footer-sorted event-time) column against the window — even when the statement never bounds that column.The fix
A raw signal is event-time pruned by the panel window only when the statement actually bounds that signal's own clock column with the window. Otherwise the signal binds every captured file (the
allTimebehaviour), so no row is dropped.The windowed columns are captured at macro expansion (
expandMacros), where each$__window(col)argument is unambiguous and already validated by the macro regex, and threaded to the engine via a dedicated context value (WithWindowColumns, mirroring the existingWithInventoryWindow). The engine prunes signalSonly when a windowed column equalsS.Clock()(bare) or namesS's own relation (S.<clock>); an alias qualifier it cannot resolve stays unbounded (binds all files — correct, if slower).Because the columns ride a separate context key rather than a new
Windowfield,Windowstays a comparable struct and every== allTime/!= allTimesite is unchanged. When no windowed columns are present (all non-SQL-panel internal readers), every signal keeps its existing clock-based pruning, so there is no behaviour change off the SQL-panel path. The metric-name prune now keys off the per-signal selected window, so it applies only when the metrics signal is genuinely window-bounded.Tests
TestSQLPanelBindsAllFilesWhenWindowColumnIsNotTheFooterClock— reproduces the row loss: a span whosestart_timeis before the window but whoseend_timeis inside it is returned when the statement windows onend_time(failed before the fix:count=1 want 2).TestSQLPanelPrunesFilesWhenWindowColumnIsTheFooterClock— proves the common case (bare$__window(start_time)on spans) still prunes to only the overlapping batch file, so there is no perf regression.TestExpandMacrosextended to assert the returned windowed columns.gofmt -l internal/empty,just vetclean,internal/engineandinternal/querypackages green, behavioral test-name check passes.Known residual (follow-up, not a regression)
When one statement references the same signal both windowed and unwindowed, file selection is still per-signal (one pinned snapshot relation per signal), so the unwindowed reference shares the windowed selection. This case was equally pruned before this change; fixing it needs per-reference relations and is out of scope here.
Closes #478