Skip to content

Commit a728352

Browse files
committed
Fix clippy
1 parent 1a23bb6 commit a728352

Some content is hidden

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

45 files changed

+359
-424
lines changed

ballista-cli/src/command.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Command {
6767
.map_err(BallistaError::DataFusionError)
6868
}
6969
Self::DescribeTable(name) => {
70-
let df = ctx.sql(&format!("SHOW COLUMNS FROM {}", name)).await?;
70+
let df = ctx.sql(&format!("SHOW COLUMNS FROM {name}")).await?;
7171
let batches = df.collect().await?;
7272
print_options
7373
.print_batches(&batches, now)
@@ -97,10 +97,10 @@ impl Command {
9797
Self::SearchFunctions(function) => {
9898
if let Ok(func) = function.parse::<Function>() {
9999
let details = func.function_details()?;
100-
println!("{}", details);
100+
println!("{details}");
101101
Ok(())
102102
} else {
103-
let msg = format!("{} is not a supported function", function);
103+
let msg = format!("{function} is not a supported function");
104104
Err(BallistaError::NotImplemented(msg))
105105
}
106106
}

ballista-cli/src/exec.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub async fn exec_from_lines(
5151
if line.ends_with(';') {
5252
match exec_and_print(ctx, print_options, query).await {
5353
Ok(_) => {}
54-
Err(err) => println!("{:?}", err),
54+
Err(err) => println!("{err:?}"),
5555
}
5656
query = "".to_owned();
5757
} else {
@@ -68,7 +68,7 @@ pub async fn exec_from_lines(
6868
if !query.is_empty() {
6969
match exec_and_print(ctx, print_options, query).await {
7070
Ok(_) => {}
71-
Err(err) => println!("{:?}", err),
71+
Err(err) => println!("{err:?}"),
7272
}
7373
}
7474
}
@@ -110,7 +110,7 @@ pub async fn exec_from_repl(ctx: &BallistaContext, print_options: &mut PrintOpti
110110
if let Err(e) =
111111
command.execute(&mut print_options).await
112112
{
113-
eprintln!("{}", e)
113+
eprintln!("{e}")
114114
}
115115
} else {
116116
eprintln!(
@@ -124,7 +124,7 @@ pub async fn exec_from_repl(ctx: &BallistaContext, print_options: &mut PrintOpti
124124
}
125125
_ => {
126126
if let Err(e) = cmd.execute(ctx, &mut print_options).await {
127-
eprintln!("{}", e)
127+
eprintln!("{e}")
128128
}
129129
}
130130
}
@@ -136,7 +136,7 @@ pub async fn exec_from_repl(ctx: &BallistaContext, print_options: &mut PrintOpti
136136
rl.add_history_entry(line.trim_end());
137137
match exec_and_print(ctx, &print_options, line).await {
138138
Ok(_) => {}
139-
Err(err) => eprintln!("{:?}", err),
139+
Err(err) => eprintln!("{err:?}"),
140140
}
141141
}
142142
Err(ReadlineError::Interrupted) => {
@@ -148,7 +148,7 @@ pub async fn exec_from_repl(ctx: &BallistaContext, print_options: &mut PrintOpti
148148
break;
149149
}
150150
Err(err) => {
151-
eprintln!("Unknown error happened {:?}", err);
151+
eprintln!("Unknown error happened {err:?}");
152152
break;
153153
}
154154
}

ballista-cli/src/main.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ pub async fn main() -> Result<()> {
9696
let args = Args::parse();
9797

9898
if !args.quiet {
99-
println!("Ballista CLI v{}", BALLISTA_CLI_VERSION);
99+
println!("Ballista CLI v{BALLISTA_CLI_VERSION}");
100100
}
101101

102102
if let Some(ref path) = args.data_path {
@@ -166,28 +166,28 @@ fn is_valid_file(dir: &str) -> std::result::Result<(), String> {
166166
if Path::new(dir).is_file() {
167167
Ok(())
168168
} else {
169-
Err(format!("Invalid file '{}'", dir))
169+
Err(format!("Invalid file '{dir}'"))
170170
}
171171
}
172172

173173
fn is_valid_data_dir(dir: &str) -> std::result::Result<(), String> {
174174
if Path::new(dir).is_dir() {
175175
Ok(())
176176
} else {
177-
Err(format!("Invalid data directory '{}'", dir))
177+
Err(format!("Invalid data directory '{dir}'"))
178178
}
179179
}
180180

181181
fn is_valid_batch_size(size: &str) -> std::result::Result<(), String> {
182182
match size.parse::<usize>() {
183183
Ok(size) if size > 0 => Ok(()),
184-
_ => Err(format!("Invalid batch size '{}'", size)),
184+
_ => Err(format!("Invalid batch size '{size}'")),
185185
}
186186
}
187187

188188
fn is_valid_concurrent_tasks_size(size: &str) -> std::result::Result<(), String> {
189189
match size.parse::<usize>() {
190190
Ok(size) if size > 0 => Ok(()),
191-
_ => Err(format!("Invalid concurrent_tasks size '{}'", size)),
191+
_ => Err(format!("Invalid concurrent_tasks size '{size}'")),
192192
}
193193
}

ballista/client/src/context.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl BallistaContext {
9494
);
9595
let connection = create_grpc_client_connection(scheduler_url.clone())
9696
.await
97-
.map_err(|e| DataFusionError::Execution(format!("{:?}", e)))?;
97+
.map_err(|e| DataFusionError::Execution(format!("{e:?}")))?;
9898
let mut scheduler = SchedulerGrpcClient::new(connection);
9999

100100
let remote_session_id = scheduler
@@ -111,7 +111,7 @@ impl BallistaContext {
111111
optional_session_id: None,
112112
})
113113
.await
114-
.map_err(|e| DataFusionError::Execution(format!("{:?}", e)))?
114+
.map_err(|e| DataFusionError::Execution(format!("{e:?}")))?
115115
.into_inner()
116116
.session_id;
117117

@@ -170,7 +170,7 @@ impl BallistaContext {
170170
optional_session_id: None,
171171
})
172172
.await
173-
.map_err(|e| DataFusionError::Execution(format!("{:?}", e)))?
173+
.map_err(|e| DataFusionError::Execution(format!("{e:?}")))?
174174
.into_inner()
175175
.session_id;
176176

@@ -260,7 +260,7 @@ impl BallistaContext {
260260
.read_csv(path, options)
261261
.await
262262
.map_err(|e| {
263-
DataFusionError::Context(format!("Can't read CSV: {}", path), Box::new(e))
263+
DataFusionError::Context(format!("Can't read CSV: {path}"), Box::new(e))
264264
})?
265265
.into_optimized_plan()?;
266266
match plan {
@@ -430,14 +430,12 @@ impl BallistaContext {
430430
Ok(DataFrame::new(ctx.state(), plan))
431431
}
432432
_ => Err(DataFusionError::NotImplemented(format!(
433-
"Unsupported file type {:?}.",
434-
file_type
433+
"Unsupported file type {file_type:?}."
435434
))),
436435
},
437436
(true, true) => Ok(DataFrame::new(ctx.state(), plan)),
438437
(false, true) => Err(DataFusionError::Execution(format!(
439-
"Table '{:?}' already exists",
440-
name
438+
"Table '{name:?}' already exists"
441439
))),
442440
}
443441
}

ballista/core/src/client.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,15 @@ impl BallistaClient {
5656
/// Create a new BallistaClient to connect to the executor listening on the specified
5757
/// host and port
5858
pub async fn try_new(host: &str, port: u16) -> Result<Self> {
59-
let addr = format!("http://{}:{}", host, port);
59+
let addr = format!("http://{host}:{port}");
6060
debug!("BallistaClient connecting to {}", addr);
6161
let connection =
6262
create_grpc_client_connection(addr.clone())
6363
.await
6464
.map_err(|e| {
6565
BallistaError::GrpcConnectionError(format!(
66-
"Error connecting to Ballista scheduler or executor at {}: {:?}",
67-
addr, e
68-
))
66+
"Error connecting to Ballista scheduler or executor at {addr}: {e:?}"
67+
))
6968
})?;
7069
let flight_client = FlightServiceClient::new(connection);
7170
debug!("BallistaClient connected OK");
@@ -115,22 +114,22 @@ impl BallistaClient {
115114

116115
serialized_action
117116
.encode(&mut buf)
118-
.map_err(|e| BallistaError::GrpcActionError(format!("{:?}", e)))?;
117+
.map_err(|e| BallistaError::GrpcActionError(format!("{e:?}")))?;
119118

120119
let request = tonic::Request::new(Ticket { ticket: buf });
121120

122121
let mut stream = self
123122
.flight_client
124123
.do_get(request)
125124
.await
126-
.map_err(|e| BallistaError::GrpcActionError(format!("{:?}", e)))?
125+
.map_err(|e| BallistaError::GrpcActionError(format!("{e:?}")))?
127126
.into_inner();
128127

129128
// the schema should be the first message returned, else client should error
130129
match stream
131130
.message()
132131
.await
133-
.map_err(|e| BallistaError::GrpcActionError(format!("{:?}", e)))?
132+
.map_err(|e| BallistaError::GrpcActionError(format!("{e:?}")))?
134133
{
135134
Some(flight_data) => {
136135
// convert FlightData to a stream

ballista/core/src/config.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,14 @@ impl BallistaConfig {
116116
for (name, entry) in &supported_entries {
117117
if let Some(v) = settings.get(name) {
118118
// validate that we can parse the user-supplied value
119-
Self::parse_value(v.as_str(), entry._data_type.clone()).map_err(|e| BallistaError::General(format!("Failed to parse user-supplied value '{}' for configuration setting '{}': {}", name, v, e)))?;
119+
Self::parse_value(v.as_str(), entry._data_type.clone()).map_err(|e| BallistaError::General(format!("Failed to parse user-supplied value '{name}' for configuration setting '{v}': {e}")))?;
120120
} else if let Some(v) = entry.default_value.clone() {
121-
Self::parse_value(v.as_str(), entry._data_type.clone()).map_err(|e| BallistaError::General(format!("Failed to parse default value '{}' for configuration setting '{}': {}", name, v, e)))?;
121+
Self::parse_value(v.as_str(), entry._data_type.clone()).map_err(|e| BallistaError::General(format!("Failed to parse default value '{name}' for configuration setting '{v}': {e}")))?;
122122
} else if entry.default_value.is_none() {
123123
// optional config
124124
} else {
125125
return Err(BallistaError::General(format!(
126-
"No value specified for mandatory configuration setting '{}'",
127-
name
126+
"No value specified for mandatory configuration setting '{name}'"
128127
)));
129128
}
130129
}
@@ -137,18 +136,18 @@ impl BallistaConfig {
137136
DataType::UInt16 => {
138137
val.to_string()
139138
.parse::<usize>()
140-
.map_err(|e| format!("{:?}", e))?;
139+
.map_err(|e| format!("{e:?}"))?;
141140
}
142141
DataType::Boolean => {
143142
val.to_string()
144143
.parse::<bool>()
145-
.map_err(|e| format!("{:?}", e))?;
144+
.map_err(|e| format!("{e:?}"))?;
146145
}
147146
DataType::Utf8 => {
148147
val.to_string();
149148
}
150149
_ => {
151-
return Err(format!("not support data type: {}", data_type));
150+
return Err(format!("not support data type: {data_type}"));
152151
}
153152
}
154153

ballista/core/src/error.rs

+17-18
Original file line numberDiff line numberDiff line change
@@ -180,15 +180,15 @@ impl Display for BallistaError {
180180
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
181181
match self {
182182
BallistaError::NotImplemented(ref desc) => {
183-
write!(f, "Not implemented: {}", desc)
183+
write!(f, "Not implemented: {desc}")
184184
}
185-
BallistaError::General(ref desc) => write!(f, "General error: {}", desc),
186-
BallistaError::ArrowError(ref desc) => write!(f, "Arrow error: {}", desc),
185+
BallistaError::General(ref desc) => write!(f, "General error: {desc}"),
186+
BallistaError::ArrowError(ref desc) => write!(f, "Arrow error: {desc}"),
187187
BallistaError::DataFusionError(ref desc) => {
188-
write!(f, "DataFusion error: {:?}", desc)
188+
write!(f, "DataFusion error: {desc:?}")
189189
}
190-
BallistaError::SqlError(ref desc) => write!(f, "SQL error: {:?}", desc),
191-
BallistaError::IoError(ref desc) => write!(f, "IO error: {}", desc),
190+
BallistaError::SqlError(ref desc) => write!(f, "SQL error: {desc:?}"),
191+
BallistaError::IoError(ref desc) => write!(f, "IO error: {desc}"),
192192
// BallistaError::ReqwestError(ref desc) => write!(f, "Reqwest error: {}", desc),
193193
// BallistaError::HttpError(ref desc) => write!(f, "HTTP error: {}", desc),
194194
// BallistaError::KubeAPIError(ref desc) => write!(f, "Kube API error: {}", desc),
@@ -198,24 +198,23 @@ impl Display for BallistaError {
198198
// BallistaError::KubeAPIResponseError(ref desc) => {
199199
// write!(f, "KubeAPI response error: {}", desc)
200200
// }
201-
BallistaError::TonicError(desc) => write!(f, "Tonic error: {}", desc),
202-
BallistaError::GrpcError(desc) => write!(f, "Grpc error: {}", desc),
201+
BallistaError::TonicError(desc) => write!(f, "Tonic error: {desc}"),
202+
BallistaError::GrpcError(desc) => write!(f, "Grpc error: {desc}"),
203203
BallistaError::GrpcConnectionError(desc) => {
204-
write!(f, "Grpc connection error: {}", desc)
204+
write!(f, "Grpc connection error: {desc}")
205205
}
206206
BallistaError::Internal(desc) => {
207-
write!(f, "Internal Ballista error: {}", desc)
207+
write!(f, "Internal Ballista error: {desc}")
208208
}
209-
BallistaError::TokioError(desc) => write!(f, "Tokio join error: {}", desc),
209+
BallistaError::TokioError(desc) => write!(f, "Tokio join error: {desc}"),
210210
BallistaError::GrpcActionError(desc) => {
211-
write!(f, "Grpc Execute Action error: {}", desc)
211+
write!(f, "Grpc Execute Action error: {desc}")
212212
}
213213
BallistaError::FetchFailed(executor_id, map_stage, map_partition, desc) => {
214214
write!(
215215
f,
216-
"Shuffle fetch partition error from Executor {}, map_stage {}, \
217-
map_partition {}, error desc: {}",
218-
executor_id, map_stage, map_partition, desc
216+
"Shuffle fetch partition error from Executor {executor_id}, map_stage {map_stage}, \
217+
map_partition {map_partition}, error desc: {desc}"
219218
)
220219
}
221220
BallistaError::Cancelled => write!(f, "Task cancelled"),
@@ -248,7 +247,7 @@ impl From<BallistaError> for FailedTask {
248247
}
249248
BallistaError::IoError(io) => {
250249
FailedTask {
251-
error: format!("Task failed due to Ballista IO error: {:?}", io),
250+
error: format!("Task failed due to Ballista IO error: {io:?}"),
252251
// IO error is considered to be temporary and retryable
253252
retryable: true,
254253
count_to_failures: true,
@@ -257,15 +256,15 @@ impl From<BallistaError> for FailedTask {
257256
}
258257
BallistaError::DataFusionError(DataFusionError::IoError(io)) => {
259258
FailedTask {
260-
error: format!("Task failed due to DataFusion IO error: {:?}", io),
259+
error: format!("Task failed due to DataFusion IO error: {io:?}"),
261260
// IO error is considered to be temporary and retryable
262261
retryable: true,
263262
count_to_failures: true,
264263
failed_reason: Some(FailedReason::IoError(IoError {})),
265264
}
266265
}
267266
other => FailedTask {
268-
error: format!("Task failed due to runtime execution error: {:?}", other),
267+
error: format!("Task failed due to runtime execution error: {other:?}"),
269268
retryable: false,
270269
count_to_failures: false,
271270
failed_reason: Some(FailedReason::ExecutionError(ExecutionError {})),

ballista/core/src/event_loop.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ impl<E> EventSender<E> {
134134
}
135135

136136
pub async fn post_event(&self, event: E) -> Result<()> {
137-
self.tx_event.send(event).await.map_err(|e| {
138-
BallistaError::General(format!("Fail to send event due to {}", e))
139-
})
137+
self.tx_event
138+
.send(event)
139+
.await
140+
.map_err(|e| BallistaError::General(format!("Fail to send event due to {e}")))
140141
}
141142
}

0 commit comments

Comments
 (0)