Skip to content

Apache DataFusion SQL Query Engine

chore: Enable workspace lint for all workspace members (#20577)

Neil Conway7ef62b988d19
diff --git a/datafusion-cli/Cargo.toml b/datafusion-cli/Cargo.toml
index 56bfbb693e..3fe6be964c 100644
--- a/datafusion-cli/Cargo.toml
+++ b/datafusion-cli/Cargo.toml
@@ -69,6 +69,9 @@ rustyline = "17.0"
tokio = { workspace = true, features = ["macros", "parking_lot", "rt", "rt-multi-thread", "signal", "sync"] }
url = { workspace = true }
+[lints]
+workspace = true
+
[dev-dependencies]
ctor = { workspace = true }
insta = { workspace = true }
diff --git a/datafusion-cli/src/functions.rs b/datafusion-cli/src/functions.rs
index cef057545c..67f3dc2826 100644
--- a/datafusion-cli/src/functions.rs
+++ b/datafusion-cli/src/functions.rs
@@ -233,7 +233,7 @@ impl TableProvider for ParquetMetadataTable {
self
}
- fn schema(&self) -> arrow::datatypes::SchemaRef {
+ fn schema(&self) -> SchemaRef {
self.schema.clone()
}
@@ -482,7 +482,7 @@ impl TableProvider for MetadataCacheTable {
self
}
- fn schema(&self) -> arrow::datatypes::SchemaRef {
+ fn schema(&self) -> SchemaRef {
self.schema.clone()
}
@@ -600,7 +600,7 @@ impl TableProvider for StatisticsCacheTable {
self
}
- fn schema(&self) -> arrow::datatypes::SchemaRef {
+ fn schema(&self) -> SchemaRef {
self.schema.clone()
}
@@ -735,7 +735,7 @@ impl TableProvider for ListFilesCacheTable {
self
}
- fn schema(&self) -> arrow::datatypes::SchemaRef {
+ fn schema(&self) -> SchemaRef {
self.schema.clone()
}
diff --git a/datafusion-cli/src/highlighter.rs b/datafusion-cli/src/highlighter.rs
index 0a2a2e6c14..adcb135bb4 100644
--- a/datafusion-cli/src/highlighter.rs
+++ b/datafusion-cli/src/highlighter.rs
@@ -38,7 +38,8 @@ pub struct SyntaxHighlighter {
impl SyntaxHighlighter {
pub fn new(dialect: &config::Dialect) -> Self {
- let dialect = dialect_from_str(dialect).unwrap_or(Box::new(GenericDialect {}));
+ let dialect =
+ dialect_from_str(dialect).unwrap_or_else(|| Box::new(GenericDialect {}));
Self { dialect }
}
}
diff --git a/datafusion-cli/src/object_storage.rs b/datafusion-cli/src/object_storage.rs
index 1343d142b7..3478783892 100644
--- a/datafusion-cli/src/object_storage.rs
+++ b/datafusion-cli/src/object_storage.rs
@@ -64,6 +64,21 @@ pub async fn get_s3_object_store_builder(
url: &Url,
aws_options: &AwsOptions,
resolve_region: bool,
+) -> Result<AmazonS3Builder> {
+ // Box the inner future to reduce the future size of this async function,
+ // which is deeply nested in the CLI's async call chain.
+ Box::pin(get_s3_object_store_builder_inner(
+ url,
+ aws_options,
+ resolve_region,
+ ))
+ .await
+}
+
+async fn get_s3_object_store_builder_inner(
+ url: &Url,
+ aws_options: &AwsOptions,
+ resolve_region: bool,
) -> Result<AmazonS3Builder> {
let AwsOptions {
access_key_id,
@@ -209,7 +224,7 @@ impl CredentialsFromConfig {
#[derive(Debug)]
struct S3CredentialProvider {
- credentials: aws_credential_types::provider::SharedCredentialsProvider,
+ credentials: SharedCredentialsProvider,
}
#[async_trait]
diff --git a/datafusion-cli/src/object_storage/instrumented.rs b/datafusion-cli/src/object_storage/instrumented.rs
index 0d5e9dc2c5..9c603619a9 100644
--- a/datafusion-cli/src/object_storage/instrumented.rs
+++ b/datafusion-cli/src/object_storage/instrumented.rs
@@ -110,7 +110,7 @@ pub enum InstrumentedObjectStoreMode {
}
impl fmt::Display for InstrumentedObjectStoreMode {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{self:?}")
}
}
@@ -383,7 +383,7 @@ impl InstrumentedObjectStore {
}
impl fmt::Display for InstrumentedObjectStore {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mode: InstrumentedObjectStoreMode =
self.instrument_mode.load(Ordering::Relaxed).into();
write!(
@@ -490,7 +490,7 @@ pub enum Operation {
}
impl fmt::Display for Operation {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{self:?}")
}
}
@@ -508,7 +508,7 @@ pub struct RequestDetails {
}
impl fmt::Display for RequestDetails {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut output_parts = vec![format!(
"{} operation={:?}",
self.timestamp.to_rfc3339(),
diff --git a/datafusion-cli/src/print_format.rs b/datafusion-cli/src/print_format.rs
index cfb8a32ffc..6a6a0370b0 100644
--- a/datafusion-cli/src/print_format.rs
+++ b/datafusion-cli/src/print_format.rs
@@ -259,7 +259,7 @@ mod tests {
fn print_csv_no_header() {
let output = PrintBatchesTest::new()
.with_format(PrintFormat::Csv)
- .with_batches(split_batch(three_column_batch()))
+ .with_batches(split_batch(&three_column_batch()))
.with_header(WithHeader::No)
.run();
assert_snapshot!(output, @r"
@@ -273,7 +273,7 @@ mod tests {
fn print_csv_with_header() {
let output = PrintBatchesTest::new()
.with_format(PrintFormat::Csv)
- .with_batches(split_batch(three_column_batch()))
+ .with_batches(split_batch(&three_column_batch()))
.with_header(WithHeader::Yes)
.run();
assert_snapshot!(output, @r"
@@ -288,7 +288,7 @@ mod tests {
fn print_tsv_no_header() {
let output = PrintBatchesTest::new()
.with_format(PrintFormat::Tsv)
- .with_batches(split_batch(three_column_batch()))
+ .with_batches(split_batch(&three_column_batch()))
.with_header(WithHeader::No)
.run();
assert_snapshot!(output, @r"
@@ -302,7 +302,7 @@ mod tests {
fn print_tsv_with_header() {
let output = PrintBatchesTest::new()
.with_format(PrintFormat::Tsv)
- .with_batches(split_batch(three_column_batch()))
+ .with_batches(split_batch(&three_column_batch()))
.with_header(WithHeader::Yes)
.run();
assert_snapshot!(output, @r"
@@ -317,7 +317,7 @@ mod tests {
fn print_table() {
let output = PrintBatchesTest::new()
.with_format(PrintFormat::Table)
- .with_batches(split_batch(three_column_batch()))
+ .with_batches(split_batch(&three_column_batch()))
.with_header(WithHeader::Ignored)
.run();
assert_snapshot!(output, @r"
@@ -334,7 +334,7 @@ mod tests {
fn print_json() {
let output = PrintBatchesTest::new()
.with_format(PrintFormat::Json)
- .with_batches(split_batch(three_column_batch()))
+ .with_batches(split_batch(&three_column_batch()))
.with_header(WithHeader::Ignored)
.run();
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 {
fn print_ndjson() {
let output = PrintBatchesTest::new()
.with_format(PrintFormat::NdJson)
- .with_batches(split_batch(three_column_batch()))
+ .with_batches(split_batch(&three_column_batch()))
.with_header(WithHeader::Ignored)
.run();
assert_snapshot!(output, @r#"
@@ -358,7 +358,7 @@ mod tests {
fn print_automatic_no_header() {
let output = PrintBatchesTest::new()
.with_format(PrintFormat::Automatic)
- .with_batches(split_batch(three_column_batch()))
+ .with_batches(split_batch(&three_column_batch()))
.with_header(WithHeader::No)
.run();
assert_snapshot!(output, @r"
@@ -371,7 +371,7 @@ mod tests {
fn print_automatic_with_header() {
let output = PrintBatchesTest::new()
.with_format(PrintFormat::Automatic)
- .with_batches(split_batch(three_column_batch()))
+ .with_batches(split_batch(&three_column_batch()))
.with_header(WithHeader::Yes)
.run();
assert_snapshot!(output, @r"
@@ -633,7 +633,7 @@ mod tests {
}
/// Slice the record batch into 2 batches
- fn split_batch(batch: RecordBatch) -> Vec<RecordBatch> {
+ fn split_batch(batch: &RecordBatch) -> Vec<RecordBatch> {
assert!(batch.num_rows() > 1);
let split = batch.num_rows() / 2;
vec![
diff --git a/datafusion-cli/src/print_options.rs b/datafusion-cli/src/print_options.rs
index 5fbe27d805..d0810cb034 100644
--- a/datafusion-cli/src/print_options.rs
+++ b/datafusion-cli/src/print_options.rs
@@ -115,7 +115,7 @@ impl PrintOptions {
row_count: usize,
format_options: &FormatOptions,
) -> Result<()> {
- let stdout = std::io::stdout();
+ let stdout = io::stdout();
let mut writer = stdout.lock();
self.format.print_batches(
@@ -137,7 +137,7 @@ impl PrintOptions {
query_start_time,
);
- self.write_output(&mut writer, formatted_exec_details)
+ self.write_output(&mut writer, &formatted_exec_details)
}
/// Print the stream to stdout using the specified format
@@ -153,7 +153,7 @@ impl PrintOptions {
));
};
- let stdout = std::io::stdout();
+ let stdout = io::stdout();
let mut writer = stdout.lock();
let mut row_count = 0_usize;
@@ -179,13 +179,13 @@ impl PrintOptions {
query_start_time,
);
- self.write_output(&mut writer, formatted_exec_details)
+ self.write_output(&mut writer, &formatted_exec_details)
}
fn write_output<W: io::Write>(
&self,
writer: &mut W,
- formatted_exec_details: String,
+ formatted_exec_details: &str,
) -> Result<()> {
if !self.quiet {
writeln!(writer, "{formatted_exec_details}")?;
@@ -237,11 +237,11 @@ mod tests {
let mut print_output: Vec<u8> = Vec::new();
let exec_out = String::from("Formatted Exec Output");
- print_options.write_output(&mut print_output, exec_out.clone())?;
+ print_options.write_output(&mut print_output, &exec_out)?;
assert!(print_output.is_empty());
print_options.quiet = false;
- print_options.write_output(&mut print_output, exec_out.clone())?;
+ print_options.write_output(&mut print_output, &exec_out)?;
let out_str: String = print_output
.clone()
.try_into()
@@ -253,7 +253,7 @@ mod tests {
print_options
.instrumented_registry
.set_instrument_mode(InstrumentedObjectStoreMode::Trace);
- print_options.write_output(&mut print_output, exec_out.clone())?;
+ print_options.write_output(&mut print_output, &exec_out)?;
let out_str: String = print_output
.clone()
.try_into()
diff --git a/datafusion-examples/examples/ffi/ffi_example_table_provider/Cargo.toml b/datafusion-examples/examples/ffi/ffi_example_table_provider/Cargo.toml
index e9c0c5b43d..e2d0e3fa67 100644
--- a/datafusion-examples/examples/ffi/ffi_example_table_provider/Cargo.toml
+++ b/datafusion-examples/examples/ffi/ffi_example_table_provider/Cargo.toml
@@ -28,6 +28,9 @@ datafusion = { workspace = true }
datafusion-ffi = { workspace = true }
ffi_module_interface = { path = "../ffi_module_interface" }
+[lints]
+workspace = true
+
[lib]
name = "ffi_example_table_provider"
crate-type = ["cdylib", 'rlib']
diff --git a/datafusion-examples/examples/ffi/ffi_module_interface/Cargo.toml b/datafusion-examples/examples/ffi/ffi_module_interface/Cargo.toml
index f393b2971e..fe49027112 100644
--- a/datafusion-examples/examples/ffi/ffi_module_interface/Cargo.toml
+++ b/datafusion-examples/examples/ffi/ffi_module_interface/Cargo.toml
@@ -21,6 +21,9 @@ version = "0.1.0"
edition = "2024"
publish = false
+[lints]
+workspace = true
+
[dependencies]
abi_stable = "0.11.3"
datafusion-ffi = { workspace = true }
diff --git a/datafusion-examples/examples/ffi/ffi_module_loader/Cargo.toml b/datafusion-examples/examples/ffi/ffi_module_loader/Cargo.toml
index 823c9afdde..8d7434dca2 100644
--- a/datafusion-examples/examples/ffi/ffi_module_loader/Cargo.toml
+++ b/datafusion-examples/examples/ffi/ffi_module_loader/Cargo.toml
@@ -21,6 +21,9 @@ version = "0.1.0"
edition = "2024"
publish = false
+[lints]
+workspace = true
+
[dependencies]
abi_stable = "0.11.3"
datafusion = { workspace = true }
diff --git a/datafusion/physical-expr-adapter/Cargo.toml b/datafusion/physical-expr-adapter/Cargo.toml
index 03e1b1f065..453c8bdaac 100644
--- a/datafusion/physical-expr-adapter/Cargo.toml
+++ b/datafusion/physical-expr-adapter/Cargo.toml
@@ -24,4 +24,7 @@ datafusion-physical-expr = { workspace = true }
datafusion-physical-expr-common = { workspace = true }
itertools = { workspace = true }
+[lints]
+workspace = true
+
[dev-dependencies]
diff --git a/datafusion/physical-expr-adapter/src/schema_rewriter.rs b/datafusion/physical-expr-adapter/src/schema_rewriter.rs
index 6a4a01c8e8..ec5f9139ed 100644
--- a/datafusion/physical-expr-adapter/src/schema_rewriter.rs
+++ b/datafusion/physical-expr-adapter/src/schema_rewriter.rs
@@ -548,7 +548,7 @@ impl DefaultPhysicalExprAdapterRewriter {
/// let factory = BatchAdapterFactory::new(Arc::clone(&target_schema));
///
/// // Create adapter for this specific source schema
-/// let adapter = factory.make_adapter(Arc::clone(&source_schema)).unwrap();
+/// let adapter = factory.make_adapter(&source_schema).unwrap();
///
/// // Create a source batch
/// let source_batch = RecordBatch::try_new(
@@ -603,10 +603,10 @@ impl BatchAdapterFactory {
///
/// Batches fed into this [`BatchAdapter`] *must* conform to the source schema,
/// no validation is performed at runtime to minimize overheads.
- pub fn make_adapter(&self, source_schema: SchemaRef) -> Result<BatchAdapter> {
+ pub fn make_adapter(&self, source_schema: &SchemaRef) -> Result<BatchAdapter> {
let expr_adapter = self
.expr_adapter_factory
- .create(Arc::clone(&self.target_schema), Arc::clone(&source_schema))?;
+ .create(Arc::clone(&self.target_schema), Arc::clone(source_schema))?;
let simplifier = PhysicalExprSimplifier::new(&self.target_schema);
@@ -617,7 +617,7 @@ impl BatchAdapterFactory {
let adapted = projection
.try_map_exprs(|e| simplifier.simplify(expr_adapter.rewrite(e)?))?;
- let projector = adapted.make_projector(&source_schema)?;
+ let projector = adapted.make_projector(source_schema)?;
Ok(BatchAdapter { projector })
}
@@ -707,7 +707,7 @@ mod tests {
let expr = expressions::BinaryExpr::new(
Arc::clone(&column_a),
Operator::Plus,
- Arc::new(expressions::Literal::new(ScalarValue::Int64(Some(5)))),
+ Arc::new(Literal::new(ScalarValue::Int64(Some(5)))),
);
let expr = expressions::BinaryExpr::new(
Arc::new(expr),
@@ -715,7 +715,7 @@ mod tests {
Arc::new(expressions::BinaryExpr::new(
Arc::clone(&column_c),
Operator::Gt,
- Arc::new(expressions::Literal::new(ScalarValue::Float64(Some(0.0)))),
+ Arc::new(Literal::new(ScalarValue::Float64(Some(0.0)))),
)),
);
@@ -730,7 +730,7 @@ mod tests {
None,
)),
Operator::Plus,
- Arc::new(expressions::Literal::new(ScalarValue::Int64(Some(5)))),
+ Arc::new(Literal::new(ScalarValue::Int64(Some(5)))),
);
let expected = Arc::new(expressions::BinaryExpr::new(
Arc::new(expected),
@@ -738,7 +738,7 @@ mod tests {
Arc::new(expressions::BinaryExpr::new(
lit(ScalarValue::Float64(None)), // c is missing, so it becomes null
Operator::Gt,
- Arc::new(expressions::Literal::new(ScalarValue::Float64(Some(0.0)))),
+ Arc::new(Literal::new(ScalarValue::Float64(Some(0.0)))),
)),
)) as Arc<dyn PhysicalExpr>;
@@ -856,7 +856,7 @@ mod tests {
let result = adapter.rewrite(column_expr)?;
// Should be replaced with a literal null
- if let Some(literal) = result.as_any().downcast_ref::<expressions::Literal>() {
+ if let Some(literal) = result.as_any().downcast_ref::<Literal>() {
assert_eq!(*literal.value(), ScalarValue::Float64(None));
} else {
panic!("Expected literal expression");
@@ -917,7 +917,7 @@ mod tests {
// Should be replaced with the partition value
let literal = result
.as_any()
- .downcast_ref::<expressions::Literal>()
+ .downcast_ref::<Literal>()
.expect("Expected literal expression");
assert_eq!(*literal.value(), partition_value);
@@ -1075,7 +1075,7 @@ mod tests {
assert_eq!(
res.column(0)
.as_any()
- .downcast_ref::<arrow::array::StringArray>()
+ .downcast_ref::<StringArray>()
.unwrap()
.iter()
.collect_vec(),
@@ -1084,7 +1084,7 @@ mod tests {
assert_eq!(
res.column(1)
.as_any()
- .downcast_ref::<arrow::array::Int64Array>()
+ .downcast_ref::<Int64Array>()
.unwrap()
.iter()
.collect_vec(),
@@ -1262,7 +1262,7 @@ mod tests {
]));
let factory = BatchAdapterFactory::new(Arc::clone(&target_schema));
- let adapter = factory.make_adapter(Arc::clone(&source_schema)).unwrap();
+ let adapter = factory.make_adapter(&source_schema).unwrap();
// Create source batch
let source_batch = RecordBatch::try_new(
@@ -1317,7 +1317,7 @@ mod tests {
]));
let factory = BatchAdapterFactory::new(Arc::clone(&target_schema));
- let adapter = factory.make_adapter(Arc::clone(&source_schema)).unwrap();
+ let adapter = factory.make_adapter(&source_schema).unwrap();
let source_batch = RecordBatch::try_new(
Arc::clone(&source_schema),
@@ -1380,7 +1380,7 @@ mod tests {
.unwrap();
let factory = BatchAdapterFactory::new(Arc::clone(&target_schema));
- let adapter = factory.make_adapter(source_schema).unwrap();
+ let adapter = factory.make_adapter(&source_schema).unwrap();
let adapted = adapter.adapt_batch(&source_batch).unwrap();
let result_struct = adapted
@@ -1405,7 +1405,7 @@ mod tests {
]));
let factory = BatchAdapterFactory::new(Arc::clone(&schema));
- let adapter = factory.make_adapter(Arc::clone(&schema)).unwrap();
+ let adapter = factory.make_adapter(&schema).unwrap();
let batch = RecordBatch::try_new(
Arc::clone(&schema),
@@ -1438,18 +1438,18 @@ mod tests {
Field::new("x", DataType::Int32, false),
Field::new("y", DataType::Utf8, true),
]));
- let adapter1 = factory.make_adapter(source1).unwrap();
+ let adapter1 = factory.make_adapter(&source1).unwrap();
// Second source schema (different order)
let source2 = Arc::new(Schema::new(vec![
Field::new("y", DataType::Utf8, true),
Field::new("x", DataType::Int64, false),
]));
- let adapter2 = factory.make_adapter(source2).unwrap();
+ let adapter2 = factory.make_adapter(&source2).unwrap();
// Both should work correctly
- assert!(format!("{:?}", adapter1).contains("BatchAdapter"));
- assert!(format!("{:?}", adapter2).contains("BatchAdapter"));
+ assert!(format!("{adapter1:?}").contains("BatchAdapter"));
+ assert!(format!("{adapter2:?}").contains("BatchAdapter"));
}
#[test]