@@ -9,7 +9,7 @@ use crate::stores::{Store, TimestampedBucketsMap};
99use core:: panic;
1010use promql_utilities:: get_is_collapsable;
1111use serde_json:: Value ;
12- use std:: collections:: { HashMap , HashSet } ;
12+ use std:: collections:: HashMap ;
1313use std:: sync:: Arc ;
1414use std:: time:: Instant ;
1515use tracing:: { debug, warn} ;
@@ -32,9 +32,7 @@ use sqlparser::parser::Parser as parser;
3232// SQL issue: refactor simpleengine to create matchresult similar to SQLquerydata
3333
3434use elastic_dsl_utilities:: pattern:: parse_and_classify;
35- use elastic_dsl_utilities:: types:: {
36- EsDslQueryPattern , GroupBySpec , MetricAggType , MetricAggregation ,
37- } ;
35+ use elastic_dsl_utilities:: types:: { EsDslQueryPattern , GroupBySpec , MetricAggType } ;
3836
3937// Type alias for merged outputs (single aggregate per key after merging)
4038type MergedOutputsMap = HashMap < Option < KeyByLabelValues > , Box < dyn AggregateCore > > ;
@@ -1517,7 +1515,7 @@ impl SimpleEngine {
15171515 // 1. Parse query DSL somehow. Elasticsearch DSL crate does not support deserializing, but maybe can use Opensearch instead?
15181516 // 2. Determine whether query is supported using some AST representation or hardcoded pattern matching.
15191517 let query_pattern: EsDslQueryPattern =
1520- parse_and_classify ( & query) . unwrap_or_else ( |_| EsDslQueryPattern :: Unknown ) ;
1518+ parse_and_classify ( & query) . unwrap_or ( EsDslQueryPattern :: Unknown ) ;
15211519 match query_pattern {
15221520 EsDslQueryPattern :: Unknown => {
15231521 debug ! ( "Could not parse query into known pattern" ) ;
@@ -1564,7 +1562,7 @@ impl SimpleEngine {
15641562 . unwrap_or_else ( KeyByLabelNames :: empty) ;
15651563
15661564 Some ( QueryExecutionContext {
1567- metric : metric ,
1565+ metric,
15681566 metadata : query_metadata,
15691567 store_plan : query_plan. clone ( ) ,
15701568 agg_info : agg_info. clone ( ) ,
@@ -1592,9 +1590,7 @@ impl SimpleEngine {
15921590 // By default, we only include grouping labels in the output for ES DSL.
15931591 let mut query_output_labels = match query_pattern. get_groupby_spec ( ) {
15941592 Some ( GroupBySpec :: Terms { field } ) => KeyByLabelNames :: new ( vec ! [ field. clone( ) ] ) ,
1595- Some ( GroupBySpec :: MultiTerms { fields } ) => {
1596- KeyByLabelNames :: new ( fields. iter ( ) . cloned ( ) . collect ( ) )
1597- }
1593+ Some ( GroupBySpec :: MultiTerms { fields } ) => KeyByLabelNames :: new ( fields. to_vec ( ) ) ,
15981594 None => KeyByLabelNames :: empty ( ) ,
15991595 } ;
16001596
@@ -1616,23 +1612,19 @@ impl SimpleEngine {
16161612 }
16171613
16181614 let mut query_kwargs = HashMap :: new ( ) ; // Placeholder - build based on query and statistic
1619- match aggregation. agg_type {
1620- MetricAggType :: Percentiles => {
1621- // Extract quantile value from aggregation parameters and add to query_kwargs
1622- if let Some ( params) = & aggregation. params {
1623- if let Some ( percents) = params. get ( "percents" ) {
1624- // Get first value from percents array since we only support one quantile argument for now.
1625- let quantile = percents
1626- . as_array ( )
1627- . and_then ( |arr| arr. first ( ) )
1628- . and_then ( |v| v. as_f64 ( ) ) ;
1629- // ES percentiles are specified as values between 0 and 100, but we want to convert to 0-1 range for our internal representation.
1630- query_kwargs
1631- . insert ( "quantile" . to_string ( ) , ( quantile? / 100.0 ) . to_string ( ) ) ;
1632- }
1615+ if aggregation. agg_type == MetricAggType :: Percentiles {
1616+ // Extract quantile value from aggregation parameters and add to query_kwargs
1617+ if let Some ( params) = & aggregation. params {
1618+ if let Some ( percents) = params. get ( "percents" ) {
1619+ // Get first value from percents array since we only support one quantile argument for now.
1620+ let quantile = percents
1621+ . as_array ( )
1622+ . and_then ( |arr| arr. first ( ) )
1623+ . and_then ( |v| v. as_f64 ( ) ) ;
1624+ // ES percentiles are specified as values between 0 and 100, but we want to convert to 0-1 range for our internal representation.
1625+ query_kwargs. insert ( "quantile" . to_string ( ) , ( quantile? / 100.0 ) . to_string ( ) ) ;
16331626 }
16341627 }
1635- _ => { }
16361628 }
16371629
16381630 let metadata = QueryMetadata {
0 commit comments