|
49 | 49 | UnparsedMetricInput, |
50 | 50 | UnparsedMetricInputMeasure, |
51 | 51 | UnparsedMetricTypeParams, |
| 52 | + UnparsedMetricV2, |
52 | 53 | UnparsedNonAdditiveDimension, |
53 | 54 | UnparsedQueryParams, |
54 | 55 | UnparsedSavedQuery, |
|
72 | 73 |
|
73 | 74 |
|
74 | 75 | def parse_where_filter( |
75 | | - where: Optional[Union[List[str], str]] |
| 76 | + where: Optional[Union[List[str], str]], |
76 | 77 | ) -> Optional[WhereFilterIntersection]: |
77 | 78 | if where is None: |
78 | 79 | return None |
@@ -470,12 +471,20 @@ def _generate_metric_config( |
470 | 471 |
|
471 | 472 | def parse(self) -> None: |
472 | 473 | for data in self.get_key_dicts(): |
473 | | - try: |
474 | | - UnparsedMetric.validate(data) |
475 | | - unparsed = UnparsedMetric.from_dict(data) |
476 | | - |
477 | | - except (ValidationError, JSONValidationError) as exc: |
478 | | - raise YamlParseDictError(self.yaml.path, self.key, data, exc) |
| 474 | + # The main differentiator of old-style yaml and new-style is "type_params", |
| 475 | + # so if that is missing, we'll assume you're using the newer yaml. |
| 476 | + if "type_params" in data: |
| 477 | + try: |
| 478 | + UnparsedMetric.validate(data) |
| 479 | + unparsed = UnparsedMetric.from_dict(data) |
| 480 | + except (ValidationError, JSONValidationError) as exc: |
| 481 | + raise YamlParseDictError(self.yaml.path, self.key, data, exc) |
| 482 | + else: |
| 483 | + try: |
| 484 | + UnparsedMetricV2.validate(data) |
| 485 | + unparsed = UnparsedMetricV2.from_dict(data) |
| 486 | + except (ValidationError, JSONValidationError) as exc: |
| 487 | + raise YamlParseDictError(self.yaml.path, self.key, data, exc) |
479 | 488 | self.parse_metric(unparsed) |
480 | 489 |
|
481 | 490 |
|
|
0 commit comments