Skip to content

Commit ff59289

Browse files
committed
refactor(cubesql): Fix clone_on_copy warning
1 parent 9e93bd5 commit ff59289

File tree

17 files changed

+97
-103
lines changed

17 files changed

+97
-103
lines changed

rust/cubesql/cubesql/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@ harness = false
9393
# Feel free to remove any rule from here and fix all warnings with it
9494
# Or to write a comment why rule should stay disabled
9595
[lints.clippy]
96-
clone_on_copy = "allow"
9796
collapsible_if = "allow"
9897
collapsible_match = "allow"
9998
collapsible_else_if = "allow"

rust/cubesql/cubesql/src/compile/engine/df/optimizers/filter_push_down.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,10 @@ fn filter_push_down(
326326
optimizer_config,
327327
)?),
328328
on: on.clone(),
329-
join_type: join_type.clone(),
330-
join_constraint: join_constraint.clone(),
329+
join_type: *join_type,
330+
join_constraint: *join_constraint,
331331
schema: schema.clone(),
332-
null_equals_null: null_equals_null.clone(),
332+
null_equals_null: *null_equals_null,
333333
}),
334334
)
335335
}
@@ -483,8 +483,8 @@ fn filter_push_down(
483483
issue_filter(
484484
predicates,
485485
LogicalPlan::Limit(Limit {
486-
skip: skip.clone(),
487-
fetch: fetch.clone(),
486+
skip: *skip,
487+
fetch: *fetch,
488488
input: Arc::new(filter_push_down(
489489
optimizer,
490490
input,

rust/cubesql/cubesql/src/compile/engine/df/optimizers/limit_push_down.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,10 @@ fn limit_push_down(
203203
optimizer_config,
204204
)?),
205205
on: on.clone(),
206-
join_type: join_type.clone(),
207-
join_constraint: join_constraint.clone(),
206+
join_type: *join_type,
207+
join_constraint: *join_constraint,
208208
schema: schema.clone(),
209-
null_equals_null: null_equals_null.clone(),
209+
null_equals_null: *null_equals_null,
210210
}),
211211
)
212212
}

rust/cubesql/cubesql/src/compile/engine/df/optimizers/sort_push_down.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ fn sort_push_down(
7272
} => Ok(if is_column_expr(expr) {
7373
rewrite(expr, &rewrite_map)?.map(|expr| Expr::Sort {
7474
expr: Box::new(expr),
75-
asc: asc.clone(),
76-
nulls_first: nulls_first.clone(),
75+
asc: *asc,
76+
nulls_first: *nulls_first,
7777
})
7878
} else {
7979
None
@@ -199,10 +199,10 @@ fn sort_push_down(
199199
)?),
200200
right: Arc::new(sort_push_down(optimizer, right, None, optimizer_config)?),
201201
on: on.clone(),
202-
join_type: join_type.clone(),
203-
join_constraint: join_constraint.clone(),
202+
join_type: *join_type,
203+
join_constraint: *join_constraint,
204204
schema: schema.clone(),
205-
null_equals_null: null_equals_null.clone(),
205+
null_equals_null: *null_equals_null,
206206
}));
207207
}
208208
}
@@ -213,10 +213,10 @@ fn sort_push_down(
213213
left: Arc::new(sort_push_down(optimizer, left, None, optimizer_config)?),
214214
right: Arc::new(sort_push_down(optimizer, right, None, optimizer_config)?),
215215
on: on.clone(),
216-
join_type: join_type.clone(),
217-
join_constraint: join_constraint.clone(),
216+
join_type: *join_type,
217+
join_constraint: *join_constraint,
218218
schema: schema.clone(),
219-
null_equals_null: null_equals_null.clone(),
219+
null_equals_null: *null_equals_null,
220220
}),
221221
)
222222
}
@@ -285,8 +285,8 @@ fn sort_push_down(
285285
issue_sort(
286286
sort_expr,
287287
LogicalPlan::Limit(Limit {
288-
skip: skip.clone(),
289-
fetch: fetch.clone(),
288+
skip: *skip,
289+
fetch: *fetch,
290290
input: Arc::new(sort_push_down(optimizer, input, None, optimizer_config)?),
291291
}),
292292
)

rust/cubesql/cubesql/src/compile/engine/df/optimizers/utils.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
4444
};
4545
rewrites.map(|(left, right)| Expr::BinaryExpr {
4646
left: Box::new(left),
47-
op: op.clone(),
47+
op: *op,
4848
right: Box::new(right),
4949
})
5050
}
@@ -60,9 +60,9 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
6060
};
6161
rewrites.map(|(left, right)| Expr::AnyExpr {
6262
left: Box::new(left),
63-
op: op.clone(),
63+
op: *op,
6464
right: Box::new(right),
65-
all: all.clone(),
65+
all: *all,
6666
})
6767
}
6868
Expr::Like(Like {
@@ -77,10 +77,10 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
7777
};
7878
rewrites.map(|(expr, pattern)| {
7979
Expr::Like(Like {
80-
negated: negated.clone(),
80+
negated: *negated,
8181
expr: Box::new(expr),
8282
pattern: Box::new(pattern),
83-
escape_char: escape_char.clone(),
83+
escape_char: *escape_char,
8484
})
8585
})
8686
}
@@ -96,10 +96,10 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
9696
};
9797
rewrites.map(|(expr, pattern)| {
9898
Expr::ILike(Like {
99-
negated: negated.clone(),
99+
negated: *negated,
100100
expr: Box::new(expr),
101101
pattern: Box::new(pattern),
102-
escape_char: escape_char.clone(),
102+
escape_char: *escape_char,
103103
})
104104
})
105105
}
@@ -115,10 +115,10 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
115115
};
116116
rewrites.map(|(expr, pattern)| {
117117
Expr::SimilarTo(Like {
118-
negated: negated.clone(),
118+
negated: *negated,
119119
expr: Box::new(expr),
120120
pattern: Box::new(pattern),
121-
escape_char: escape_char.clone(),
121+
escape_char: *escape_char,
122122
})
123123
})
124124
}
@@ -148,7 +148,7 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
148148
};
149149
rewrites.map(|(expr, low, high)| Expr::Between {
150150
expr: Box::new(expr),
151-
negated: negated.clone(),
151+
negated: *negated,
152152
low: Box::new(low),
153153
high: Box::new(high),
154154
})
@@ -211,8 +211,8 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
211211
nulls_first,
212212
} => rewrite(expr, map)?.map(|expr| Expr::Sort {
213213
expr: Box::new(expr),
214-
asc: asc.clone(),
215-
nulls_first: nulls_first.clone(),
214+
asc: *asc,
215+
nulls_first: *nulls_first,
216216
}),
217217
Expr::ScalarFunction { fun, args } => args
218218
.iter()
@@ -249,7 +249,7 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
249249
.map(|args| Expr::AggregateFunction {
250250
fun: fun.clone(),
251251
args,
252-
distinct: distinct.clone(),
252+
distinct: *distinct,
253253
}),
254254
Expr::WindowFunction {
255255
fun,
@@ -283,7 +283,7 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
283283
args,
284284
partition_by,
285285
order_by,
286-
window_frame: window_frame.clone(),
286+
window_frame: *window_frame,
287287
})
288288
}
289289
Expr::AggregateUDF { fun, args } => args
@@ -310,7 +310,7 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
310310
.map(|list| Expr::InList {
311311
expr: Box::new(expr),
312312
list,
313-
negated: negated.clone(),
313+
negated: *negated,
314314
})
315315
}
316316
// As rewrites are used to push things down or up the plan, wildcards
@@ -329,7 +329,7 @@ pub fn rewrite(expr: &Expr, map: &HashMap<Column, Option<Expr>>) -> Result<Optio
329329
rewrites.map(|(expr, subquery)| Expr::InSubquery {
330330
expr: Box::new(expr),
331331
subquery: Box::new(subquery),
332-
negated: negated.clone(),
332+
negated: *negated,
333333
})
334334
}
335335
})

