Skip to content

Commit c2e21f1

Browse files
committed
fix some clippy warnings and allow the rest.
1 parent 7cb8972 commit c2e21f1

File tree

19 files changed

+57
-98
lines changed

19 files changed

+57
-98
lines changed

rust/cubesqlplanner/cubesqlplanner/Cargo.toml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,11 @@ too-many-arguments = "allow"
5656
useless_conversion = "allow"
5757
useless_format = "allow"
5858
vec_init_then_push = "allow"
59+
type_complexity = "allow"
60+
if_same_then_else = "allow"
61+
to_string_trait_impl = "allow"
62+
field_reassign_with_default = "allow"
63+
collapsible_match = "allow"
64+
wrong_self_convention = "allow"
65+
module_inception = "allow"
66+
comparison_chain = "allow"

rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/measure_matcher.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,8 @@ impl MeasureMatcher {
2424
pub fn try_match(&self, symbol: &Rc<MemberSymbol>) -> Result<bool, CubeError> {
2525
match symbol.as_ref() {
2626
MemberSymbol::Measure(measure) => {
27-
if self.pre_aggregation_measures.contains(&measure.full_name()) {
28-
if !self.only_addictive || measure.is_addictive() {
29-
return Ok(true);
30-
}
27+
if self.pre_aggregation_measures.contains(&measure.full_name()) && (!self.only_addictive || measure.is_addictive()) {
28+
return Ok(true);
3129
}
3230
}
3331
MemberSymbol::MemberExpression(_) => {

rust/cubesqlplanner/cubesqlplanner/src/logical_plan/optimizers/pre_aggregation/optimizer.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ impl MatchState {
2323
if matches!(self, MatchState::Partial) || matches!(other, MatchState::Partial) {
2424
return MatchState::Partial;
2525
}
26-
return MatchState::Full;
26+
MatchState::Full
2727
}
2828
}
2929

@@ -233,9 +233,7 @@ impl PreAggregationOptimizer {
233233
}
234234

235235
if let Some(multi_stage_item) = multi_stage_queries
236-
.iter()
237-
.cloned()
238-
.find(|query| &query.name == multi_stage_name)
236+
.iter().find(|&query| &query.name == multi_stage_name).cloned()
239237
{
240238
match &multi_stage_item.member_type {
241239
MultiStageMemberLogicalType::LeafMeasure(multi_stage_leaf_measure) => self
@@ -432,7 +430,7 @@ impl PreAggregationOptimizer {
432430
.map(|(d, _)| d.clone()),
433431
)
434432
.collect(),
435-
measures: pre_aggregation.measures.iter().cloned().collect(),
433+
measures: pre_aggregation.measures.to_vec(),
436434
multiplied_measures: HashSet::new(),
437435
};
438436
let pre_aggregation = PreAggregation {

rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,11 @@ use itertools::Itertools;
1616
use std::collections::HashMap;
1717
use std::collections::HashSet;
1818
use std::rc::Rc;
19-
const TOTAL_COUNT: &'static str = "total_count";
20-
const ORIGINAL_QUERY: &'static str = "original_query";
19+
const TOTAL_COUNT: &str = "total_count";
20+
const ORIGINAL_QUERY: &str = "original_query";
2121

2222
#[derive(Clone, Debug)]
23+
#[derive(Default)]
2324
struct PhysicalPlanBuilderContext {
2425
pub alias_prefix: Option<String>,
2526
pub render_measure_as_state: bool, //Render measure as state, for example hll state for count_approx
@@ -28,17 +29,6 @@ struct PhysicalPlanBuilderContext {
2829
pub original_sql_pre_aggregations: HashMap<String, String>,
2930
}
3031

31-
impl Default for PhysicalPlanBuilderContext {
32-
fn default() -> Self {
33-
Self {
34-
alias_prefix: None,
35-
render_measure_as_state: false,
36-
render_measure_for_ungrouped: false,
37-
time_shifts: HashMap::new(),
38-
original_sql_pre_aggregations: HashMap::new(),
39-
}
40-
}
41-
}
4232

4333
impl PhysicalPlanBuilderContext {
4434
pub fn make_sql_nodes_factory(&self) -> SqlNodesFactory {

rust/cubesqlplanner/cubesqlplanner/src/plan/builder/select.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,11 +203,8 @@ impl SelectBuilder {
203203
source: &SingleAliasedSource,
204204
refs: &mut HashMap<String, String>,
205205
) {
206-
match &source.source {
207-
SingleSource::Cube(cube) => {
208-
refs.insert(cube.name().clone(), source.alias.clone());
209-
}
210-
_ => {}
206+
if let SingleSource::Cube(cube) = &source.source {
207+
refs.insert(cube.name().clone(), source.alias.clone());
211208
}
212209
}
213210

rust/cubesqlplanner/cubesqlplanner/src/planner/base_dimension.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,11 @@ impl BaseDimension {
178178
pub fn is_sub_query(&self) -> bool {
179179
self.definition
180180
.as_ref()
181-
.map_or(false, |def| def.static_data().sub_query.unwrap_or(false))
181+
.is_some_and(|def| def.static_data().sub_query.unwrap_or(false))
182182
}
183183

184184
pub fn propagate_filters_to_sub_query(&self) -> bool {
185-
self.definition.as_ref().map_or(false, |def| {
185+
self.definition.as_ref().is_some_and(|def| {
186186
def.static_data()
187187
.propagate_filters_to_sub_query
188188
.unwrap_or(false)

rust/cubesqlplanner/cubesqlplanner/src/planner/base_measure.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,19 +185,19 @@ impl BaseMeasure {
185185
pub fn reduce_by(&self) -> Option<Vec<String>> {
186186
self.definition
187187
.as_ref()
188-
.map_or(None, |d| d.static_data().reduce_by_references.clone())
188+
.and_then(|d| d.static_data().reduce_by_references.clone())
189189
}
190190

191191
pub fn add_group_by(&self) -> Option<Vec<String>> {
192192
self.definition
193193
.as_ref()
194-
.map_or(None, |d| d.static_data().add_group_by_references.clone())
194+
.and_then(|d| d.static_data().add_group_by_references.clone())
195195
}
196196

197197
pub fn group_by(&self) -> Option<Vec<String>> {
198198
self.definition
199199
.as_ref()
200-
.map_or(None, |d| d.static_data().group_by_references.clone())
200+
.and_then(|d| d.static_data().group_by_references.clone())
201201
}
202202

203203
//FIXME dublicate with symbol
@@ -218,13 +218,13 @@ impl BaseMeasure {
218218
pub fn is_multi_stage(&self) -> bool {
219219
self.definition
220220
.as_ref()
221-
.map_or(false, |d| d.static_data().multi_stage.unwrap_or(false))
221+
.is_some_and(|d| d.static_data().multi_stage.unwrap_or(false))
222222
}
223223

224224
pub fn rolling_window(&self) -> Option<RollingWindow> {
225225
self.definition
226226
.as_ref()
227-
.map_or(None, |d| d.static_data().rolling_window.clone())
227+
.and_then(|d| d.static_data().rolling_window.clone())
228228
}
229229

230230
pub fn is_rolling_window(&self) -> bool {

rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_filter.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use crate::planner::{evaluate_with_context, FiltersContext, VisitorContext};
88
use cubenativeutils::CubeError;
99
use std::rc::Rc;
1010

11-
const FROM_PARTITION_RANGE: &'static str = "__FROM_PARTITION_RANGE";
11+
const FROM_PARTITION_RANGE: &str = "__FROM_PARTITION_RANGE";
1212

13-
const TO_PARTITION_RANGE: &'static str = "__TO_PARTITION_RANGE";
13+
const TO_PARTITION_RANGE: &str = "__TO_PARTITION_RANGE";
1414

1515
#[derive(Debug, Clone, PartialEq, Eq)]
1616
pub enum FilterType {
@@ -589,7 +589,7 @@ impl BaseFilter {
589589
}
590590
let from = self.format_from_date(value)?;
591591

592-
let res = if use_db_time_zone && &from != FROM_PARTITION_RANGE {
592+
let res = if use_db_time_zone && from != FROM_PARTITION_RANGE {
593593
self.query_tools.base_tools().in_db_time_zone(from)?
594594
} else {
595595
from
@@ -607,7 +607,7 @@ impl BaseFilter {
607607
}
608608
let from = self.format_to_date(value)?;
609609

610-
let res = if use_db_time_zone && &from != TO_PARTITION_RANGE {
610+
let res = if use_db_time_zone && from != TO_PARTITION_RANGE {
611611
self.query_tools.base_tools().in_db_time_zone(from)?
612612
} else {
613613
from
@@ -705,10 +705,10 @@ impl BaseFilter {
705705
as_date_time,
706706
)
707707
} else {
708-
return Err(CubeError::user(format!(
708+
Err(CubeError::user(format!(
709709
"Arguments for timestamp parameter for operator {} is not valid",
710710
self.filter_operator().to_string()
711-
)));
711+
)))
712712
}
713713
}
714714
}

rust/cubesqlplanner/cubesqlplanner/src/planner/planners/multi_stage/rolling_window_planner.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl RollingWindowPlanner {
6363
}
6464
}
6565

66-
if time_dimensions.len() == 0 {
66+
if time_dimensions.is_empty() {
6767
let rolling_base = self.add_rolling_window_base(
6868
member.clone(),
6969
state.clone(),
@@ -254,7 +254,7 @@ impl RollingWindowPlanner {
254254
let is_to_date = rolling_window
255255
.rolling_type
256256
.as_ref()
257-
.map_or(false, |tp| tp == "to_date");
257+
.is_some_and(|tp| tp == "to_date");
258258

259259
if is_to_date {
260260
if let Some(granularity) = &rolling_window.granularity {

rust/cubesqlplanner/cubesqlplanner/src/planner/query_properties.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,7 @@ impl QueryProperties {
479479
.into_values()
480480
.map(|measures_and_join| {
481481
(
482-
measures_and_join.iter().next().unwrap().1 .1.clone(),
482+
measures_and_join.first().unwrap().1 .1.clone(),
483483
measures_and_join
484484
.into_iter()
485485
.flat_map(|m| m.0)
@@ -506,7 +506,7 @@ impl QueryProperties {
506506
.join(", ")
507507
)));
508508
}
509-
Ok(self.multi_fact_join_groups.iter().next().unwrap().0.clone())
509+
Ok(self.multi_fact_join_groups.first().unwrap().0.clone())
510510
}
511511

512512
pub fn measures(&self) -> &Vec<Rc<BaseMeasure>> {
@@ -796,9 +796,7 @@ impl QueryProperties {
796796
result.multi_stage_measures.push(m.clone())
797797
} else {
798798
let join = self
799-
.compute_join_multi_fact_groups_with_measures(&vec![m.clone()])?
800-
.iter()
801-
.next()
799+
.compute_join_multi_fact_groups_with_measures(&vec![m.clone()])?.first()
802800
.expect("No join groups returned for single measure multi-fact join group")
803801
.0
804802
.clone();
@@ -845,10 +843,8 @@ impl QueryProperties {
845843
}
846844
FilterItem::Item(item) => {
847845
let item_member_name = item.member_name();
848-
if measures
849-
.iter()
850-
.find(|m| m.full_name() == item_member_name)
851-
.is_none()
846+
if !measures
847+
.iter().any(|m| m.full_name() == item_member_name)
852848
{
853849
measures.push(BaseMeasure::try_new_required(
854850
item.member_evaluator().clone(),

0 commit comments

Comments
 (0)