Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Shared Dimensions for Derived Metrics
When querying derived metrics, the system needed to correctly compute which dimensions are available. A derived metric that references multiple base metrics should be able to use dimensions from any of its base metrics (union), while multiple metrics queried together should only expose shared dimensions (intersection).
The changes modified
get_shared_dimensions()to compute per-metric dimension unions first, then intersect across metrics. We also addget_metric_parents_map()to batch-fetch parent mappings while maintaining metric-to-parent relationships. This enables dimension determination for derived metrics to work correctly.AST Column Compilation for Derived Metrics
Derived metric queries have no
FROMclause - they reference base metrics directly as columns (e.g., SELECT default.revenue / default.orders). The AST compiler couldn't resolve these references with the right types.The changes here extended
Column.compile()to resolve metric references by looking up the metric node and getting its output type, and added support for dimension attribute references for ordering/filtering.Pre-expanded Template Handling
Metric decomposition could produce pre-expanded aggregation templates like
SUM(POWER(match_score, 2))instead of the unexpandedSUM(POWER({}, 2)). The build_component_expression() function didn't handle these. This change adds detection for pre-expanded templates, which are parsed directly as complete SQL expressions.Test Plan
make checkpassesmake testshows 100% unit test coverageDeployment Plan