Fix time_comparison metric error when base_metric is missing#9
Merged
Fix time_comparison metric error when base_metric is missing#9
Conversation
When querying a time_comparison metric that lacked a base_metric field, the error "argument of type 'NoneType' is not iterable" was raised. This was confusing as it didn't indicate the actual problem. Changes: - Add validation in _generate_with_window_functions to raise a clear ValueError when base_metric is missing - Add defensive check in final SELECT building phase - Add test for the error message
Validate type-specific required fields at Metric construction time: - time_comparison: requires base_metric - ratio: requires numerator and denominator - derived: requires sql - cumulative: requires sql - conversion: requires entity, base_event, conversion_event Also fix MetricFlow adapter to set sql for cumulative metrics from type_params.measure, and remove invalid test that mixed conversion type with ratio fields.
- Add scripts/generate_schema.py to generate schema from pydantic models - Publish schema to docs/schema.json (available at sidemantic.com/schema.json) - Add CI check to ensure schema stays in sync with models - Update getting-started docs with schema URL for YAML autocomplete
32234f0 to
4bf16fd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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
"argument of type 'NoneType' is not iterable"error when usingtime_comparisonmetrics that lack abase_metricfieldValueErrorwith the message:time_comparison metric 'metric_name' requires 'base_metric' fieldRoot cause
When a
time_comparisonmetric was defined without abase_metric:The code would fail at line 1820 with
if "." in base_ref:wherebase_refwasNone.Changes
_generate_with_window_functionsto check for requiredbase_metricfield and raise a descriptive error