Skip to content

SQR: Fix datasource-template runtime routing for multi-select fan-out#1416

Merged
harisrozajac merged 6 commits intomainfrom
haris/mixed-ds-bug
Apr 2, 2026
Merged

SQR: Fix datasource-template runtime routing for multi-select fan-out#1416
harisrozajac merged 6 commits intomainfrom
haris/mixed-ds-bug

Conversation

@harisrozajac
Copy link
Copy Markdown
Contributor

@harisrozajac harisrozajac commented Apr 2, 2026

This PR fixes runtime execution for panels using a datasource variable with multiple selected values.

Previously, when a datasource variable (for example ${ds}) had multiple selected values, runtime could execute only one datasource query path (effectively the first), instead of running across all selected datasources.

This change ensures runtime routes templated datasource execution through the Mixed datasource path so all selected datasource values are executed.

The demo below shows v1 dashboards, but i've verified that this also fixes it for v2 dashboards.

Current behavior:

Screen.Recording.2026-04-02.at.9.30.06.AM.mov

With the fix:

Screen.Recording.2026-04-02.at.9.23.41.AM.mov

Fixes: grafana/grafana#121324

📦 Published PR as canary version: 7.3.8--canary.1416.23913328165.0

✨ Test out this PR locally via:

npm install @grafana/scenes@7.3.8--canary.1416.23913328165.0
npm install @grafana/scenes-react@7.3.8--canary.1416.23913328165.0
# or 
yarn add @grafana/scenes@7.3.8--canary.1416.23913328165.0
yarn add @grafana/scenes-react@7.3.8--canary.1416.23913328165.0

@harisrozajac harisrozajac self-assigned this Apr 2, 2026
@harisrozajac harisrozajac added patch Increment the patch version when merged release Create a release when this pr is merged labels Apr 2, 2026
@harisrozajac harisrozajac requested a review from bfmatei April 2, 2026 15:31
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates SceneQueryRunner runtime datasource resolution so panels using a templated datasource variable (e.g. ${ds}) can correctly fan out execution when the variable has multiple selected values, by routing execution through the Mixed datasource path.

Changes:

  • Add runtime detection logic to decide when to use the Mixed datasource for query execution based on datasource templating and variable selection count.
  • Preserve the original templated datasource ref on request targets when executing via Mixed, so Mixed can perform the fan-out.
  • Extend unit tests to cover single-selection, multi-selection, and “ambiguous” templated datasource UID cases; update snapshot accordingly.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/scenes/src/querying/SceneQueryRunner.ts Adds Mixed-runtime routing decision logic and adjusts request target datasource assignment to preserve templated refs when running via Mixed.
packages/scenes/src/querying/SceneQueryRunner.test.ts Adds unit tests verifying Mixed vs non-Mixed runtime datasource selection behavior for templated datasource variables.
packages/scenes/src/querying/__snapshots__/SceneQueryRunner.test.ts.snap Updates snapshot output due to additional tests affecting requestId counter progression.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

@kristinademeshchik kristinademeshchik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this on different combinations v1/v2 with/without panel level ds works well!

@harisrozajac harisrozajac merged commit 72ea5d3 into main Apr 2, 2026
14 checks passed
@harisrozajac harisrozajac deleted the haris/mixed-ds-bug branch April 2, 2026 17:54
@scenes-repo-bot-access-token
Copy link
Copy Markdown

🚀 PR was released in v7.3.8 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch Increment the patch version when merged release Create a release when this pr is merged released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dashboards: Running queries with data source variable and multiple values doesn't fan out

3 participants