rust/cubesql/cubesql/src/compile/engine/df/scan.rs

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,7 @@ impl UserDefinedLogicalNode for WrappedSelectNode {
281281
.map(|i| Arc::new(inputs[i].clone()))
282282
.collect::<Vec<_>>();
283283
let mut joins_expr = vec![];
284-
let join_types = self
285-
.joins
286-
.iter()
287-
.map(|(_, _, t)| t.clone())
288-
.collect::<Vec<_>>();
284+
let join_types = self.joins.iter().map(|(_, _, t)| *t).collect::<Vec<_>>();
289285
let mut filter_expr = vec![];
290286
let mut having_expr = vec![];
291287
let mut order_expr = vec![];
@@ -332,7 +328,7 @@ impl UserDefinedLogicalNode for WrappedSelectNode {
332328

333329
Arc::new(WrappedSelectNode::new(
334330
self.schema.clone(),
335-
self.select_type.clone(),
331+
self.select_type,
336332
projection_expr,
337333
self.subqueries.clone(),
338334
group_expr,
@@ -976,7 +972,7 @@ pub fn transform_response<V: ValueObject>(
976972
},
977973
},
978974
{
979-
(ScalarValue::Int16(v), builder) => builder.append_option(v.clone())?,
975+
(ScalarValue::Int16(v), builder) => builder.append_option(*v)?,
980976
}
981977
)
982978
}
@@ -1001,7 +997,7 @@ pub fn transform_response<V: ValueObject>(
1001997
},
1002998
},
1003999
{
1004-
(ScalarValue::Int32(v), builder) => builder.append_option(v.clone())?,
1000+
(ScalarValue::Int32(v), builder) => builder.append_option(*v)?,
10051001
}
10061002
)
10071003
}
@@ -1026,7 +1022,7 @@ pub fn transform_response<V: ValueObject>(
10261022
},
10271023
},
10281024
{
1029-
(ScalarValue::Int64(v), builder) => builder.append_option(v.clone())?,
1025+
(ScalarValue::Int64(v), builder) => builder.append_option(*v)?,
10301026
}
10311027
)
10321028
}
@@ -1051,7 +1047,7 @@ pub fn transform_response<V: ValueObject>(
10511047
},
10521048
},
10531049
{
1054-
(ScalarValue::Float32(v), builder) => builder.append_option(v.clone())?,
1050+
(ScalarValue::Float32(v), builder) => builder.append_option(*v)?,
10551051
}
10561052
)
10571053
}
@@ -1076,7 +1072,7 @@ pub fn transform_response<V: ValueObject>(
10761072
},
10771073
},
10781074
{
1079-
(ScalarValue::Float64(v), builder) => builder.append_option(v.clone())?,
1075+
(ScalarValue::Float64(v), builder) => builder.append_option(*v)?,
10801076
}
10811077
)
10821078
}
@@ -1099,7 +1095,7 @@ pub fn transform_response<V: ValueObject>(
10991095
},
11001096
},
11011097
{
1102-
(ScalarValue::Boolean(v), builder) => builder.append_option(v.clone())?,
1098+
(ScalarValue::Boolean(v), builder) => builder.append_option(*v)?,
11031099
}
11041100
)
11051101
}
@@ -1141,7 +1137,7 @@ pub fn transform_response<V: ValueObject>(
11411137
},
11421138
},
11431139
{
1144-
(ScalarValue::TimestampNanosecond(v, None), builder) => builder.append_option(v.clone())?,
1140+
(ScalarValue::TimestampNanosecond(v, None), builder) => builder.append_option(*v)?,
11451141
}
11461142
)
11471143
}
@@ -1177,7 +1173,7 @@ pub fn transform_response<V: ValueObject>(
11771173
},
11781174
},
11791175
{
1180-
(ScalarValue::TimestampMillisecond(v, None), builder) => builder.append_option(v.clone())?,
1176+
(ScalarValue::TimestampMillisecond(v, None), builder) => builder.append_option(*v)?,
11811177
}
11821178
)
11831179
}
@@ -1217,7 +1213,7 @@ pub fn transform_response<V: ValueObject>(
12171213
}
12181214
},
12191215
{
1220-
(ScalarValue::Date32(v), builder) => builder.append_option(v.clone())?,
1216+
(ScalarValue::Date32(v), builder) => builder.append_option(*v)?,
12211217
}
12221218
)
12231219
}
@@ -1279,7 +1275,7 @@ pub fn transform_response<V: ValueObject>(
12791275
// TODO
12801276
},
12811277
{
1282-
(ScalarValue::IntervalYearMonth(v), builder) => builder.append_option(v.clone())?,
1278+
(ScalarValue::IntervalYearMonth(v), builder) => builder.append_option(*v)?,
12831279
}
12841280
)
12851281
}
@@ -1293,7 +1289,7 @@ pub fn transform_response<V: ValueObject>(
12931289
// TODO
12941290
},
12951291
{
1296-
(ScalarValue::IntervalDayTime(v), builder) => builder.append_option(v.clone())?,
1292+
(ScalarValue::IntervalDayTime(v), builder) => builder.append_option(*v)?,
12971293
}
12981294
)
12991295
}
@@ -1307,7 +1303,7 @@ pub fn transform_response<V: ValueObject>(
13071303
// TODO
13081304
},
13091305
{
1310-
(ScalarValue::IntervalMonthDayNano(v), builder) => builder.append_option(v.clone())?,
1306+
(ScalarValue::IntervalMonthDayNano(v), builder) => builder.append_option(*v)?,
13111307
}
13121308
)
13131309
}

rust/cubesql/cubesql/src/compile/engine/df/wrapper.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1075,7 +1075,7 @@ impl CubeScanWrapperNode {
10751075
alias: subq_alias.unwrap_or_else(|| alias.clone()),
10761076
sql: subq_sql_string,
10771077
condition: cond.clone(),
1078-
join_type: join_type.clone(),
1078+
join_type: join_type,
10791079
});
10801080
known_join_subqueries.insert(alias.clone());
10811081
}
@@ -1365,21 +1365,21 @@ impl CubeScanWrapperNode {
13651365
load_request.order.clone()
13661366
},
13671367
ungrouped: if let WrappedSelectType::Projection = select_type {
1368-
load_request.ungrouped.clone()
1368+
load_request.ungrouped
13691369
} else {
13701370
None
13711371
},
13721372
// TODO is it okay to just override limit?
13731373
limit: if let Some(limit) = limit {
13741374
Some(limit as i32)
13751375
} else {
1376-
load_request.limit.clone()
1376+
load_request.limit
13771377
},
13781378
// TODO is it okay to just override offset?
13791379
offset: if let Some(offset) = offset {
13801380
Some(offset as i32)
13811381
} else {
1382-
load_request.offset.clone()
1382+
load_request.offset
13831383
},
13841384

13851385
// Original scan node can already have consumed filters from Logical plan

rust/cubesql/cubesql/src/compile/rewrite/analysis.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ impl LogicalPlanAnalysis {
350350
egraph: &EGraph<LogicalPlanLanguage, Self>,
351351
enode: &LogicalPlanLanguage,
352352
) -> Option<usize> {
353-
let trivial_push_down = |id| egraph.index(id).data.trivial_push_down.clone();
353+
let trivial_push_down = |id| egraph.index(id).data.trivial_push_down;
354354
match enode {
355355
LogicalPlanLanguage::ColumnExpr(_) => Some(0),
356356
LogicalPlanLanguage::LiteralExpr(_) => Some(0),
@@ -1244,7 +1244,7 @@ impl LogicalPlanAnalysis {
12441244
egraph: &EGraph<LogicalPlanLanguage, Self>,
12451245
enode: &LogicalPlanLanguage,
12461246
) -> Option<bool> {
1247-
let is_empty_list = |id| egraph.index(id).data.is_empty_list.clone();
1247+
let is_empty_list = |id| egraph.index(id).data.is_empty_list;
12481248
match enode {
12491249
LogicalPlanLanguage::FilterOpFilters(params)
12501250
| LogicalPlanLanguage::CubeScanFilters(params)

0 commit comments

Comments
 (0)