Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: Improve Date Range and Granularity handling for Materialized Views #1533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
pulpdrew wants to merge 3 commits into main
base: main
Choose a base branch
Loading
from drew/mv-granularity-fix-rebased

Conversation

@pulpdrew
Copy link
Contributor

@pulpdrew pulpdrew commented Dec 29, 2025
edited
Loading

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 will likely be removed in a followup PR.

Demo

Show Complete Intervals Option
Screen.Recording.2025年12月29日.at.3.20.59.PM.mov

Copy link

changeset-bot bot commented Dec 29, 2025
edited
Loading

🦋 Changeset detected

Latest commit: 251f167

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

Copy link

vercel bot commented Dec 29, 2025
edited
Loading

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 Dec 29, 2025 8:47pm

@pulpdrew pulpdrew changed the title (削除) Drew/mv granularity fix rebased (削除ここまで) (追記) feat: Improve Date Range and Granularity handling for Materialized Views (追記ここまで) Dec 29, 2025
Copy link

claude bot commented Dec 29, 2025
edited
Loading

Code Review

No critical issues found.

The PR makes solid improvements to materialized view query alignment and date range handling. The implementation is well-tested with comprehensive test coverage for edge cases.

Minor observations:

  • Good: New test coverage for granularity validation (packages/common-utils/src/clickhouse/tests/materializedViews.test.ts:630-718)
  • Good: Date range alignment is opt-in via alignDateRangeToGranularity flag with sensible defaults
  • Good: Live mode correctly disables alignment to avoid stale cache (DBSearchPage.tsx:1360)
  • Good: End-exclusive date ranges prevent double-counting at MV boundaries (materializedViews.ts:325)

Optional improvements (non-blocking):

  • Consider documenting the alignDateRangeToGranularity flag behavior in code comments for future maintainers
  • The previousPeriodOffsetSeconds calculation could be extracted to a shared utility (currently duplicated in multiple places)

Recommendation: ✅ Approve and merge

Copy link
Contributor

github-actions bot commented Dec 29, 2025
edited
Loading

E2E Test Results

All tests passed • 51 passed • 4 skipped • 695s

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

Tests ran across 4 shards in parallel.

View full report →

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

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

2 participants

AltStyle によって変換されたページ (->オリジナル) /