@@ -10,8 +10,8 @@ use super::{
1010} ;
1111use crate :: data_model:: { AggregationIdInfo , KeyByLabelValues , QueryConfig , SchemaConfig } ;
1212use crate :: engines:: query_result:: { QueryResult , RangeVectorElement } ;
13- use asap_types:: query_requirements:: QueryRequirements ;
14- use asap_types:: utils :: normalize_spatial_filter ;
13+ use asap_types:: query_requirements:: build_query_requirements_promql ;
14+ use asap_types:: PromQLSchema ;
1515use promql_utilities:: ast_matching:: PromQLMatchResult ;
1616use promql_utilities:: data_model:: KeyByLabelNames ;
1717use promql_utilities:: get_is_collapsable;
@@ -614,56 +614,6 @@ impl SimpleEngine {
614614 Some ( ( output_labels, QueryResult :: matrix ( combined) ) )
615615 }
616616
617- /// Extract QueryRequirements from a parsed PromQL match result.
618- /// Used as the fallback path when no query_configs entry is found.
619- fn build_query_requirements_promql (
620- & self ,
621- match_result : & PromQLMatchResult ,
622- query_pattern_type : QueryPatternType ,
623- ) -> Option < QueryRequirements > {
624- let ( metric, spatial_filter) = get_metric_and_spatial_filter ( match_result) ;
625-
626- let statistics = get_statistics_to_compute ( query_pattern_type, match_result)
627- . map_err ( |err| {
628- warn ! ( "{}" , err) ;
629- err
630- } )
631- . ok ( ) ?;
632-
633- let data_range_ms = match query_pattern_type {
634- QueryPatternType :: OnlySpatial => None ,
635- _ => match_result
636- . get_range_duration ( )
637- . map ( |d| d. num_seconds ( ) as u64 * 1000 ) ,
638- } ;
639-
640- let all_labels = match & self . inference_config . read ( ) . unwrap ( ) . schema {
641- SchemaConfig :: PromQL ( schema) => schema
642- . get_labels ( & metric)
643- . cloned ( )
644- . unwrap_or_else ( KeyByLabelNames :: empty) ,
645- _ => KeyByLabelNames :: empty ( ) ,
646- } ;
647-
648- let grouping_labels = match query_pattern_type {
649- QueryPatternType :: OnlyTemporal => all_labels,
650- QueryPatternType :: OnlySpatial | QueryPatternType :: OneTemporalOneSpatial => {
651- get_spatial_aggregation_output_labels ( match_result, & all_labels)
652- }
653- } ;
654-
655- Some ( QueryRequirements {
656- metric,
657- statistics,
658- data_range_ms,
659- grouping_labels,
660- spatial_filter_normalized : normalize_spatial_filter ( & spatial_filter) ,
661- // PromQL top-k does not constrain the sketch weighting; leave the
662- // count/sum discriminator unset so matching does not over-filter.
663- topk_count_events : None ,
664- } )
665- }
666-
667617 // /// Try to extract sketch query components from a PromQL query string.
668618 // ///
669619 // /// Attempts the standard AST parser first. If that fails (e.g. for custom
@@ -1085,8 +1035,18 @@ impl SimpleEngine {
10851035 "No query_config entry for PromQL query '{}'. Attempting capability-based matching." ,
10861036 query
10871037 ) ;
1088- let requirements =
1089- self . build_query_requirements_promql ( & match_result, query_pattern_type) ?;
1038+ let inference_config = self . inference_config . read ( ) . unwrap ( ) ;
1039+ let empty_schema = PromQLSchema :: new ( ) ;
1040+ let metric_schema = match & inference_config. schema {
1041+ SchemaConfig :: PromQL ( schema) => schema,
1042+ _ => & empty_schema,
1043+ } ;
1044+ let requirements = build_query_requirements_promql (
1045+ & query,
1046+ & match_result,
1047+ query_pattern_type,
1048+ metric_schema,
1049+ ) ?;
10901050 self . streaming_config
10911051 . read ( )
10921052 . unwrap ( )
0 commit comments