Skip to content

Commit 7ef62b9

Browse files
authored
chore: Enable workspace lint for all workspace members (#20577)
## Which issue does this PR close? N/A ## Rationale for this change Several workspace members did not opt into workspace-level lints. This was almost certainly an oversight. ## What changes are included in this PR? * Enable workspace-level lints for all workspace members * Fix up code to fix various linter errors This PR pulls out some of the changes made in #20250, although I didn't actually use that PR. ## Are these changes tested? Yes. ## Are there any user-facing changes? No.
1 parent c63ca33 commit 7ef62b9

File tree

12 files changed

+79
-48
lines changed

12 files changed

+79
-48
lines changed

datafusion-cli/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ rustyline = "17.0"
6969
tokio = { workspace = true, features = ["macros", "parking_lot", "rt", "rt-multi-thread", "signal", "sync"] }
7070
url = { workspace = true }
7171

72+
[lints]
73+
workspace = true
74+
7275
[dev-dependencies]
7376
ctor = { workspace = true }
7477
insta = { workspace = true }

datafusion-cli/src/functions.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ impl TableProvider for ParquetMetadataTable {
233233
self
234234
}
235235

236-
fn schema(&self) -> arrow::datatypes::SchemaRef {
236+
fn schema(&self) -> SchemaRef {
237237
self.schema.clone()
238238
}
239239

@@ -482,7 +482,7 @@ impl TableProvider for MetadataCacheTable {
482482
self
483483
}
484484

485-
fn schema(&self) -> arrow::datatypes::SchemaRef {
485+
fn schema(&self) -> SchemaRef {
486486
self.schema.clone()
487487
}
488488

@@ -600,7 +600,7 @@ impl TableProvider for StatisticsCacheTable {
600600
self
601601
}
602602

603-
fn schema(&self) -> arrow::datatypes::SchemaRef {
603+
fn schema(&self) -> SchemaRef {
604604
self.schema.clone()
605605
}
606606

@@ -735,7 +735,7 @@ impl TableProvider for ListFilesCacheTable {
735735
self
736736
}
737737

738-
fn schema(&self) -> arrow::datatypes::SchemaRef {
738+
fn schema(&self) -> SchemaRef {
739739
self.schema.clone()
740740
}
741741

datafusion-cli/src/highlighter.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ pub struct SyntaxHighlighter {
3838

3939
impl SyntaxHighlighter {
4040
pub fn new(dialect: &config::Dialect) -> Self {
41-
let dialect = dialect_from_str(dialect).unwrap_or(Box::new(GenericDialect {}));
41+
let dialect =
42+
dialect_from_str(dialect).unwrap_or_else(|| Box::new(GenericDialect {}));
4243
Self { dialect }
4344
}
4445
}

datafusion-cli/src/object_storage.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,21 @@ pub async fn get_s3_object_store_builder(
6464
url: &Url,
6565
aws_options: &AwsOptions,
6666
resolve_region: bool,
67+
) -> Result<AmazonS3Builder> {
68+
// Box the inner future to reduce the future size of this async function,
69+
// which is deeply nested in the CLI's async call chain.
70+
Box::pin(get_s3_object_store_builder_inner(
71+
url,
72+
aws_options,
73+
resolve_region,
74+
))
75+
.await
76+
}
77+
78+
async fn get_s3_object_store_builder_inner(
79+
url: &Url,
80+
aws_options: &AwsOptions,
81+
resolve_region: bool,
6782
) -> Result<AmazonS3Builder> {
6883
let AwsOptions {
6984
access_key_id,
@@ -209,7 +224,7 @@ impl CredentialsFromConfig {
209224

210225
#[derive(Debug)]
211226
struct S3CredentialProvider {
212-
credentials: aws_credential_types::provider::SharedCredentialsProvider,
227+
credentials: SharedCredentialsProvider,
213228
}
214229

215230
#[async_trait]

datafusion-cli/src/object_storage/instrumented.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub enum InstrumentedObjectStoreMode {
110110
}
111111

112112
impl fmt::Display for InstrumentedObjectStoreMode {
113-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
113+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
114114
write!(f, "{self:?}")
115115
}
116116
}
@@ -383,7 +383,7 @@ impl InstrumentedObjectStore {
383383
}
384384

385385
impl fmt::Display for InstrumentedObjectStore {
386-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
386+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
387387
let mode: InstrumentedObjectStoreMode =
388388
self.instrument_mode.load(Ordering::Relaxed).into();
389389
write!(
@@ -490,7 +490,7 @@ pub enum Operation {
490490
}
491491

492492
impl fmt::Display for Operation {
493-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
493+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
494494
write!(f, "{self:?}")
495495
}
496496
}
@@ -508,7 +508,7 @@ pub struct RequestDetails {
508508
}
509509

510510
impl fmt::Display for RequestDetails {
511-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
511+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
512512
let mut output_parts = vec![format!(
513513
"{} operation={:?}",
514514
self.timestamp.to_rfc3339(),

datafusion-cli/src/print_format.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ mod tests {
259259
fn print_csv_no_header() {
260260
let output = PrintBatchesTest::new()
261261
.with_format(PrintFormat::Csv)
262-
.with_batches(split_batch(three_column_batch()))
262+
.with_batches(split_batch(&three_column_batch()))
263263
.with_header(WithHeader::No)
264264
.run();
265265
assert_snapshot!(output, @r"
@@ -273,7 +273,7 @@ mod tests {
273273
fn print_csv_with_header() {
274274
let output = PrintBatchesTest::new()
275275
.with_format(PrintFormat::Csv)
276-
.with_batches(split_batch(three_column_batch()))
276+
.with_batches(split_batch(&three_column_batch()))
277277
.with_header(WithHeader::Yes)
278278
.run();
279279
assert_snapshot!(output, @r"
@@ -288,7 +288,7 @@ mod tests {
288288
fn print_tsv_no_header() {
289289
let output = PrintBatchesTest::new()
290290
.with_format(PrintFormat::Tsv)
291-
.with_batches(split_batch(three_column_batch()))
291+
.with_batches(split_batch(&three_column_batch()))
292292
.with_header(WithHeader::No)
293293
.run();
294294
assert_snapshot!(output, @r"
@@ -302,7 +302,7 @@ mod tests {
302302
fn print_tsv_with_header() {
303303
let output = PrintBatchesTest::new()
304304
.with_format(PrintFormat::Tsv)
305-
.with_batches(split_batch(three_column_batch()))
305+
.with_batches(split_batch(&three_column_batch()))
306306
.with_header(WithHeader::Yes)
307307
.run();
308308
assert_snapshot!(output, @r"
@@ -317,7 +317,7 @@ mod tests {
317317
fn print_table() {
318318
let output = PrintBatchesTest::new()
319319
.with_format(PrintFormat::Table)
320-
.with_batches(split_batch(three_column_batch()))
320+
.with_batches(split_batch(&three_column_batch()))
321321
.with_header(WithHeader::Ignored)
322322
.run();
323323
assert_snapshot!(output, @r"
@@ -334,7 +334,7 @@ mod tests {
334334
fn print_json() {
335335
let output = PrintBatchesTest::new()
336336
.with_format(PrintFormat::Json)
337-
.with_batches(split_batch(three_column_batch()))
337+
.with_batches(split_batch(&three_column_batch()))
338338
.with_header(WithHeader::Ignored)
339339
.run();
340340
assert_snapshot!(output, @r#"[{"a":1,"b":4,"c":7},{"a":2,"b":5,"c":8},{"a":3,"b":6,"c":9}]"#);
@@ -344,7 +344,7 @@ mod tests {
344344
fn print_ndjson() {
345345
let output = PrintBatchesTest::new()
346346
.with_format(PrintFormat::NdJson)
347-
.with_batches(split_batch(three_column_batch()))
347+
.with_batches(split_batch(&three_column_batch()))
348348
.with_header(WithHeader::Ignored)
349349
.run();
350350
assert_snapshot!(output, @r#"
@@ -358,7 +358,7 @@ mod tests {
358358
fn print_automatic_no_header() {
359359
let output = PrintBatchesTest::new()
360360
.with_format(PrintFormat::Automatic)
361-
.with_batches(split_batch(three_column_batch()))
361+
.with_batches(split_batch(&three_column_batch()))
362362
.with_header(WithHeader::No)
363363
.run();
364364
assert_snapshot!(output, @r"
@@ -371,7 +371,7 @@ mod tests {
371371
fn print_automatic_with_header() {
372372
let output = PrintBatchesTest::new()
373373
.with_format(PrintFormat::Automatic)
374-
.with_batches(split_batch(three_column_batch()))
374+
.with_batches(split_batch(&three_column_batch()))
375375
.with_header(WithHeader::Yes)
376376
.run();
377377
assert_snapshot!(output, @r"
@@ -633,7 +633,7 @@ mod tests {
633633
}
634634

635635
/// Slice the record batch into 2 batches
636-
fn split_batch(batch: RecordBatch) -> Vec<RecordBatch> {
636+
fn split_batch(batch: &RecordBatch) -> Vec<RecordBatch> {
637637
assert!(batch.num_rows() > 1);
638638
let split = batch.num_rows() / 2;
639639
vec![

datafusion-cli/src/print_options.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ impl PrintOptions {
115115
row_count: usize,
116116
format_options: &FormatOptions,
117117
) -> Result<()> {
118-
let stdout = std::io::stdout();
118+
let stdout = io::stdout();
119119
let mut writer = stdout.lock();
120120

121121
self.format.print_batches(
@@ -137,7 +137,7 @@ impl PrintOptions {
137137
query_start_time,
138138
);
139139

140-
self.write_output(&mut writer, formatted_exec_details)
140+
self.write_output(&mut writer, &formatted_exec_details)
141141
}
142142

143143
/// Print the stream to stdout using the specified format
@@ -153,7 +153,7 @@ impl PrintOptions {
153153
));
154154
};
155155

156-
let stdout = std::io::stdout();
156+
let stdout = io::stdout();
157157
let mut writer = stdout.lock();
158158

159159
let mut row_count = 0_usize;
@@ -179,13 +179,13 @@ impl PrintOptions {
179179
query_start_time,
180180
);
181181

182-
self.write_output(&mut writer, formatted_exec_details)
182+
self.write_output(&mut writer, &formatted_exec_details)
183183
}
184184

185185
fn write_output<W: io::Write>(
186186
&self,
187187
writer: &mut W,
188-
formatted_exec_details: String,
188+
formatted_exec_details: &str,
189189
) -> Result<()> {
190190
if !self.quiet {
191191
writeln!(writer, "{formatted_exec_details}")?;
@@ -237,11 +237,11 @@ mod tests {
237237

238238
let mut print_output: Vec<u8> = Vec::new();
239239
let exec_out = String::from("Formatted Exec Output");
240-
print_options.write_output(&mut print_output, exec_out.clone())?;
240+
print_options.write_output(&mut print_output, &exec_out)?;
241241
assert!(print_output.is_empty());
242242

243243
print_options.quiet = false;
244-
print_options.write_output(&mut print_output, exec_out.clone())?;
244+
print_options.write_output(&mut print_output, &exec_out)?;
245245
let out_str: String = print_output
246246
.clone()
247247
.try_into()
@@ -253,7 +253,7 @@ mod tests {
253253
print_options
254254
.instrumented_registry
255255
.set_instrument_mode(InstrumentedObjectStoreMode::Trace);
256-
print_options.write_output(&mut print_output, exec_out.clone())?;
256+
print_options.write_output(&mut print_output, &exec_out)?;
257257
let out_str: String = print_output
258258
.clone()
259259
.try_into()

datafusion-examples/examples/ffi/ffi_example_table_provider/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ datafusion = { workspace = true }
2828
datafusion-ffi = { workspace = true }
2929
ffi_module_interface = { path = "../ffi_module_interface" }
3030

31+
[lints]
32+
workspace = true
33+
3134
[lib]
3235
name = "ffi_example_table_provider"
3336
crate-type = ["cdylib", 'rlib']

datafusion-examples/examples/ffi/ffi_module_interface/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ version = "0.1.0"
2121
edition = "2024"
2222
publish = false
2323

24+
[lints]
25+
workspace = true
26+
2427
[dependencies]
2528
abi_stable = "0.11.3"
2629
datafusion-ffi = { workspace = true }

datafusion-examples/examples/ffi/ffi_module_loader/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ version = "0.1.0"
2121
edition = "2024"
2222
publish = false
2323

24+
[lints]
25+
workspace = true
26+
2427
[dependencies]
2528
abi_stable = "0.11.3"
2629
datafusion = { workspace = true }

0 commit comments

Comments
 (0)