Skip to content

feat: Add support for dashboard filters on Raw SQL Charts#1924

Open
pulpdrew wants to merge 4 commits intomainfrom
drew/raw-sql-filters
Open

feat: Add support for dashboard filters on Raw SQL Charts#1924
pulpdrew wants to merge 4 commits intomainfrom
drew/raw-sql-filters

Conversation

@pulpdrew
Copy link
Contributor

@pulpdrew pulpdrew commented Mar 16, 2026

Summary

This PR updates Raw SQL charts with support for dashboard filters, using the $__filters macro.

Lucene global filters require a Source to be included in the ChartConfig, for schema introspection and the implicitColumnExpression value. To support Lucene filters, this PR also updates the RawSqlChartConfig type to include optional source, implicitColumnExpression, and from properties. Only source is saved in the database. The external API has been updated to accept the source field for raw SQL charts as well.

Dashboard import/export has also been updated to support source mapping for raw sql charts with sources.

Screenshots or video

Both the global filter and the drop-down filters are applied:

Screenshot 2026-03-17 at 10 57 36 AM

To render Lucene conditions, we require Source information (the from and implicitColumnExpression fields). When a source is not set, filters are therefore not applied:

Screenshot 2026-03-17 at 10 54 41 AM

Similarly, if the $__filters macro is not used, then the filters are not applied

Screenshot 2026-03-17 at 10 56 33 AM

Import:

Screenshot 2026-03-17 at 3 35 16 PM

How to test locally or on Vercel

This can be tested in the preview environment.

  1. Create a saved dashboard and add some filters.
  2. Create a raw sql tile, with or without the $__filters macro
  3. Try selecting filters, deselecting filters, and applying global SQL and Lucene filters
  4. Inspect the generated queries in the console.

References

  • Linear Issue: Closes HDX-3694
  • Related PRs:

@changeset-bot
Copy link

changeset-bot bot commented Mar 16, 2026

🦋 Changeset detected

Latest commit: 4a1b464

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
@hyperdx/common-utils Patch
@hyperdx/app Patch
@hyperdx/api Patch
@hyperdx/otel-collector Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Mar 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
hyperdx-oss Ready Ready Preview, Comment Mar 17, 2026 7:47pm

Request Review

@pulpdrew pulpdrew changed the title Drew/raw sql filters feat: Add support for dashboard filters on Raw SQL Charts Mar 16, 2026
@pulpdrew pulpdrew force-pushed the drew/raw-sql-filters branch from 8d251e1 to c5e5745 Compare March 16, 2026 18:47
@github-actions
Copy link
Contributor

github-actions bot commented Mar 16, 2026

E2E Test Results

All tests passed • 91 passed • 3 skipped • 976s

Status Count
✅ Passed 91
❌ Failed 0
⚠️ Flaky 2
⏭️ Skipped 3

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew pulpdrew force-pushed the drew/raw-sql-filters branch from 6589971 to 8d74a01 Compare March 17, 2026 17:35
@pulpdrew pulpdrew marked this pull request as ready for review March 17, 2026 18:49
@github-actions
Copy link
Contributor

github-actions bot commented Mar 17, 2026

PR Review

  • ⚠️ doFiltersExist excludes sql_ast filter typerenderFiltersToSql silently drops ALL filters (including sql_ast) when source or from is missing, but the warning check only triggers for lucene/sql types. If a user has only dropdown (sql_ast) filters set with no source or no $__filters macro, filters are silently ignored with no user-facing warning. Fix: add filter.type === 'sql_ast' to the doFiltersExist check.

  • ⚠️ sql_ast filters dropped even though they don't need source/from → The early return in renderFiltersToSql (if (!chartConfig.source || !chartConfig.from) return undefined) drops sql_ast filters too, even though sql_ast rendering has no dependency on source or from. Either: (a) handle sql_ast before the early return so they're always applied when $__filters is present, or (b) ensure the warning always fires for this case (see above).

  • ℹ️ Dual-failure message priority → When both isMissingSourceForFiltering AND isMissingFiltersMacro are true, only the "missing macro" message is shown. User fixes the macro, then hits a second error about missing source. Consider a combined message or prioritizing the source warning.

✅ Validation logic (getSourceConnectionMismatches), multi-tenancy scoping, Zod schema extensions, and test coverage all look solid.

@pulpdrew pulpdrew requested review from a team and removed request for a team March 17, 2026 19:58
@pulpdrew pulpdrew requested a review from karl-power March 17, 2026 19:58
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.

1 participant