Skip to content

Conversation

@pulpdrew
Copy link
Contributor

@pulpdrew pulpdrew commented Dec 29, 2025

Closes HDX-3067
Closes #1331
Closes #1212
Closes #1468

Summary

This PR makes a number of improvements around the way we handle date ranges and granularities, in an effort to minimize discrepancies between aggregate values queried from original data and aggregate values queried from materialized views.

  1. Date ranges for Line and Bar chart queries are now (by default) auto-aligned to the chart's granularity. This is not limited to materialized view queries. Since the chart granularity is a multiple of the MV granularity, this ensures that the date range is aligned to the MV granularity as well. This also address a number of related issues that point out 0-values or low-values in the first or last data points. This PR also includes an option to disable this behavior for charts in Chart Explorer or Dashboard Tiles.
  2. All materialized view queries and all time chart queries are now end-exclusive, to avoid selecting the entirety of the next "time bucket" from the materialized view when the date range is aligned with the materialized view granularity
  3. Materialized views are only used for a query with a granularity if the chart query granularity is a multiple of the MV granularity. Previously, we'd use the MV as long as the chart query granularity was at least as large as the MV granularity, but this could cause unequal distributions of data across time buckets. Nearly all available granularities are multiples of all smaller available granularities - so this should only impact queries with granularity 15 minutes with MVs with granularity 10 minutes. 10m granularity support is being removed in chore: Standardize granularities #1551

Demo

Show Complete Intervals Option
Screen.Recording.2025-12-29.at.3.20.59.PM.mov

@changeset-bot
Copy link

changeset-bot bot commented Dec 29, 2025

🦋 Changeset detected

Latest commit: 4fd206b

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

This PR includes changesets to release 3 packages
Name Type
@hyperdx/common-utils Patch
@hyperdx/api Patch
@hyperdx/app 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 Dec 29, 2025

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

Project Deployment Review Updated (UTC)
hyperdx-v2-oss-app Ready Ready Preview, Comment Jan 7, 2026 6:42pm

@pulpdrew pulpdrew changed the title Drew/mv granularity fix rebased feat: Improve Date Range and Granularity handling for Materialized Views Dec 29, 2025
@claude
Copy link

claude bot commented Dec 29, 2025

Code Review

Critical Issues

  • Previous period offset calculation bug at DBTimeChart.tsx:287-290 uses aligned date ranges instead of original ranges, causing incorrect offsets when alignment changes boundaries. Fix: use differenceInSeconds(originalDateRange[1], originalDateRange[0])

Important Issues

  • Missing null safety at ChartUtils.tsx:169-171 where getAlignedDateRange receives granularity that could still be 'auto' from line 163-166. Add type guard.

Quality Issues

  • getAlignedDateRange tests miss edge cases: DST transitions, leap seconds, year boundaries
  • DBSearchPage.tsx:1370 alignment logic using !isLive is correct but unintuitive - add comment explaining cache behavior

Non-Blocking

  • materializedViews.ts:158 modulo check is good but lacks comment on why 15min/10min fails

Recommendation: Fix offset calculation bug before merge

@github-actions
Copy link
Contributor

github-actions bot commented Dec 29, 2025

E2E Test Results

All tests passed • 56 passed • 4 skipped • 710s

Status Count
✅ Passed 56
❌ Failed 0
⚠️ Flaky 0
⏭️ Skipped 4

Tests ran across 4 shards in parallel.

View full report →

@pulpdrew pulpdrew force-pushed the drew/mv-granularity-fix-rebased branch from 251f167 to 986d465 Compare January 6, 2026 19:08
@pulpdrew pulpdrew marked this pull request as ready for review January 6, 2026 19:11
@pulpdrew pulpdrew changed the title feat: Improve Date Range and Granularity handling for Materialized Views feat: Align date ranges to chart and MV granularity (Line/Bar charts) Jan 6, 2026
@pulpdrew pulpdrew requested review from a team and knudtty and removed request for a team January 6, 2026 19:21
Copy link
Contributor

@knudtty knudtty left a comment

Choose a reason for hiding this comment

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

Long awaited! Great fix

@kodiakhq kodiakhq bot merged commit 725dbc2 into main Jan 7, 2026
21 of 22 checks passed
@kodiakhq kodiakhq bot deleted the drew/mv-granularity-fix-rebased branch January 7, 2026 19:02
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.

First Bucket in Histograms is Always 0 in 2.9.0 Hide Incomplete Time Ranges in Charts Charts starts with zero

3 participants