@@ -14,12 +14,10 @@ use crate::schemas::{
14
14
} ,
15
15
dbt_column:: DbtColumnRef ,
16
16
manifest:: {
17
- DbtOperation , DbtSavedQuery , DbtSemanticModel ,
17
+ DbtMetric , DbtOperation , DbtSavedQuery , DbtSemanticModel ,
18
18
common:: { DbtOwner , SourceFileMetadata , WhereFilterIntersection } ,
19
- semantic_model:: {
20
- MeasureAggregationParameters , NodeRelation , SemanticEntity , SemanticMeasure ,
21
- SemanticModelDefaults ,
22
- } ,
19
+ metric:: { MeasureAggregationParameters , MetricTypeParams , NonAdditiveDimension } ,
20
+ semantic_model:: { NodeRelation , SemanticEntity , SemanticMeasure , SemanticModelDefaults } ,
23
21
} ,
24
22
nodes:: TestMetadata ,
25
23
project:: {
@@ -28,7 +26,7 @@ use crate::schemas::{
28
26
} ,
29
27
properties:: {
30
28
ModelConstraint , UnitTestOverrides ,
31
- metrics_properties:: { AggregationType , NonAdditiveDimension , WindowChoice } ,
29
+ metrics_properties:: { AggregationType , MetricType } ,
32
30
} ,
33
31
ref_and_source:: { DbtRef , DbtSourceWrapper } ,
34
32
semantic_layer:: semantic_manifest:: SemanticLayerElementConfig ,
@@ -637,8 +635,8 @@ pub struct ManifestMetric {
637
635
// Metric Specific Attributes
638
636
pub label : String ,
639
637
#[ serde( rename = "type" ) ]
640
- pub metric_type : crate :: schemas :: manifest :: metric :: MetricType ,
641
- pub type_params : crate :: schemas :: manifest :: metric :: MetricTypeParams ,
638
+ pub metric_type : MetricType ,
639
+ pub type_params : MetricTypeParams ,
642
640
pub filter : Option < WhereFilterIntersection > ,
643
641
pub metadata : Option < SourceFileMetadata > ,
644
642
pub time_granularity : Option < String > ,
@@ -652,6 +650,41 @@ pub struct ManifestMetric {
652
650
pub __other__ : BTreeMap < String , YmlValue > ,
653
651
}
654
652
653
+ impl From < DbtMetric > for ManifestMetric {
654
+ fn from ( metric : DbtMetric ) -> Self {
655
+ Self {
656
+ __common_attr__ : ManifestCommonAttributes {
657
+ unique_id : metric. __common_attr__ . unique_id ,
658
+ name : metric. __common_attr__ . name ,
659
+ package_name : metric. __common_attr__ . package_name ,
660
+ fqn : metric. __common_attr__ . fqn ,
661
+ path : metric. __common_attr__ . path ,
662
+ original_file_path : metric. __common_attr__ . original_file_path ,
663
+ description : metric. __common_attr__ . description ,
664
+ tags : metric. __common_attr__ . tags ,
665
+ meta : metric. __common_attr__ . meta ,
666
+ } ,
667
+ __base_attr__ : ManifestMetricNodeBaseAttributes {
668
+ depends_on : metric. __metric_attr__ . depends_on ,
669
+ refs : metric. __metric_attr__ . refs ,
670
+ sources : metric. __metric_attr__ . sources ,
671
+ unrendered_config : metric. __metric_attr__ . unrendered_config ,
672
+ created_at : metric. __metric_attr__ . created_at ,
673
+ } ,
674
+ label : metric. __metric_attr__ . label . unwrap_or_default ( ) ,
675
+ metric_type : metric. __metric_attr__ . metric_type ,
676
+ type_params : metric. __metric_attr__ . type_params ,
677
+ filter : metric. __metric_attr__ . filter ,
678
+ metadata : metric. __metric_attr__ . metadata ,
679
+ time_granularity : metric. __metric_attr__ . time_granularity . clone ( ) ,
680
+ group : metric. __metric_attr__ . group . clone ( ) ,
681
+ config : metric. deprecated_config . into ( ) ,
682
+ __other__ : metric. __other__ ,
683
+ metrics : vec ! [ ] , // TODO: metric.__metric_attr__.metrics.clone(),
684
+ }
685
+ }
686
+ }
687
+
655
688
#[ derive( Deserialize , Serialize , Debug , Clone , PartialEq ) ]
656
689
pub struct ManifestMetricConfig {
657
690
pub enabled : bool ,
@@ -779,23 +812,6 @@ impl From<DbtSemanticModel> for ManifestSemanticModel {
779
812
}
780
813
}
781
814
782
- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
783
- pub struct ManifestNonAdditiveDimension {
784
- pub name : String ,
785
- pub window_choice : WindowChoice ,
786
- pub window_groupings : Option < Vec < String > > ,
787
- }
788
-
789
- impl From < NonAdditiveDimension > for ManifestNonAdditiveDimension {
790
- fn from ( dim : NonAdditiveDimension ) -> Self {
791
- Self {
792
- name : dim. name ,
793
- window_choice : dim. window_agg ,
794
- window_groupings : dim. group_by ,
795
- }
796
- }
797
- }
798
-
799
815
#[ derive( Debug , Clone , Serialize , Deserialize ) ]
800
816
pub struct ManifestSemanticModelMeasure {
801
817
pub name : String ,
@@ -805,7 +821,7 @@ pub struct ManifestSemanticModelMeasure {
805
821
pub create_metric : Option < bool > ,
806
822
pub expr : Option < String > ,
807
823
pub agg_params : Option < MeasureAggregationParameters > ,
808
- pub non_additive_dimension : Option < ManifestNonAdditiveDimension > ,
824
+ pub non_additive_dimension : Option < NonAdditiveDimension > ,
809
825
pub agg_time_dimension : Option < String > ,
810
826
pub config : Option < SemanticLayerElementConfig > ,
811
827
}
@@ -820,9 +836,7 @@ impl From<SemanticMeasure> for ManifestSemanticModelMeasure {
820
836
create_metric : measure. create_metric ,
821
837
expr : measure. expr ,
822
838
agg_params : measure. agg_params ,
823
- non_additive_dimension : measure
824
- . non_additive_dimension
825
- . map ( ManifestNonAdditiveDimension :: from) ,
839
+ non_additive_dimension : measure. non_additive_dimension ,
826
840
agg_time_dimension : measure. agg_time_dimension ,
827
841
config : measure. config ,
828
842
}
0 commit comments