Skip to content

Commit 361f0f0

Browse files
authored
chore(cubesql): Clippy Cleanup, part 1 (#8590)
* Replace &Vec<T> with &[T] in pg-srv * Replace &Vec<T> with &[T] in PostgreSQL information_schema * Remove useless references in pg-srv * Remove useless references in PostgreSQL information_schema * Replace clone call with deref for Copy types in PostgreSQL information_schema * Replace vec!+push with just vec! in MySQL information_schema * Replace vec!+push with just vec! in PostgreSQL information_schema * Replace vec!+push with just vec! in Redshift information_schema
1 parent 547a41b commit 361f0f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+686
-717
lines changed

rust/cubesql/cubesql/src/compile/engine/information_schema/mysql/collations.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,15 @@ impl InformationSchemaCollationsBuilder {
6868
}
6969

7070
fn finish(mut self) -> Vec<Arc<dyn Array>> {
71-
let mut columns: Vec<Arc<dyn Array>> = vec![];
72-
73-
columns.push(Arc::new(self.collation_names.finish()));
74-
columns.push(Arc::new(self.character_set_names.finish()));
75-
columns.push(Arc::new(self.ids.finish()));
76-
columns.push(Arc::new(self.is_defaults.finish()));
77-
columns.push(Arc::new(self.is_compiled_values.finish()));
78-
columns.push(Arc::new(self.sortlens.finish()));
79-
columns.push(Arc::new(self.pad_attributes.finish()));
71+
let columns: Vec<Arc<dyn Array>> = vec![
72+
Arc::new(self.collation_names.finish()),
73+
Arc::new(self.character_set_names.finish()),
74+
Arc::new(self.ids.finish()),
75+
Arc::new(self.is_defaults.finish()),
76+
Arc::new(self.is_compiled_values.finish()),
77+
Arc::new(self.sortlens.finish()),
78+
Arc::new(self.pad_attributes.finish()),
79+
];
8080

8181
columns
8282
}

rust/cubesql/cubesql/src/compile/engine/information_schema/mysql/key_column_usage.rs

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -66,51 +66,22 @@ impl TableProvider for InfoSchemaKeyColumnUsageProvider {
6666
_filters: &[Expr],
6767
_limit: Option<usize>,
6868
) -> Result<Arc<dyn ExecutionPlan>, DataFusionError> {
69-
let mut data: Vec<Arc<dyn Array>> = vec![];
70-
data.push(Arc::new(new_string_array_with_placeholder(
71-
0,
72-
Some("".to_string()),
73-
)));
74-
data.push(Arc::new(new_string_array_with_placeholder(
75-
0,
76-
Some("".to_string()),
77-
)));
78-
data.push(Arc::new(new_string_array_with_placeholder(
79-
0,
80-
Some("".to_string()),
81-
)));
82-
data.push(Arc::new(new_string_array_with_placeholder(
83-
0,
84-
Some("".to_string()),
85-
)));
86-
data.push(Arc::new(new_string_array_with_placeholder(
87-
0,
88-
Some("".to_string()),
89-
)));
90-
data.push(Arc::new(new_string_array_with_placeholder(
91-
0,
92-
Some("".to_string()),
93-
)));
94-
data.push(Arc::new(new_string_array_with_placeholder(
95-
0,
96-
Some("".to_string()),
97-
)));
98-
// ORDINAL_POSITION
99-
data.push(Arc::new(new_uint32_array_with_placeholder(0, 0)));
100-
// POSITION_IN_UNIQUE_CONSTRAINT
101-
data.push(Arc::new(new_boolean_array_with_placeholder(0, false)));
102-
data.push(Arc::new(new_string_array_with_placeholder(
103-
0,
104-
Some("".to_string()),
105-
)));
106-
data.push(Arc::new(new_string_array_with_placeholder(
107-
0,
108-
Some("".to_string()),
109-
)));
110-
data.push(Arc::new(new_string_array_with_placeholder(
111-
0,
112-
Some("".to_string()),
113-
)));
69+
let data: Vec<Arc<dyn Array>> = vec![
70+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
71+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
72+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
73+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
74+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
75+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
76+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
77+
// ORDINAL_POSITION
78+
Arc::new(new_uint32_array_with_placeholder(0, 0)),
79+
// POSITION_IN_UNIQUE_CONSTRAINT
80+
Arc::new(new_boolean_array_with_placeholder(0, false)),
81+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
82+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
83+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
84+
];
11485

11586
let batch = RecordBatch::try_new(self.schema(), data)?;
11687

rust/cubesql/cubesql/src/compile/engine/information_schema/mysql/processlist.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,19 @@ impl InformationSchemaProcesslistBuilder {
6868
}
6969

7070
fn finish(mut self) -> Vec<Arc<dyn Array>> {
71-
let mut columns: Vec<Arc<dyn Array>> = vec![];
72-
columns.push(Arc::new(self.id.finish()));
73-
columns.push(Arc::new(self.user.finish()));
74-
columns.push(Arc::new(self.host.finish()));
75-
columns.push(Arc::new(self.db.finish()));
76-
columns.push(Arc::new(self.command.finish()));
77-
columns.push(Arc::new(self.time.finish()));
78-
7971
let state = self.state.finish();
8072
let total = state.len();
81-
columns.push(Arc::new(state));
8273

83-
columns.push(Arc::new(new_string_array_with_placeholder(total, None)));
74+
let columns: Vec<Arc<dyn Array>> = vec![
75+
Arc::new(self.id.finish()),
76+
Arc::new(self.user.finish()),
77+
Arc::new(self.host.finish()),
78+
Arc::new(self.db.finish()),
79+
Arc::new(self.command.finish()),
80+
Arc::new(self.time.finish()),
81+
Arc::new(state),
82+
Arc::new(new_string_array_with_placeholder(total, None)),
83+
];
8484

8585
columns
8686
}

rust/cubesql/cubesql/src/compile/engine/information_schema/mysql/referential_constraints.rs

Lines changed: 13 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -62,51 +62,19 @@ impl TableProvider for InfoSchemaReferentialConstraintsProvider {
6262
_filters: &[Expr],
6363
_limit: Option<usize>,
6464
) -> Result<Arc<dyn ExecutionPlan>, DataFusionError> {
65-
let mut data: Vec<Arc<dyn Array>> = vec![];
66-
data.push(Arc::new(new_string_array_with_placeholder(
67-
0,
68-
Some("".to_string()),
69-
)));
70-
data.push(Arc::new(new_string_array_with_placeholder(
71-
0,
72-
Some("".to_string()),
73-
)));
74-
data.push(Arc::new(new_string_array_with_placeholder(
75-
0,
76-
Some("".to_string()),
77-
)));
78-
data.push(Arc::new(new_string_array_with_placeholder(
79-
0,
80-
Some("".to_string()),
81-
)));
82-
data.push(Arc::new(new_string_array_with_placeholder(
83-
0,
84-
Some("".to_string()),
85-
)));
86-
data.push(Arc::new(new_string_array_with_placeholder(
87-
0,
88-
Some("".to_string()),
89-
)));
90-
data.push(Arc::new(new_string_array_with_placeholder(
91-
0,
92-
Some("".to_string()),
93-
)));
94-
data.push(Arc::new(new_string_array_with_placeholder(
95-
0,
96-
Some("".to_string()),
97-
)));
98-
data.push(Arc::new(new_string_array_with_placeholder(
99-
0,
100-
Some("".to_string()),
101-
)));
102-
data.push(Arc::new(new_string_array_with_placeholder(
103-
0,
104-
Some("".to_string()),
105-
)));
106-
data.push(Arc::new(new_string_array_with_placeholder(
107-
0,
108-
Some("".to_string()),
109-
)));
65+
let data: Vec<Arc<dyn Array>> = vec![
66+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
67+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
68+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
69+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
70+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
71+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
72+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
73+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
74+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
75+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
76+
Arc::new(new_string_array_with_placeholder(0, Some("".to_string()))),
77+
];
11078

11179
let batch = RecordBatch::try_new(self.schema(), data)?;
11280

rust/cubesql/cubesql/src/compile/engine/information_schema/mysql/variables.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,7 @@ impl TableProvider for PerfSchemaVariablesProvider {
6565
values.append_value(variable.value.to_string()).unwrap();
6666
}
6767

68-
let mut data: Vec<Arc<dyn Array>> = vec![];
69-
data.push(Arc::new(names.finish()));
70-
data.push(Arc::new(values.finish()));
68+
let data: Vec<Arc<dyn Array>> = vec![Arc::new(names.finish()), Arc::new(values.finish())];
7169

7270
let batch = RecordBatch::try_new(self.schema(), data)?;
7371

rust/cubesql/cubesql/src/compile/engine/information_schema/postgres/character_sets.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,16 @@ impl InfoSchemaCharacterSetsBuilder {
6969
}
7070

7171
fn finish(mut self) -> Vec<Arc<dyn Array>> {
72-
let mut columns: Vec<Arc<dyn Array>> = vec![];
73-
columns.push(Arc::new(self.character_set_catalog.finish()));
74-
columns.push(Arc::new(self.character_set_schema.finish()));
75-
columns.push(Arc::new(self.character_set_name.finish()));
76-
columns.push(Arc::new(self.character_repertoire.finish()));
77-
columns.push(Arc::new(self.form_of_use.finish()));
78-
columns.push(Arc::new(self.default_collate_catalog.finish()));
79-
columns.push(Arc::new(self.default_collate_schema.finish()));
80-
columns.push(Arc::new(self.default_collate_name.finish()));
72+
let columns: Vec<Arc<dyn Array>> = vec![
73+
Arc::new(self.character_set_catalog.finish()),
74+
Arc::new(self.character_set_schema.finish()),
75+
Arc::new(self.character_set_name.finish()),
76+
Arc::new(self.character_repertoire.finish()),
77+
Arc::new(self.form_of_use.finish()),
78+
Arc::new(self.default_collate_catalog.finish()),
79+
Arc::new(self.default_collate_schema.finish()),
80+
Arc::new(self.default_collate_name.finish()),
81+
];
8182

8283
columns
8384
}

rust/cubesql/cubesql/src/compile/engine/information_schema/postgres/constraint_column_usage.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,15 @@ impl InformationSchemaConstraintColumnUsageBuilder {
3939
}
4040

4141
fn finish(mut self) -> Vec<Arc<dyn Array>> {
42-
let mut columns: Vec<Arc<dyn Array>> = vec![];
43-
columns.push(Arc::new(self.table_catalog.finish()));
44-
columns.push(Arc::new(self.table_schema.finish()));
45-
columns.push(Arc::new(self.table_name.finish()));
46-
columns.push(Arc::new(self.column_name.finish()));
47-
columns.push(Arc::new(self.constraint_catalog.finish()));
48-
columns.push(Arc::new(self.constraint_schema.finish()));
49-
columns.push(Arc::new(self.constraint_name.finish()));
42+
let columns: Vec<Arc<dyn Array>> = vec![
43+
Arc::new(self.table_catalog.finish()),
44+
Arc::new(self.table_schema.finish()),
45+
Arc::new(self.table_name.finish()),
46+
Arc::new(self.column_name.finish()),
47+
Arc::new(self.constraint_catalog.finish()),
48+
Arc::new(self.constraint_schema.finish()),
49+
Arc::new(self.constraint_name.finish()),
50+
];
5051

5152
columns
5253
}

rust/cubesql/cubesql/src/compile/engine/information_schema/postgres/key_column_usage.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,17 @@ impl InfoSchemaKeyColumnUsageBuilder {
4343
}
4444

4545
fn finish(mut self) -> Vec<Arc<dyn Array>> {
46-
let mut columns: Vec<Arc<dyn Array>> = vec![];
47-
columns.push(Arc::new(self.constraint_catalog.finish()));
48-
columns.push(Arc::new(self.constraint_schema.finish()));
49-
columns.push(Arc::new(self.constraint_name.finish()));
50-
columns.push(Arc::new(self.table_catalog.finish()));
51-
columns.push(Arc::new(self.table_schema.finish()));
52-
columns.push(Arc::new(self.table_name.finish()));
53-
columns.push(Arc::new(self.column_name.finish()));
54-
columns.push(Arc::new(self.ordinal_position.finish()));
55-
columns.push(Arc::new(self.position_in_unique_constraint.finish()));
46+
let columns: Vec<Arc<dyn Array>> = vec![
47+
Arc::new(self.constraint_catalog.finish()),
48+
Arc::new(self.constraint_schema.finish()),
49+
Arc::new(self.constraint_name.finish()),
50+
Arc::new(self.table_catalog.finish()),
51+
Arc::new(self.table_schema.finish()),
52+
Arc::new(self.table_name.finish()),
53+
Arc::new(self.column_name.finish()),
54+
Arc::new(self.ordinal_position.finish()),
55+
Arc::new(self.position_in_unique_constraint.finish()),
56+
];
5657

5758
columns
5859
}

rust/cubesql/cubesql/src/compile/engine/information_schema/postgres/pg_am.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ impl PgCatalogAmBuilder {
3333
}
3434

3535
fn finish(mut self) -> Vec<Arc<dyn Array>> {
36-
let mut columns: Vec<Arc<dyn Array>> = vec![];
37-
columns.push(Arc::new(self.oid.finish()));
38-
columns.push(Arc::new(self.amname.finish()));
39-
columns.push(Arc::new(self.amhandler.finish()));
40-
columns.push(Arc::new(self.amtype.finish()));
36+
let columns: Vec<Arc<dyn Array>> = vec![
37+
Arc::new(self.oid.finish()),
38+
Arc::new(self.amname.finish()),
39+
Arc::new(self.amhandler.finish()),
40+
Arc::new(self.amtype.finish()),
41+
];
4142

4243
columns
4344
}

rust/cubesql/cubesql/src/compile/engine/information_schema/postgres/pg_attrdef.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ impl PgCatalogAttrdefBuilder {
3333
}
3434

3535
fn finish(mut self) -> Vec<Arc<dyn Array>> {
36-
let mut columns: Vec<Arc<dyn Array>> = vec![];
37-
columns.push(Arc::new(self.oid.finish()));
38-
columns.push(Arc::new(self.adrelid.finish()));
39-
columns.push(Arc::new(self.adnum.finish()));
40-
columns.push(Arc::new(self.adbin.finish()));
36+
let columns: Vec<Arc<dyn Array>> = vec![
37+
Arc::new(self.oid.finish()),
38+
Arc::new(self.adrelid.finish()),
39+
Arc::new(self.adnum.finish()),
40+
Arc::new(self.adbin.finish()),
41+
];
4142

4243
columns
4344
}

0 commit comments

Comments
 (0)