Skip to content

Commit 4a38020

Browse files
committed
lint fix
1 parent 2a2cc92 commit 4a38020

File tree

10 files changed

+59
-72
lines changed

10 files changed

+59
-72
lines changed

crates/configuration/src/version1.rs

+8-12
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub struct HasuraRegionName(pub String);
127127
impl std::fmt::Display for HasuraRegionName {
128128
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
129129
let HasuraRegionName(region) = self;
130-
write!(f, "{}", region)
130+
write!(f, "{region}")
131131
}
132132
}
133133

@@ -139,7 +139,7 @@ pub struct RegionName(pub String);
139139
impl std::fmt::Display for RegionName {
140140
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
141141
let RegionName(region) = self;
142-
write!(f, "{}", region)
142+
write!(f, "{region}")
143143
}
144144
}
145145

@@ -362,7 +362,7 @@ pub async fn configure(
362362
let project_id = project_id_.as_str();
363363
let dataset_id = dataset_id_.as_str();
364364

365-
let schema_name = format!("{}.{}", project_id, dataset_id);
365+
let schema_name = format!("{project_id}.{dataset_id}");
366366
let database_name = schema_name.clone();
367367

368368
// Init BigQuery client
@@ -374,8 +374,7 @@ pub async fn configure(
374374
// get scalar_types
375375

376376
let types_query = format!(
377-
"select data_type from {}.{}.INFORMATION_SCHEMA.COLUMN_FIELD_PATHS",
378-
project_id, dataset_id
377+
"select data_type from {project_id}.{dataset_id}.INFORMATION_SCHEMA.COLUMN_FIELD_PATHS"
379378
);
380379

381380
let types_row = bigquery_client
@@ -391,13 +390,13 @@ pub async fn configure(
391390
.rows
392391
.as_ref()
393392
.unwrap()
394-
.into_iter()
393+
.iter()
395394
.map(|row| TypeItem {
396395
name: serde_json::from_value(
397396
row.columns
398397
.as_ref()
399398
.unwrap()
400-
.into_iter()
399+
.iter()
401400
.next()
402401
.unwrap()
403402
.value
@@ -439,13 +438,10 @@ pub async fn configure(
439438
// tables_info.merge(table_info_map);
440439
Ok(table_info_map)
441440
} else {
442-
Err(format!(
443-
"Failed to deserialize TablesInfo from JSON: {}",
444-
str
445-
))
441+
Err(format!("Failed to deserialize TablesInfo from JSON: {str}"))
446442
}
447443
} else {
448-
Err(format!("Expected a string value, found: {:?}", value))
444+
Err(format!("Expected a string value, found: {value:?}"))
449445
}
450446
} else {
451447
Err("Missing value in columns".to_string())

crates/connectors/ndc-bigquery/src/connector.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ impl<Env: Environment + Send + Sync> ConnectorSetup for BigQuerySetup<Env> {
241241
.instrument(info_span!("Initialise state"))
242242
.await
243243
.map(Arc::new)
244-
.map_err(|err| connector::ErrorResponse::from_error(err))
244+
.map_err(connector::ErrorResponse::from_error)
245245
.map_err(|err| {
246246
tracing::error!(
247247
meta.signal_type = "log",

crates/query-engine/execution/src/metrics.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ impl Metrics {
8686
pool_max_connections,
8787
pool_min_connections,
8888
pool_acquire_timeout,
89-
pool_idle_timeout,
9089
pool_max_lifetime,
90+
pool_idle_timeout,
9191
error_metrics,
9292
})
9393
}
9494

9595
pub fn record_successful_query(&self) {
96-
self.query_total.inc()
96+
self.query_total.inc();
9797
}
9898

9999
pub fn record_successful_explain(&self) {
100-
self.explain_total.inc()
100+
self.explain_total.inc();
101101
}
102102

103103
pub fn time_query_plan(&self) -> Timer {

crates/query-engine/execution/src/query.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use query_engine_sql::sql;
1414
pub async fn execute(
1515
bigquery_client: &gcp_bigquery_client::Client,
1616
_metrics: &metrics::Metrics,
17-
project_id: &String,
17+
project_id: &str,
1818
plan: sql::execution_plan::ExecutionPlan<sql::execution_plan::Query>,
1919
) -> Result<Bytes, Error> {
2020
let mut buffer = BytesMut::new();
@@ -67,26 +67,21 @@ pub async fn execute(
6767
// Query
6868
let mut rs = bigquery_client
6969
.job()
70-
.query(project_id.as_str(), query_request)
70+
.query(project_id, query_request)
7171
.await
7272
.unwrap();
7373

7474
while rs.next_row() {
7575
dbg!("result set of row: ", &rs);
7676
let this_row = rs.get_string(0).unwrap().unwrap(); // we should only have one row called 'universe'
7777
dbg!("this row: ", &this_row);
78-
let foo: Value = serde_json::from_str(&this_row).unwrap();
79-
dbg!("foo: ", &foo);
80-
let bar = Value::Array(vec![foo]);
81-
dbg!("bar: ", &bar);
82-
let baz = to_string(&bar).unwrap();
83-
dbg!("baz: ", &baz);
84-
// let bar: u8 = this_row.as_bytes()[0];
85-
// dbg!("bar: ", &bar);
86-
// let foo = vec![this_row];
87-
// let json_value = serde_json::from_str(&this_row).unwrap();
88-
let b: Bytes = Bytes::from(baz);
89-
// let b: Bytes = Bytes::from(to_string(&foo).unwrap());
78+
let row_value: Value = serde_json::from_str(&this_row).unwrap();
79+
dbg!("row_value: ", &row_value);
80+
let row_value_array = Value::Array(vec![row_value]);
81+
dbg!("row_value_array: ", &row_value_array);
82+
let final_row = to_string(&row_value_array).unwrap();
83+
dbg!("final_row: ", &final_row);
84+
let b: Bytes = Bytes::from(final_row);
9085
dbg!("b: ", &b);
9186
buffer.put(b);
9287
// let this_row = rs.get_json_value(0).unwrap(); // we should only have one row called 'universe'

crates/query-engine/sql/src/sql/convert.rs

+18-18
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ impl With {
1616
for (index, cte) in ctes.iter().enumerate() {
1717
cte.to_sql(sql);
1818
if index < (ctes.len() - 1) {
19-
sql.append_syntax(", ")
19+
sql.append_syntax(", ");
2020
}
2121
}
2222
}
@@ -88,7 +88,7 @@ impl SelectList {
8888
sql.append_syntax(" AS ");
8989
col.to_sql(sql);
9090
if index < (select_list.len() - 1) {
91-
sql.append_syntax(", ")
91+
sql.append_syntax(", ");
9292
}
9393
}
9494
}
@@ -131,8 +131,8 @@ impl Select {
131131
None => (),
132132
}
133133

134-
for join in self.joins.iter() {
135-
join.to_sql(sql)
134+
for join in &self.joins {
135+
join.to_sql(sql);
136136
}
137137

138138
self.where_.to_sql(sql);
@@ -442,7 +442,7 @@ impl Expression {
442442
for (index, item) in right.iter().enumerate() {
443443
item.to_sql(sql);
444444
if index < (right.len() - 1) {
445-
sql.append_syntax(", ")
445+
sql.append_syntax(", ");
446446
}
447447
}
448448
sql.append_syntax(")");
@@ -464,7 +464,7 @@ impl Expression {
464464
for (index, arg) in args.iter().enumerate() {
465465
arg.to_sql(sql);
466466
if index < (args.len() - 1) {
467-
sql.append_syntax(", ")
467+
sql.append_syntax(", ");
468468
}
469469
}
470470
sql.append_syntax(")");
@@ -473,7 +473,7 @@ impl Expression {
473473
for (index, expression) in expressions.iter().enumerate() {
474474
expression.to_sql(sql);
475475
if index < (expressions.len() - 1) {
476-
sql.append_syntax("")
476+
sql.append_syntax("");
477477
}
478478
}
479479
}
@@ -498,7 +498,7 @@ impl Expression {
498498
item.to_sql(sql);
499499

500500
if index < (map.len() - 1) {
501-
sql.append_syntax(", ")
501+
sql.append_syntax(", ");
502502
}
503503
}
504504

@@ -514,7 +514,7 @@ impl Expression {
514514
sql.append_syntax("COUNT");
515515
sql.append_syntax("(");
516516
count_type.to_sql(sql);
517-
sql.append_syntax(")")
517+
sql.append_syntax(")");
518518
}
519519
Expression::ArrayConstructor(elements) => {
520520
sql.append_syntax("ARRAY[");
@@ -615,7 +615,7 @@ impl Function {
615615
Function::Unnest => sql.append_syntax("unnest"),
616616
Function::Unknown(name) => sql.append_syntax(name),
617617
Function::SafeOffSet(index) => {
618-
sql.append_syntax(format!("[SAFE_OFFSET({index})]").as_str())
618+
sql.append_syntax(format!("[SAFE_OFFSET({index})]").as_str());
619619
}
620620
}
621621
}
@@ -628,7 +628,7 @@ impl CountType {
628628
CountType::Simple(column) => column.to_sql(sql),
629629
CountType::Distinct(column) => {
630630
sql.append_syntax("DISTINCT ");
631-
column.to_sql(sql)
631+
column.to_sql(sql);
632632
}
633633
}
634634
}
@@ -638,8 +638,8 @@ impl Value {
638638
pub fn to_sql(&self, sql: &mut SQL) {
639639
match &self {
640640
Value::EmptyJsonArray => sql.append_syntax("'[]'"),
641-
Value::Int8(i) => sql.append_syntax(format!("{}", i).as_str()),
642-
Value::Float8(n) => sql.append_syntax(format!("{}", n).as_str()),
641+
Value::Int8(i) => sql.append_syntax(format!("{i}").as_str()),
642+
Value::Float8(n) => sql.append_syntax(format!("{n}").as_str()),
643643
Value::Character(s) => sql.append_param(Param::String(s.clone())),
644644
Value::String(s) => sql.append_param(Param::String(s.clone())),
645645
Value::Variable(v) => sql.append_param(Param::Variable(v.clone())),
@@ -652,7 +652,7 @@ impl Value {
652652
for (index, item) in items.iter().enumerate() {
653653
item.to_sql(sql);
654654
if index < (items.len() - 1) {
655-
sql.append_syntax(", ")
655+
sql.append_syntax(", ");
656656
}
657657
}
658658
sql.append_syntax("]");
@@ -708,14 +708,14 @@ impl Limit {
708708
None => (),
709709
Some(limit) => {
710710
sql.append_syntax(" LIMIT ");
711-
sql.append_syntax(format!("{}", limit).as_str());
711+
sql.append_syntax(format!("{limit}").as_str());
712712
}
713713
};
714714
match self.offset {
715715
None => (),
716716
Some(offset) => {
717717
sql.append_syntax(" OFFSET ");
718-
sql.append_syntax(format!("{}", offset).as_str());
718+
sql.append_syntax(format!("{offset}").as_str());
719719
}
720720
};
721721
}
@@ -796,7 +796,7 @@ impl OrderBy {
796796
for (index, order_by_item) in self.elements.iter().enumerate() {
797797
order_by_item.to_sql(sql);
798798
if index < (self.elements.len() - 1) {
799-
sql.append_syntax(", ")
799+
sql.append_syntax(", ");
800800
}
801801
}
802802
}
@@ -806,7 +806,7 @@ impl OrderBy {
806806
impl OrderByElement {
807807
pub fn to_sql(&self, sql: &mut SQL) {
808808
self.target.to_sql(sql);
809-
self.direction.to_sql(sql)
809+
self.direction.to_sql(sql);
810810
}
811811
}
812812

crates/query-engine/sql/src/sql/helpers.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ pub fn select_rowset(
258258
select_set: SelectSet,
259259
returns_field: ReturnsFields,
260260
) -> Select {
261-
dbg!(output_table_alias.clone());
261+
dbg!(output_table_alias);
262262
dbg!(output_column_alias.clone());
263263
dbg!(row_table_alias.clone());
264264
match select_set {
@@ -294,7 +294,7 @@ pub fn select_rowset(
294294
match returns_field {
295295
ReturnsFields::FieldsWereRequested => {
296296
let star_select = star_select(From::Select {
297-
alias: row_inner_table_alias_.clone(),
297+
alias: row_inner_table_alias_,
298298
select: Box::new(row_select),
299299
});
300300
final_select.from = Some(From::Select {
@@ -385,7 +385,7 @@ pub fn select_rowset(
385385
let mut final_select = simple_select(row);
386386

387387
let select_star = star_select(From::Select {
388-
alias: row_inner_table_alias_.clone(),
388+
alias: row_inner_table_alias_,
389389
select: Box::new(row_select),
390390
});
391391

crates/query-engine/sql/src/sql/rewrites/constant_folding.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ pub fn normalize_expr(expr: Expression) -> Expression {
260260
Expression::JoinExpressions(expressions) => {
261261
Expression::JoinExpressions(expressions.into_iter().map(normalize_expr).collect())
262262
}
263-
Expression::SafeOffSet { offset } => Expression::SafeOffSet { offset: offset },
263+
Expression::SafeOffSet { offset } => Expression::SafeOffSet { offset },
264264
}
265265
}
266266

crates/query-engine/sql/src/sql/string.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub struct Statement(pub SQL);
3535
impl SQL {
3636
pub fn new() -> SQL {
3737
SQL {
38-
sql: "".to_string(),
38+
sql: String::new(),
3939
params: vec![],
4040
}
4141
}
@@ -47,7 +47,7 @@ impl SQL {
4747
/// inserted surrounded by quotes
4848
pub fn append_identifier(&mut self, sql: &String) {
4949
// todo: sanitize
50-
self.sql.push_str(format!("{}", sql).as_str());
50+
self.sql.push_str(sql.to_string().as_str());
5151
}
5252
/// Append a parameter to a parameterized query. Will be represented as $1, $2, and so on,
5353
/// in the sql query text, and will be inserted to the `params` vector, so we can

crates/query-engine/translation/src/translation/query/root.rs

+11-14
Original file line numberDiff line numberDiff line change
@@ -137,20 +137,18 @@ fn translate_rows_select(
137137
};
138138

139139
let mut fields_select = match returns_fields {
140-
ReturnsFields::FieldsWereRequested => {
141-
let fields_select = fields::translate_fields(
142-
env,
143-
state,
144-
fields,
145-
&current_table,
146-
from_clause,
147-
&mut join_relationship_fields,
148-
)?;
149-
fields_select
150-
}
140+
ReturnsFields::FieldsWereRequested => fields::translate_fields(
141+
env,
142+
state,
143+
fields,
144+
&current_table,
145+
from_clause,
146+
&mut join_relationship_fields,
147+
)?,
151148
ReturnsFields::NoFieldsWereRequested => {
152149
let select_1 = sql::ast::SelectList::Select1;
153-
let select = sql::ast::Select {
150+
151+
sql::ast::Select {
154152
with: sql::helpers::empty_with(),
155153
select_list: select_1,
156154
from: Some(from_clause),
@@ -159,8 +157,7 @@ fn translate_rows_select(
159157
group_by: sql::helpers::empty_group_by(),
160158
order_by: sql::helpers::empty_order_by(),
161159
limit: sql::helpers::empty_limit(),
162-
};
163-
select
160+
}
164161
}
165162
};
166163

0 commit comments

Comments
 (0)