@@ -14,7 +14,7 @@ use serde_json::json;
1414
1515use super :: catalog:: mock_catalog:: { self , MockCatalog } ;
1616use super :: interface:: {
17- Attr , AttrId , CatalogSource , EpochId , EpochOption , ExprId , Stat , StatId , TableId ,
17+ Attr , AttrId , CatalogSource , EpochId , EpochOption , ExprId , Stat , StatId , StatType , TableId ,
1818} ;
1919
2020impl BackendManager {
@@ -228,7 +228,7 @@ impl CostModelStorageLayer for BackendManager {
228228 stat. attr_ids . len ( ) as i32
229229 ) ,
230230 creation_time : sea_orm:: ActiveValue :: Set ( Utc :: now ( ) ) ,
231- variant_tag : sea_orm:: ActiveValue :: Set ( stat. stat_type ) ,
231+ variant_tag : sea_orm:: ActiveValue :: Set ( stat. stat_type as i32 ) ,
232232 description : sea_orm:: ActiveValue :: Set ( "" . to_string ( ) ) ,
233233 ..Default :: default ( )
234234 } ;
@@ -250,7 +250,7 @@ impl CostModelStorageLayer for BackendManager {
250250 let res = Statistic :: find ( )
251251 . filter ( statistic:: Column :: NumberOfAttributes . eq ( stat. attr_ids . len ( ) as i32 ) )
252252 . filter ( statistic:: Column :: Description . eq ( description. clone ( ) ) )
253- . filter ( statistic:: Column :: VariantTag . eq ( stat. stat_type ) )
253+ . filter ( statistic:: Column :: VariantTag . eq ( stat. stat_type as i32 ) )
254254 . inner_join ( versioned_statistic:: Entity )
255255 . select_also ( versioned_statistic:: Entity )
256256 . order_by_desc ( versioned_statistic:: Column :: EpochId )
@@ -270,7 +270,7 @@ impl CostModelStorageLayer for BackendManager {
270270 stat. attr_ids . len ( ) as i32
271271 ) ,
272272 creation_time : sea_orm:: ActiveValue :: Set ( Utc :: now ( ) ) ,
273- variant_tag : sea_orm:: ActiveValue :: Set ( stat. stat_type ) ,
273+ variant_tag : sea_orm:: ActiveValue :: Set ( stat. stat_type as i32 ) ,
274274 description : sea_orm:: ActiveValue :: Set ( description) ,
275275 ..Default :: default ( )
276276 } ;
@@ -366,24 +366,24 @@ impl CostModelStorageLayer for BackendManager {
366366 /// TODO: documentation
367367 async fn get_stats_for_table (
368368 & self ,
369- table_id : i32 ,
370- stat_type : i32 ,
369+ table_id : TableId ,
370+ stat_type : StatType ,
371371 epoch_id : Option < EpochId > ,
372372 ) -> StorageResult < Option < Json > > {
373373 match epoch_id {
374374 Some ( epoch_id) => Ok ( VersionedStatistic :: find ( )
375375 . filter ( versioned_statistic:: Column :: EpochId . eq ( epoch_id) )
376376 . inner_join ( statistic:: Entity )
377377 . filter ( statistic:: Column :: TableId . eq ( table_id) )
378- . filter ( statistic:: Column :: VariantTag . eq ( stat_type) )
378+ . filter ( statistic:: Column :: VariantTag . eq ( stat_type as i32 ) )
379379 . one ( & self . db )
380380 . await ?
381381 . map ( |stat| stat. statistic_value ) ) ,
382382
383383 None => Ok ( VersionedStatistic :: find ( )
384384 . inner_join ( statistic:: Entity )
385385 . filter ( statistic:: Column :: TableId . eq ( table_id) )
386- . filter ( statistic:: Column :: VariantTag . eq ( stat_type) )
386+ . filter ( statistic:: Column :: VariantTag . eq ( stat_type as i32 ) )
387387 . order_by_desc ( versioned_statistic:: Column :: EpochId )
388388 . one ( & self . db )
389389 . await ?
@@ -395,7 +395,7 @@ impl CostModelStorageLayer for BackendManager {
395395 async fn get_stats_for_attr (
396396 & self ,
397397 mut attr_ids : Vec < AttrId > ,
398- stat_type : i32 ,
398+ stat_type : StatType ,
399399 epoch_id : Option < EpochId > ,
400400 ) -> StorageResult < Option < Json > > {
401401 let attr_num = attr_ids. len ( ) as i32 ;
@@ -412,7 +412,7 @@ impl CostModelStorageLayer for BackendManager {
412412 . inner_join ( statistic:: Entity )
413413 . filter ( statistic:: Column :: NumberOfAttributes . eq ( attr_num) )
414414 . filter ( statistic:: Column :: Description . eq ( description) )
415- . filter ( statistic:: Column :: VariantTag . eq ( stat_type) )
415+ . filter ( statistic:: Column :: VariantTag . eq ( stat_type as i32 ) )
416416 . one ( & self . db )
417417 . await ?
418418 . map ( |stat| stat. statistic_value ) ) ,
@@ -421,7 +421,7 @@ impl CostModelStorageLayer for BackendManager {
421421 . inner_join ( statistic:: Entity )
422422 . filter ( statistic:: Column :: NumberOfAttributes . eq ( attr_num) )
423423 . filter ( statistic:: Column :: Description . eq ( description) )
424- . filter ( statistic:: Column :: VariantTag . eq ( stat_type) )
424+ . filter ( statistic:: Column :: VariantTag . eq ( stat_type as i32 ) )
425425 . order_by_desc ( versioned_statistic:: Column :: EpochId )
426426 . one ( & self . db )
427427 . await ?
@@ -624,12 +624,12 @@ mod tests {
624624 assert_eq ! ( lookup_res. len( ) , 3 ) ;
625625
626626 let stat_res = backend_manager
627- . get_stats_for_table ( 1 , StatType :: TableRowCount as i32 , Some ( epoch_id) )
627+ . get_stats_for_table ( 1 , StatType :: TableRowCount , Some ( epoch_id) )
628628 . await ;
629629 assert ! ( stat_res. is_ok( ) ) ;
630630 assert_eq ! ( stat_res. unwrap( ) . unwrap( ) , json!( 300 ) ) ;
631631 let stat_res = backend_manager
632- . get_stats_for_attr ( [ 2 ] . to_vec ( ) , StatType :: NotNullCount as i32 , None )
632+ . get_stats_for_attr ( [ 2 ] . to_vec ( ) , StatType :: NotNullCount , None )
633633 . await ;
634634 assert ! ( stat_res. is_ok( ) ) ;
635635 assert_eq ! ( stat_res. unwrap( ) . unwrap( ) , json!( 200 ) ) ;
@@ -649,7 +649,7 @@ mod tests {
649649 . await
650650 . unwrap ( ) ;
651651 let stat = Stat {
652- stat_type : StatType :: NotNullCount as i32 ,
652+ stat_type : StatType :: NotNullCount ,
653653 stat_value : json ! ( 100 ) ,
654654 attr_ids : vec ! [ 1 ] ,
655655 table_id : None ,
@@ -731,7 +731,7 @@ mod tests {
731731 . await
732732 . unwrap ( ) ;
733733 let stat2 = Stat {
734- stat_type : StatType :: NotNullCount as i32 ,
734+ stat_type : StatType :: NotNullCount ,
735735 stat_value : json ! ( 200 ) ,
736736 attr_ids : vec ! [ 1 ] ,
737737 table_id : None ,
@@ -785,7 +785,7 @@ mod tests {
785785 // 3. Update existed stat with the same value
786786 let epoch_num = Event :: find ( ) . all ( & backend_manager. db ) . await . unwrap ( ) . len ( ) ;
787787 let stat3 = Stat {
788- stat_type : StatType :: NotNullCount as i32 ,
788+ stat_type : StatType :: NotNullCount ,
789789 stat_value : json ! ( 200 ) ,
790790 attr_ids : vec ! [ 1 ] ,
791791 table_id : None ,
@@ -826,21 +826,21 @@ mod tests {
826826
827827 let statistics: Vec < Stat > = vec ! [
828828 Stat {
829- stat_type: StatType :: TableRowCount as i32 ,
829+ stat_type: StatType :: TableRowCount ,
830830 stat_value: json!( 0 ) ,
831831 attr_ids: vec![ ] ,
832832 table_id: Some ( 1 ) ,
833833 name: "row_count" . to_string( ) ,
834834 } ,
835835 Stat {
836- stat_type: StatType :: TableRowCount as i32 ,
836+ stat_type: StatType :: TableRowCount ,
837837 stat_value: json!( 20 ) ,
838838 attr_ids: vec![ ] ,
839839 table_id: Some ( 1 ) ,
840840 name: "row_count" . to_string( ) ,
841841 } ,
842842 Stat {
843- stat_type: StatType :: TableRowCount as i32 ,
843+ stat_type: StatType :: TableRowCount ,
844844 stat_value: json!( 100 ) ,
845845 attr_ids: vec![ ] ,
846846 table_id: Some ( table_inserted_res. last_insert_id) ,
@@ -1044,7 +1044,7 @@ mod tests {
10441044 let backend_manager = binding. as_mut ( ) . unwrap ( ) ;
10451045 let epoch_id = 1 ;
10461046 let table_id = 1 ;
1047- let stat_type = StatType :: TableRowCount as i32 ;
1047+ let stat_type = StatType :: TableRowCount ;
10481048
10491049 // Get initial stats
10501050 let res = backend_manager
@@ -1061,7 +1061,7 @@ mod tests {
10611061 . await
10621062 . unwrap ( ) ;
10631063 let stat = Stat {
1064- stat_type : StatType :: TableRowCount as i32 ,
1064+ stat_type : StatType :: TableRowCount ,
10651065 stat_value : json ! ( 100 ) ,
10661066 attr_ids : vec ! [ ] ,
10671067 table_id : Some ( table_id) ,
@@ -1101,7 +1101,7 @@ mod tests {
11011101 let backend_manager = binding. as_mut ( ) . unwrap ( ) ;
11021102 let epoch_id = 1 ;
11031103 let attr_ids = vec ! [ 1 ] ;
1104- let stat_type = StatType :: Cardinality as i32 ;
1104+ let stat_type = StatType :: Cardinality ;
11051105
11061106 // Get initial stats
11071107 let res = backend_manager
@@ -1121,7 +1121,7 @@ mod tests {
11211121 . await
11221122 . unwrap ( ) ;
11231123 let stat = Stat {
1124- stat_type : StatType :: Cardinality as i32 ,
1124+ stat_type : StatType :: Cardinality ,
11251125 stat_value : json ! ( 100 ) ,
11261126 attr_ids : attr_ids. clone ( ) ,
11271127 table_id : None ,
@@ -1161,7 +1161,7 @@ mod tests {
11611161 let backend_manager = binding. as_mut ( ) . unwrap ( ) ;
11621162 let epoch_id = 1 ;
11631163 let attr_ids = vec ! [ 2 , 1 ] ;
1164- let stat_type = StatType :: Cardinality as i32 ;
1164+ let stat_type = StatType :: Cardinality ;
11651165
11661166 // Get initial stats
11671167 let res = backend_manager
@@ -1181,7 +1181,7 @@ mod tests {
11811181 . await
11821182 . unwrap ( ) ;
11831183 let stat = Stat {
1184- stat_type : StatType :: Cardinality as i32 ,
1184+ stat_type : StatType :: Cardinality ,
11851185 stat_value : json ! ( 111 ) ,
11861186 attr_ids : attr_ids. clone ( ) ,
11871187 table_id : None ,
0 commit comments