Skip to content

Conversation

@pulpdrew
Copy link
Contributor

@pulpdrew pulpdrew commented Jan 5, 2026

Closes HDX-3064

Summary

This PR makes two improvements to MV configuration

  1. Additional granularities are now available
  2. Configuration can now be inferred from SummingMergeTree MVs (in addition to AggregatingMergeTree, which were already supported)
  3. Source column inference has been improved to support cases where the target table column name does not follow the aggFn__sourceColumn convention.

Also, tests have been updated and additional tests have been backported from the EE repo.

Demo

Screen.Recording.2026-01-05.at.10.22.42.AM.mov

Testing

To test the Summing Merge Tree inference, create a materialized view like so:

CREATE TABLE default.traces_summed_2              
(                                                
   `Timestamp` DateTime,                        
   `ServiceName` LowCardinality(String),        
   `StatusCode` LowCardinality(String),         
   `count` UInt64,                              
   `sumDuration` UInt64,
   `quantileDuration` AggregateFunction(quantile(0.5), UInt64)                       
)                                                
ENGINE = SummingMergeTree((count, sumDuration))
ORDER BY (ServiceName, StatusCode, Timestamp)    
SETTINGS index_granularity = 8192;

CREATE MATERIALIZED VIEW default.traces_summed_mv_2 TO default.traces_summed_2
(
      `Timestamp` DateTime,
      `ServiceName` LowCardinality(String),
      `StatusCode` LowCardinality(String),
      `count` UInt64,
      `sumDuration` UInt64,
      `quantileDuration` AggregateFunction(quantile(0.5), UInt64)
)
AS SELECT
      toStartOfInterval(Timestamp, toIntervalMinute(30)) AS Timestamp,
      ServiceName,
      StatusCode,
      count() AS count,
      sum(Duration) AS sumDuration,
      quantileState(0.5)(Duration) AS quantileDuration
FROM default.otel_traces
GROUP BY
      Timestamp,
      ServiceName,
      StatusCode;

@vercel
Copy link

vercel bot commented Jan 5, 2026

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 6, 2026 7:45pm

@changeset-bot
Copy link

changeset-bot bot commented Jan 5, 2026

🦋 Changeset detected

Latest commit: 60dff26

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

This PR includes changesets to release 2 packages
Name Type
@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

@pulpdrew pulpdrew changed the title Drew/infer mv summing merge tree feat: Add MV granularities and infer config from SummingMergeTree Jan 5, 2026
@claude
Copy link

claude bot commented Jan 5, 2026

Code Review

No critical issues found.

The PR successfully adds MV granularities and SummingMergeTree support with comprehensive test coverage. The implementation follows HyperDX patterns correctly.

Minor observations:

  • ✓ Type safety maintained throughout with proper type guards
  • ✓ 698 lines of tests added with good edge case coverage
  • ✓ Graceful fallbacks when inference fails
  • ✓ Notification IDs added (good UX improvement)
  • ✓ Exported constants follow existing patterns

Recommendation: Approve and merge

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

E2E Test Results

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

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/infer-mv-summing-merge-tree branch from d514c50 to 77a1aa9 Compare January 5, 2026 16:08
@pulpdrew pulpdrew requested review from a team, bot-hyperdx and teeohhem and removed request for a team and bot-hyperdx January 5, 2026 16:45
.toLowerCase()
.includes('count')
? 'count'
: 'sum';
Copy link
Member

Choose a reason for hiding this comment

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

should we check other agg functions here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For AggregatingMergeTree, we do. But for SummingMergeTree, the behavior is that the summedColumnNames (which are the arguments passed to the engine eg. SummingMergeTree([...columns])) are all summed. That's only valid for sums and counts - so we handle count as a special case and assume others are sums.

SummingMergeTree does technically support other aggregations if the Column has AggregateFunction type - in which case the .map above will cover that case. I'll update the test case to show that.

Comment on lines 265 to 275
function getSourceTableColumn(
mvColumnName: string,
aggFn: string,
sourceTableColumnNames: Set<string>,
) {
// By convention: MV Columns are named "<aggFn>__<sourceColumn>"
const nameSuffix = mvColumnName.split('__')[1];
return sourceTableColumnNames.has(nameSuffix) && aggFn !== 'count'
? nameSuffix
: '';
}
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we could use mv DDL to figure out the mapping cuz users don't need to follow these conventions to map source table columns, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can in most cases! I've updated getSourceTableColumn to extract the column definitions from the materialized view DDL and try to match up source and target column names, if the convention-based matching fails. The user always has the option to explicitly configure the source column name, in case the inference fails though (such as due to multiple MVs writing to the table, or unexpectedly complex expressions).

@pulpdrew pulpdrew force-pushed the drew/infer-mv-summing-merge-tree branch from 99b7b07 to 1c7e72e Compare January 6, 2026 15:18
Copy link
Member

@wrn14897 wrn14897 left a comment

Choose a reason for hiding this comment

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

lgtm

@kodiakhq kodiakhq bot merged commit ae12ca1 into main Jan 6, 2026
12 checks passed
@kodiakhq kodiakhq bot deleted the drew/infer-mv-summing-merge-tree branch January 6, 2026 19:45
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.

3 participants