Skip to content

feat(querier): support dynamic variable ALL for ClickHouse queries#9892

Closed
ixchio wants to merge 4 commits intoSigNoz:mainfrom
ixchio:fix/dynamic-variable-all-clickhouse
Closed

feat(querier): support dynamic variable ALL for ClickHouse queries#9892
ixchio wants to merge 4 commits intoSigNoz:mainfrom
ixchio:fix/dynamic-variable-all-clickhouse

Conversation

@ixchio
Copy link
Copy Markdown

@ixchio ixchio commented Dec 28, 2025

What

This integrates the existing QueryTransformer with renderVars() to properly handle the __all__ case for dynamic variables in ClickHouse queries.

Why

When users select "ALL" for a dashboard variable, the filter should be removed entirely - not substituted with the literal __all__ string (which matches nothing).

Before: WHERE service_name = '__all__' → returns nothing
After: WHERE clause for that variable is removed → returns all

How

  1. Check if any dynamic variable has __all__ value
  2. Run QueryTransformer to parse SQL and remove those filter conditions
  3. Log when transformation changes the query (for observability)
  4. Fall back to original if parsing fails (safe rollout)

Testing

  • Added unit tests for helper functions
  • Added integration test for the full renderVars flow with __all__
  • All existing tests pass

Fixes #9889


Note

Implements proper handling of dashboard variables set to __all__ in ClickHouse queries.

  • Integrates QueryTransformer into renderVars() to detect __all__ dynamic variables and remove their filter clauses; logs transform results and falls back to original query on errors
  • Adds helpers convertToVariableValues and hasAllVars, plus unit and integration tests in clickhouse_query_test.go
  • Minor deploy/install.sh tweaks: more robust Docker start flow on macOS and small messaging/comment cleanups

Written by Cursor Bugbot for commit 32aabb0. This will update automatically on new commits. Configure here.

This change integrates the existing QueryTransformer with the
renderVars function to handle the __all__ case for dynamic variables.

When a user selects 'ALL' for a dashboard variable, instead of
substituting the literal __all__ value (which would match nothing),
we now parse the SQL and remove that filter condition entirely.

Changes:
- Added convertToVariableValues() to bridge API types to transformer
- Added hasAllVars() for quick detection of __all__ variables
- Integrated transform step in renderVars() before substitution
- Logs transformation diffs for observability in production
- Falls back to original query if parsing fails (safe rollout)

Tests added for all new functionality.

Fixes SigNoz#9889
@ixchio ixchio requested review from a team and srikanthccv as code owners December 28, 2025 20:50
@welcome
Copy link
Copy Markdown

welcome Bot commented Dec 28, 2025

Welcome to the SigNoz community! Thank you for your first pull request and making this project better. 🤗

@srikanthccv
Copy link
Copy Markdown
Member

See #9889 (comment)

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.

Dynamic variable ALL doesn't work with ClickHouse queries

2 participants