Skip to content

feat: Support raw sql number charts and pie charts#1875

Merged
kodiakhq[bot] merged 2 commits intomainfrom
drew/raw-sql-pie-number
Mar 11, 2026
Merged

feat: Support raw sql number charts and pie charts#1875
kodiakhq[bot] merged 2 commits intomainfrom
drew/raw-sql-pie-number

Conversation

@pulpdrew
Copy link
Contributor

@pulpdrew pulpdrew commented Mar 10, 2026

Summary

This PR adds support for Raw SQL Number and Pie charts. It also introduces a shared ChartErrorState component for a few chart types.

Screenshots or video

Number and Pie Chart:
Screenshot 2026-03-10 at 10 52 53 AM
Screenshot 2026-03-10 at 10 53 27 AM

Error States
Screenshot 2026-03-10 at 10 54 29 AM
Screenshot 2026-03-10 at 10 54 25 AM
Screenshot 2026-03-10 at 10 54 17 AM

How to test locally or on Vercel

This change can be tested in the preview environment.

References

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

@changeset-bot
Copy link

changeset-bot bot commented Mar 10, 2026

🦋 Changeset detected

Latest commit: db55617

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/api Patch
@hyperdx/app 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 10, 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 11, 2026 2:22pm

Request Review

@pulpdrew pulpdrew changed the title Drew/raw sql pie number feat: Support raw sql number charts and pie charts Mar 10, 2026
@github-actions
Copy link
Contributor

PR Review: feat: Support raw sql number charts and pie charts

✅ Overall looks good — clean refactoring, good test coverage, and well-structured shared ChartErrorState component.

Minor issues:

  • ⚠️ ChartErrorState.tsx:53variant == 'collapsible' uses loose equality → change to === for consistency
  • ⚠️ rawSqlParams.ts:23getIntervalSeconds calls convertGranularityToSeconds('auto') when no dateRange is provided (passing non-SQLInterval string to a typed function, silently returns 0). The behavior is intentional and tested, but consider an explicit guard: if (!config.dateRange) return 0 before the conversion to make it explicit and type-safe.
  • ℹ️ ChartUtils.tsx:215useTimeChartSettings memo depends on the entire config object reference ([config]). If callers pass object literals, this will recalculate on every render. Not a regression (same as before), but worth noting.

No critical bugs or security issues found.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

Code Review

  • WARNING: data.meta in DBNumberChart.tsx produces [object Object],[object Object] in the error message - arrays do not serialize in template literals - change to JSON.stringify(data.meta) to match the pattern already used in ChartUtils.tsx formatResponseForPieChart

  • WARNING: responseFormatError typed as unknown in DBPieChart.tsx catch block, but passed directly to ChartErrorState which expects Error or ClickHouseQueryError - add a type guard or cast

  • Minor: variant == collapsible in ChartErrorState.tsx uses loose equality - prefer strict ===

Overall the refactor is clean - shared ChartErrorState component is a good abstraction, and the raw SQL support for number/pie charts follows the established line chart pattern correctly.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

Code Review

  • ⚠️ DBNumberChart.tsx:92: data.meta (an array) is interpolated directly in the template literal → produces [object Object] instead of useful JSON. Compare with formatResponseForPieChart which correctly uses JSON.stringify(data.meta). Fix: JSON.stringify(data.meta)

  • ⚠️ DBPieChart.tsx:158: responseFormatError from a catch block is typed as unknown but passed directly to ChartErrorState which expects Error | ClickHouseQueryError. Fix: cast or narrow the type (e.g. error instanceof Error ? error : new Error(String(error))) before passing it.

Otherwise the approach is clean — good refactor consolidating error state into a shared ChartErrorState component and correctly extending raw SQL support to number/pie chart types.

@pulpdrew pulpdrew force-pushed the drew/raw-sql-pie-number branch from 59e4033 to 4648f60 Compare March 10, 2026 18:50
@pulpdrew pulpdrew marked this pull request as ready for review March 10, 2026 18:52
@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

Code Review

No critical issues found.

A few minor observations:

  • DBNumberChart result error logic: resultError falls back to the query error when not a raw SQL config, but isError is checked first in the render, so this fallback is dead code for the non-raw-SQL path. Using null as the fallback would make intent clearer.

  • useMemo on details in ChartErrorState: Wrapping static JSX in useMemo that only depends on error adds unnecessary complexity since the memo fires on every error change anyway.

Overall the PR is clean: the shared ChartErrorState component is a good abstraction, type unions are handled correctly, and the test updates correctly reflect the behavioral change in formatResponseForPieChart (throw vs. return empty array).

@pulpdrew pulpdrew force-pushed the drew/raw-sql-pie-number branch from 4648f60 to 2d06b75 Compare March 10, 2026 19:32
@pulpdrew pulpdrew requested review from a team and knudtty and removed request for a team March 10, 2026 19:38
@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

E2E Test Results

All tests passed • 87 passed • 3 skipped • 927s

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

Tests ran across 4 shards in parallel.

View full report →

kodiakhq bot pushed a commit that referenced this pull request Mar 11, 2026
## Summary

This PR adds support for Raw SQL Charts to the external dashboards APIs.

### Screenshots or video

<img width="2294" height="1180" alt="Screenshot 2026-03-10 at 1 25 16 PM" src="https://github.com/user-attachments/assets/1f35bbe9-2558-43fa-8cc4-148af75042c5" />

### How to test locally or on Vercel

- `yarn dev` locally
- Grab your Personal API Key from Team Settings
- Make a request to the dashboard endpoints

```
curl http://localhost:8000/api/v2/dashboards -H "Authorization: Bearer <Key>"  -H "Content-Type: application/json" 
```

Schema is available at [`http://localhost:8000/api/v2/docs/#/`](http://localhost:8000/api/v2/docs/#/)

### References



- Linear Issue: HDX-3582 HDX-3585
- Related PRs: #1866, #1875
</div>
)}
{queryReady && queriedConfig != null && activeTab === 'number' && (
<div className="flex-grow-1 d-flex flex-column" style={{ height: 400 }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

If there's some pattern you see to extract this rather than wrapping every chart in this flex-grow div, go for it

@kodiakhq kodiakhq bot merged commit 1381782 into main Mar 11, 2026
13 of 14 checks passed
@kodiakhq kodiakhq bot deleted the drew/raw-sql-pie-number branch March 11, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants