Skip to content

Commit 8035608

Browse files
committed
Clippy & cleanup
1 parent da9f6fc commit 8035608

File tree

6 files changed

+27
-33
lines changed

6 files changed

+27
-33
lines changed

partiql-ast/src/pretty.rs

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use partiql_common::pretty::{
66
};
77
use pretty::{DocAllocator, DocBuilder};
88
use std::borrow::Cow;
9-
use std::num::NonZeroU32;
109

1110
impl<T> PrettyDoc for AstNode<T>
1211
where
@@ -1021,7 +1020,7 @@ impl PrettyDoc for GraphMatch {
10211020
shape.export.as_ref().map(|d| d.pretty_doc(arena)),
10221021
]
10231022
.into_iter()
1024-
.filter_map(|x| x)
1023+
.flatten()
10251024
.collect::<Vec<_>>();
10261025
if !shapes.is_empty() {
10271026
let docs = std::iter::once(match_expr).chain(shapes);
@@ -1033,7 +1032,7 @@ impl PrettyDoc for GraphMatch {
10331032
}
10341033

10351034
impl PrettyDoc for GraphTableRows {
1036-
fn pretty_doc<'b, D, A>(&'b self, arena: &'b D) -> DocBuilder<'b, D, A>
1035+
fn pretty_doc<'b, D, A>(&'b self, _arena: &'b D) -> DocBuilder<'b, D, A>
10371036
where
10381037
D: DocAllocator<'b, A>,
10391038
D::Doc: Clone,
@@ -1044,7 +1043,7 @@ impl PrettyDoc for GraphTableRows {
10441043
}
10451044

10461045
impl PrettyDoc for GraphTableColumns {
1047-
fn pretty_doc<'b, D, A>(&'b self, arena: &'b D) -> DocBuilder<'b, D, A>
1046+
fn pretty_doc<'b, D, A>(&'b self, _arena: &'b D) -> DocBuilder<'b, D, A>
10481047
where
10491048
D: DocAllocator<'b, A>,
10501049
D::Doc: Clone,
@@ -1055,7 +1054,7 @@ impl PrettyDoc for GraphTableColumns {
10551054
}
10561055

10571056
impl PrettyDoc for GraphTableExport {
1058-
fn pretty_doc<'b, D, A>(&'b self, arena: &'b D) -> DocBuilder<'b, D, A>
1057+
fn pretty_doc<'b, D, A>(&'b self, _arena: &'b D) -> DocBuilder<'b, D, A>
10591058
where
10601059
D: DocAllocator<'b, A>,
10611060
D::Doc: Clone,
@@ -1083,15 +1082,15 @@ impl PrettyDoc for GraphPattern {
10831082
mode.as_ref().map(|inner| inner.pretty_doc(arena)),
10841083
Some(patterns),
10851084
keep.as_ref().map(|inner| inner.pretty_doc(arena)),
1086-
self.where_clause.as_ref().map(|clause| {
1085+
where_clause.as_ref().map(|clause| {
10871086
arena.intersperse(
10881087
[arena.text("WHERE"), clause.pretty_doc(arena)],
10891088
arena.space(),
10901089
)
10911090
}),
10921091
]
10931092
.into_iter()
1094-
.filter_map(|x| x);
1093+
.flatten();
10951094

10961095
arena.intersperse(parts, arena.space())
10971096
}
@@ -1149,7 +1148,7 @@ impl PrettyDoc for GraphPathPrefix {
11491148
],
11501149
}
11511150
.into_iter()
1152-
.filter_map(|x| x)
1151+
.flatten()
11531152
.collect::<Vec<_>>();
11541153
arena.intersperse(parts, arena.space())
11551154
}
@@ -1190,7 +1189,7 @@ impl PrettyDoc for GraphPathPattern {
11901189

11911190
let parts = [var, prefix, Some(self.path.pretty_doc(arena))]
11921191
.into_iter()
1193-
.filter_map(|x| x);
1192+
.flatten();
11941193
arena.intersperse(parts, arena.space())
11951194
}
11961195
}
@@ -1217,7 +1216,7 @@ impl PrettyDoc for GraphPathSubPattern {
12171216

12181217
let parts = [var, mode, Some(self.path.pretty_doc(arena)), where_clause]
12191218
.into_iter()
1220-
.filter_map(|x| x);
1219+
.flatten();
12211220
arena.intersperse(parts, arena.space())
12221221
}
12231222
}
@@ -1258,7 +1257,7 @@ impl PrettyDoc for GraphMatchNode {
12581257
.map(|label| arena.concat([arena.text(":"), label.pretty_doc(arena)])),
12591258
]
12601259
.into_iter()
1261-
.filter_map(|x| x)
1260+
.flatten()
12621261
.collect();
12631262
let name = if name.is_empty() {
12641263
None
@@ -1271,7 +1270,7 @@ impl PrettyDoc for GraphMatchNode {
12711270
arena.space(),
12721271
)
12731272
});
1274-
let parts = [name, where_clause].into_iter().filter_map(|x| x);
1273+
let parts = [name, where_clause].into_iter().flatten();
12751274

12761275
let spec = arena.intersperse(parts, arena.space());
12771276
pretty_surrounded_doc(spec, "(", ")", arena).group()
@@ -1292,7 +1291,7 @@ impl PrettyDoc for GraphMatchEdge {
12921291
.map(|label| arena.concat([arena.text(":"), label.pretty_doc(arena)])),
12931292
]
12941293
.into_iter()
1295-
.filter_map(|x| x)
1294+
.flatten()
12961295
.collect();
12971296
let name = if name.is_empty() {
12981297
None
@@ -1307,7 +1306,7 @@ impl PrettyDoc for GraphMatchEdge {
13071306
});
13081307
let parts = [name, where_clause]
13091308
.into_iter()
1310-
.filter_map(|x| x)
1309+
.flatten()
13111310
.collect::<Vec<_>>();
13121311

13131312
let mut edge = if !parts.is_empty() {

partiql-logical-planner/src/graph.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use partiql_logical::graph::{
66
BindSpec, DirectionFilter, EdgeFilter, EdgeMatch, LabelFilter, NodeFilter, NodeMatch,
77
PathMatch, PathPattern, PathPatternMatch, StepFilter, TripleFilter, ValueFilter,
88
};
9-
use petgraph::visit::Walker;
109
use std::mem::take;
1110

1211
#[macro_export]
@@ -249,24 +248,24 @@ impl GraphToLogical {
249248
Ok(path?.into_iter().flatten().collect())
250249
}
251250
GraphMatchPathPattern::Union(_) => {
252-
not_yet_implemented_result!("MATCH expression UNION is not yet supported.")
251+
not_yet_implemented_result!("MATCH expression UNION is not yet supported.");
253252
}
254253
GraphMatchPathPattern::Multiset(_) => {
255-
not_yet_implemented_result!("MATCH expression MULTISET is not yet supported.")
254+
not_yet_implemented_result!("MATCH expression MULTISET is not yet supported.");
256255
}
257256
GraphMatchPathPattern::Questioned(_) => {
258-
not_yet_implemented_result!("MATCH expression QUESTIONED is not yet supported.")
257+
not_yet_implemented_result!("MATCH expression QUESTIONED is not yet supported.");
259258
}
260259
GraphMatchPathPattern::Quantified(_, _) => {
261-
not_yet_implemented_result!("MATCH expression QUANTIFIED is not yet supported.")
260+
not_yet_implemented_result!("MATCH expression QUANTIFIED is not yet supported.");
262261
}
263262
GraphMatchPathPattern::Sub(subpath) => self.plan_graph_subpath_pattern(subpath),
264-
GraphMatchPathPattern::Node(n) => self.plan_graph_pattern_part_node(&n),
265-
GraphMatchPathPattern::Edge(e) => self.plan_graph_pattern_part_edge(&e),
263+
GraphMatchPathPattern::Node(n) => self.plan_graph_pattern_part_node(n),
264+
GraphMatchPathPattern::Edge(e) => self.plan_graph_pattern_part_edge(e),
266265
GraphMatchPathPattern::Simplified(_) => {
267266
not_yet_implemented_result!(
268267
"MATCH expression Simplified Edge Expressions are not yet supported."
269-
)
268+
);
270269
}
271270
}
272271
}

partiql-logical-planner/src/lower.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ impl<'ast> Visitor<'ast> for AstToLogical<'_> {
19111911
let graph_reference = Box::new(env.pop().unwrap());
19121912
let graph_planner = crate::graph::GraphToLogical::default();
19131913

1914-
match graph_planner.plan_graph_match(&graph_match) {
1914+
match graph_planner.plan_graph_match(graph_match) {
19151915
Ok(pattern) => {
19161916
self.push_vexpr(ValueExpr::GraphMatch(GraphMatchExpr {
19171917
value: graph_reference,

partiql-parser/src/parse/partiql.lalrpop

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1924,14 +1924,14 @@ PuncSepStar<P, T>: Vec<T> = {
19241924

19251925
// This is a macro; see http://lalrpop.github.io/lalrpop/tutorial/006_macros.html
19261926
PuncSepPlus<P, T>: Vec<T> = {
1927-
<mut v:(<T> <P>)*> <e:T> => {
1927+
<v:(<T> <P>)*> <e:T> => {
19281928
v.into_iter().map(|t|t.0).chain(std::iter::once(e)).collect()
19291929
}
19301930
}
19311931

19321932
// This is a macro; see http://lalrpop.github.io/lalrpop/tutorial/006_macros.html
19331933
PuncSep2Plus<P, T>: Vec<T> = {
1934-
<mut v:(<T> <P>)+> <e:T> => {
1934+
<v:(<T> <P>)+> <e:T> => {
19351935
v.into_iter().map(|t|t.0).chain(std::iter::once(e)).collect()
19361936
}
19371937
}

partiql/benches/bench_eval_multi_like.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ fn employee_data() -> Vec<Value> {
239239

240240
// seed the rng with a known value to assure same data across runs
241241
let mut rng = rand::rngs::StdRng::from_seed([42; 32]);
242-
use rand::distributions::Distribution;
243-
let chars = rand::distributions::Alphanumeric;
244-
let random_size = rand::distributions::uniform::Uniform::from(5..=100);
242+
use rand::distr::Distribution;
243+
let chars = rand::distr::Alphanumeric;
244+
let random_size = rand::distr::uniform::Uniform::new_inclusive(5, 100).expect("rand");
245245

246246
// add random string prefix and suffix to each combined name
247247
let employee_data: Vec<Value> = combined

partiql/tests/graph.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
use insta::assert_snapshot;
22
use partiql_catalog::catalog::PartiqlCatalog;
3-
use partiql_catalog::context::SystemContext;
4-
use partiql_common::pretty::ToPretty;
5-
use partiql_eval::eval::graph::string_graph::StringGraphTypes;
6-
use partiql_eval::eval::BasicContext;
73
use partiql_eval::plan::EvaluationMode;
84
use partiql_extension_ion::decode::{IonDecodeResult, IonDecoderBuilder, IonDecoderConfig};
95

106
use crate::common::{compile, evaluate, lower, parse};
117
use partiql_extension_ion::Encoding;
12-
use partiql_value::{tuple, DateTime, Value};
8+
use partiql_value::{tuple, Value};
139

1410
mod common;
1511

0 commit comments

Comments
 (0)