Skip to content

Commit cdc29d5

Browse files
authored
fix: Fix query error on ClickHouse Query latency chart (#1978)
## Summary This PR fixes the heatmap Query Latency chart on the ClickHouse page, by casting the value expression to Float64 so that it matches the type of other `greatest()` args. ### Screenshots or video Before <img width="2301" height="341" alt="Screenshot 2026-03-24 at 10 29 44 AM" src="https://github.com/user-attachments/assets/4c3c2562-e2c8-4bc8-8739-adb7768d7cf6" /> <img width="1945" height="304" alt="Screenshot 2026-03-24 at 10 29 35 AM" src="https://github.com/user-attachments/assets/5d8d3dd0-bf56-4af8-bfe9-7672723c255b" /> After <img width="2290" height="367" alt="Screenshot 2026-03-24 at 10 33 29 AM" src="https://github.com/user-attachments/assets/af034dbd-d983-416b-9b47-927db818bd02" /> <img width="2296" height="299" alt="Screenshot 2026-03-24 at 10 33 38 AM" src="https://github.com/user-attachments/assets/e5910d8d-e799-444d-b38d-8fa574beae87" /> ### How to test locally or on Vercel This can be validated in the preview environment ### References - Linear Issue: Closes HDX-3794 - Related PRs:
1 parent 4575526 commit cdc29d5

File tree

4 files changed

+73
-2
lines changed

4 files changed

+73
-2
lines changed

.changeset/few-ravens-teach.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@hyperdx/app": patch
3+
---
4+
5+
fix: Fix query error on ClickHouse Query latency chart

packages/app/src/components/DBHeatmapChart.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,11 +454,11 @@ function HeatmapContainer({
454454
// For linear scale: bucket by raw value (original behavior)
455455
const bucketExprAgg =
456456
scaleType === 'log'
457-
? `widthBucket(log(greatest(value_calc, ${effectiveMin})), log(${effectiveMin}), log(${max}), ${nBuckets})`
457+
? `widthBucket(log(greatest(toFloat64(value_calc), ${effectiveMin})), log(${effectiveMin}), log(${max}), ${nBuckets})`
458458
: `widthBucket(value_calc, ${effectiveMin}, ${max}, ${nBuckets})`;
459459
const bucketExprDirect =
460460
scaleType === 'log'
461-
? `widthBucket(log(greatest(${valueExpression}, ${effectiveMin})), log(${effectiveMin}), log(${max}), ${nBuckets})`
461+
? `widthBucket(log(greatest(toFloat64(${valueExpression}), ${effectiveMin})), log(${effectiveMin}), log(${max}), ${nBuckets})`
462462
: `widthBucket(${valueExpression}, ${effectiveMin}, ${max}, ${nBuckets})`;
463463

464464
const bucketConfig: BuilderChartConfigWithDateRange = isAggregateExpression
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { ClickHouseDashboardPage } from '../page-objects/ClickHouseDashboardPage';
2+
import { expect, test } from '../utils/base-test';
3+
4+
test.describe('ClickHouse Dashboard', { tag: ['@full-stack'] }, () => {
5+
let clickhousePage: ClickHouseDashboardPage;
6+
7+
test.beforeEach(async ({ page }) => {
8+
clickhousePage = new ClickHouseDashboardPage(page);
9+
});
10+
11+
test('should load heatmap chart without error', async () => {
12+
await clickhousePage.goto();
13+
await clickhousePage.waitForPageLoad();
14+
15+
// Select the local connection
16+
await clickhousePage.selectConnection('local');
17+
18+
// Assert the heatmap rendered without error
19+
await expect(await clickhousePage.queryLatencyChart).toBeVisible();
20+
});
21+
});
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* ClickHouseDashboardPage - Page object for the /clickhouse dashboard page
3+
* Encapsulates interactions with the ClickHouse system dashboard
4+
*/
5+
import { Locator, Page } from '@playwright/test';
6+
7+
export class ClickHouseDashboardPage {
8+
readonly page: Page;
9+
private readonly _pageContainer: Locator;
10+
private readonly _queryLatencyChart: Locator;
11+
private readonly _connectionSelect: Locator;
12+
13+
constructor(page: Page) {
14+
this.page = page;
15+
this._pageContainer = page.getByTestId('clickhouse-dashboard-page');
16+
// Scope heatmap locators to the chart container with the "Query Latency" title
17+
this._queryLatencyChart = this._pageContainer
18+
.locator('div')
19+
.filter({ hasText: 'Query Latency' })
20+
.first();
21+
this._connectionSelect = page.getByPlaceholder('Connection');
22+
}
23+
24+
async goto() {
25+
await this.page.goto('/clickhouse');
26+
}
27+
28+
async selectConnection(connectionName: string) {
29+
await this._connectionSelect.click();
30+
const option = this.page.getByRole('option', { name: connectionName });
31+
await option.click();
32+
}
33+
34+
async waitForPageLoad() {
35+
await this._pageContainer.waitFor({ state: 'visible' });
36+
}
37+
38+
get container(): Locator {
39+
return this._pageContainer;
40+
}
41+
42+
get queryLatencyChart(): Locator {
43+
return this._queryLatencyChart.locator('.uplot');
44+
}
45+
}

0 commit comments

Comments
 (0)