Skip to content

Commit 209bc7a

Browse files
committed
Fix lint errors.
1 parent 60616fd commit 209bc7a

2 files changed

Lines changed: 19 additions & 29 deletions

File tree

asap-query-engine/src/engines/simple_engine.rs

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::stores::{Store, TimestampedBucketsMap};
99
use core::panic;
1010
use promql_utilities::get_is_collapsable;
1111
use serde_json::Value;
12-
use std::collections::{HashMap, HashSet};
12+
use std::collections::HashMap;
1313
use std::sync::Arc;
1414
use std::time::Instant;
1515
use 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

3434
use 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)
4038
type 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 {

asap-query-engine/src/tests/elastic_dsl_query_tests.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66
#[cfg(test)]
77
mod tests {
88
use crate::data_model::{AggregateCore, KeyByLabelValues};
9-
use crate::precompute_operators::{
10-
CountMinSketchAccumulator, DatasketchesKLLAccumulator, DeltaSetAggregatorAccumulator,
11-
SumAccumulator,
12-
};
9+
use crate::precompute_operators::DatasketchesKLLAccumulator;
1310
use crate::tests::test_utilities::create_engine_multi_timestamp;
1411
use crate::QueryResult;
15-
use serde_json::{json, Value};
12+
use serde_json::json;
1613

1714
fn create_kll_accumulator_with_values(values: &[f64]) -> DatasketchesKLLAccumulator {
1815
let mut kll = DatasketchesKLLAccumulator::new(200);
@@ -22,6 +19,7 @@ mod tests {
2219
kll
2320
}
2421

22+
#[allow(clippy::type_complexity)]
2523
fn create_kll_data_with_timestamps(
2624
timestamps: &[u64],
2725
label_values: Vec<Option<Vec<String>>>,

0 commit comments

Comments
 (0)