Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 90 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -209,29 +209,111 @@ url = "2.5.7"
uuid = "1.23"
zstd = { version = "0.13", default-features = false }

# Keep this list sorted alphabetically.
# See https://github.com/apache/datafusion/issues/18467 for the ongoing effort of
# picking useful non-default lints.
[workspace.lints.clippy]
# https://github.com/apache/datafusion/issues/18881
allow_attributes = "warn"
as_ptr_cast_mut = "warn"
assigning_clones = "warn"
char_lit_as_u8 = "warn"
clear_with_drain = "warn"
coerce_container_to_any = "warn"
debug_assert_with_mut_call = "warn"
decimal_bitwise_operands = "warn"
default_union_representation = "warn"
doc_include_without_cfg = "warn"
empty_enum_variants_with_brackets = "warn"
empty_line_after_outer_attr = "warn"
exit = "warn"
flat_map_option = "warn"
fn_to_numeric_cast_any = "warn"
if_let_mutex = "warn"
imprecise_flops = "warn"
index_refutable_slice = "warn"
inefficient_to_string = "warn"
infinite_loop = "warn"
invalid_upcast_comparisons = "warn"
ip_constant = "warn"
iter_filter_is_ok = "warn"
iter_filter_is_some = "warn"
iter_on_empty_collections = "warn"
# Detects large stack-allocated futures that may cause stack overflow crashes (see threshold in clippy.toml)
large_futures = "warn"
used_underscore_binding = "warn"
or_fun_call = "warn"
unnecessary_lazy_evaluations = "warn"
uninlined_format_args = "warn"
inefficient_to_string = "warn"
large_include_file = "warn"
macro_use_imports = "warn"
manual_ilog2 = "warn"
manual_instant_elapsed = "warn"
manual_is_power_of_two = "warn"
manual_ok_or = "warn"
match_wild_err_arm = "warn"
mem_forget = "warn"
mismatching_type_param_order = "warn"
missing_enforced_import_renames = "warn"
mut_mut = "warn"
mutex_integer = "warn"
# https://github.com/apache/datafusion/issues/18503
needless_pass_by_value = "warn"
# https://github.com/apache/datafusion/issues/18881
allow_attributes = "warn"
assigning_clones = "warn"
negative_feature_names = "warn"
non_zero_suggestions = "warn"
nonstandard_macro_braces = "warn"
or_fun_call = "warn"
path_buf_push_overwrite = "warn"
pathbuf_init_then_push = "warn"
precedence_bits = "warn"
pub_underscore_fields = "warn"
rc_mutex = "warn"
ref_option_ref = "warn"
same_length_and_capacity = "warn"
str_split_at_newline = "warn"
string_add_assign = "warn"
suspicious_command_arg_space = "warn"
suspicious_xor_used_as_pow = "warn"
trailing_empty_array = "warn"
transmute_ptr_to_ptr = "warn"
uninhabited_references = "warn"
uninlined_format_args = "warn"
unnecessary_lazy_evaluations = "warn"
unnecessary_safety_comment = "warn"
unnecessary_self_imports = "warn"
unused_async = "warn"
unused_rounding = "warn"
used_underscore_binding = "warn"
useless_transmute = "warn"
verbose_file_reads = "warn"
wildcard_dependencies = "warn"
zero_sized_map_values = "warn"

# Keep this list sorted alphabetically.
[workspace.lints.rust]
# Part of the `rust_2018_idioms` group, but ~800 violations today:
# https://github.com/apache/datafusion/issues/18467
elided_lifetimes_in_paths = "allow"
future_incompatible = { level = "warn", priority = -1 }
nonstandard_style = { level = "warn", priority = -1 }
rust_2018_idioms = { level = "warn", priority = -1 }
rust_2021_prelude_collisions = "warn"
semicolon_in_expressions_from_macros = "warn"
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(datafusion_coop, values("tokio", "tokio_fallback", "per_stream"))',
"cfg(coverage)",
"cfg(coverage_nightly)",
] }
unsafe_op_in_unsafe_fn = "warn"
unused_extern_crates = "warn"
unused_import_braces = "warn"
unused_lifetimes = "warn"
unused_qualifications = "deny"

# Keep this list sorted alphabetically.
[workspace.lints.rustdoc]
all = { level = "warn", priority = -1 }
# Part of the `all` group, but has too many violations today to enable:
# https://github.com/apache/datafusion/issues/18467
missing_crate_level_docs = "allow"
unescaped_backticks = "allow"

# --------------------
# Compilation Profiles
# --------------------
Expand Down
2 changes: 1 addition & 1 deletion datafusion-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
html_favicon_url = "https://raw.githubusercontent.com/apache/datafusion/19fe44cf2f30cbdd63d4a4f52c74055163c6cc38/docs/logos/standalone_logo/logo_original.svg"
)]
#![cfg_attr(docsrs, feature(doc_cfg))]
#![doc = include_str!("../README.md")]
#![cfg_attr(doc, doc = include_str!("../README.md"))]
pub const DATAFUSION_CLI_VERSION: &str = env!("CARGO_PKG_VERSION");

pub mod catalog;
Expand Down
4 changes: 4 additions & 0 deletions datafusion-cli/tests/cli_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ fn test_cli_format<'a>(#[case] format: &'a str) {
#[case("top2", ["--top-memory-consumers", "2"])]
#[case("top3_default", [])]
#[test]
// `'a` is used by the signature below, but not by the per-case functions `rstest` generates.
#[expect(unused_lifetimes)]
fn test_cli_top_memory_consumers<'a>(
#[case] snapshot_name: &str,
#[case] top_memory_consumers: impl IntoIterator<Item = &'a str>,
Expand All @@ -446,6 +448,8 @@ fn test_cli_top_memory_consumers<'a>(
#[case("no_track", ["--top-memory-consumers", "0"])]
#[case("top2", ["--top-memory-consumers", "2"])]
#[test]
// `'a` is used by the signature below, but not by the per-case functions `rstest` generates.
#[expect(unused_lifetimes)]
fn test_cli_top_memory_consumers_with_mem_pool_type<'a>(
#[case] snapshot_name: &str,
#[case] top_memory_consumers: impl IntoIterator<Item = &'a str>,
Expand Down
2 changes: 1 addition & 1 deletion datafusion/common/src/cse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,7 +808,7 @@ mod test {
) -> HashSet<u64> {
id_array
.iter_mut()
.flat_map(|(_, id_option)| {
.filter_map(|(_, id_option)| {
id_option.as_mut().map(|node_id| {
let hash = node_id.hash;
node_id.hash = 0;
Expand Down
3 changes: 3 additions & 0 deletions datafusion/common/src/rounding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ const FE_UPWARD: i32 = 0x0800;
#[cfg(all(target_arch = "x86_64", not(target_os = "windows")))]
const FE_DOWNWARD: i32 = 0x0400;

// Links `libc`, which provides the `fesetround`/`fegetround` symbols declared below.
// There is no path reference to the crate, so `unused_extern_crates` cannot see the use.
#[expect(unused_extern_crates)]
#[cfg(all(
any(target_arch = "x86_64", target_arch = "aarch64"),
not(target_os = "windows")
Expand Down
2 changes: 1 addition & 1 deletion datafusion/common/src/utils/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ where
if cfg!(debug_assertions) {
// In debug mode, check that the element is not already present
debug_assert!(
self.find_entry(hash, |y| y == &x).is_err(),
self.find(hash, |y| y == &x).is_none(),
"attempted to insert duplicate element into HashTableAllocExt::insert_accounted"
);
}
Expand Down
6 changes: 1 addition & 5 deletions datafusion/core/benches/parquet_query_sql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ use parquet::file::properties::{WriterProperties, WriterVersion};
use rand::distr::Alphanumeric;
use rand::distr::uniform::SampleUniform;
use rand::prelude::*;
use std::fs::File;
use std::io::Read;
use std::ops::Range;
use std::path::Path;
use std::sync::Arc;
Expand Down Expand Up @@ -211,9 +209,7 @@ fn criterion_benchmark(c: &mut Criterion) {
.unwrap();

// We read the queries from a file so they can be changed without recompiling the benchmark
let mut queries_file = File::open("benches/parquet_query_sql.sql").unwrap();
let mut queries = String::new();
queries_file.read_to_string(&mut queries).unwrap();
let queries = std::fs::read_to_string("benches/parquet_query_sql.sql").unwrap();

for query in queries.split(';') {
let query = query.trim();
Expand Down
5 changes: 1 addition & 4 deletions datafusion/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -761,11 +761,8 @@
//! [`RecordBatch`]: arrow::array::RecordBatch
//! [`RecordBatchReader`]: arrow::record_batch::RecordBatchReader
//! [`Array`]: arrow::array::Array
#![doc = include_str!("optimizer_rule_reference.md")]
#![cfg_attr(doc, doc = include_str!("optimizer_rule_reference.md"))]

extern crate core;
#[cfg(feature = "sql")]
extern crate sqlparser;
/// DataFusion crate version
pub const DATAFUSION_VERSION: &str = env!("CARGO_PKG_VERSION");

Expand Down
4 changes: 2 additions & 2 deletions datafusion/core/tests/physical_optimizer/enforce_sorting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::physical_optimizer::test_utils::{
spr_repartition_exec, stream_exec_ordered, union_exec,
};

use arrow::compute::{SortOptions};
use arrow::compute::SortOptions;
use arrow::datatypes::{DataType, SchemaRef};
use datafusion_common::config::{ConfigOptions, CsvOptions};
use datafusion_common::tree_node::{TreeNode, TransformedResult};
Expand Down Expand Up @@ -61,7 +61,7 @@ use datafusion_physical_optimizer::output_requirements::OutputRequirementExec;
use datafusion_physical_optimizer::PhysicalOptimizerRule;
use datafusion::prelude::*;
use arrow::array::{record_batch, Array, ArrayRef, Int32Array, RecordBatch};
use arrow::datatypes::{Field};
use arrow::datatypes::Field;
use arrow_schema::Schema;
use datafusion_execution::TaskContext;
use datafusion_catalog::streaming::StreamingTable;
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/tests/physical_optimizer/pushdown_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ pub fn format_execution_plan(plan: &Arc<dyn ExecutionPlan>) -> Vec<String> {
}

fn format_lines(s: &str) -> Vec<String> {
s.trim().split('\n').map(|s| s.to_string()).collect()
s.trim().lines().map(|s| s.to_string()).collect()
}

pub fn format_plan_for_test(plan: &Arc<dyn ExecutionPlan>) -> String {
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/tests/physical_optimizer/test_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -801,7 +801,7 @@ pub fn format_execution_plan(plan: &Arc<dyn ExecutionPlan>) -> Vec<String> {
}

fn format_lines(s: &str) -> Vec<String> {
s.trim().split('\n').map(|s| s.to_string()).collect()
s.trim().lines().map(|s| s.to_string()).collect()
}

/// Create a simple ProjectionExec with column indices (simplified version)
Expand Down
30 changes: 9 additions & 21 deletions datafusion/datasource-arrow/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ impl From<ArrowSource> for Arc<dyn FileSource> {

#[cfg(test)]
mod tests {
use std::{fs::File, io::Read};
use std::fs::File;

use arrow::datatypes::{DataType, Field, Schema};
use arrow_ipc::reader::{FileReader, StreamReader};
Expand All @@ -460,11 +460,8 @@ mod tests {
for filename in ["example.arrow", "example_stream.arrow"] {
let path = format!("tests/data/{filename}");
let path_str = path.as_str();
let mut file = File::open(path_str)?;
let file_size = file.metadata()?.len();

let mut buffer = Vec::new();
file.read_to_end(&mut buffer)?;
let buffer = std::fs::read(path_str)?;
let file_size = buffer.len() as u64;
let bytes = Bytes::from(buffer);

let object_store = Arc::new(InMemory::new());
Expand Down Expand Up @@ -504,11 +501,8 @@ mod tests {
let filename = "example.arrow";
let path = format!("tests/data/{filename}");
let path_str = path.as_str();
let mut file = File::open(path_str)?;
let file_size = file.metadata()?.len();

let mut buffer = Vec::new();
file.read_to_end(&mut buffer)?;
let buffer = std::fs::read(path_str)?;
let file_size = buffer.len() as u64;
let bytes = Bytes::from(buffer);

let object_store = Arc::new(InMemory::new());
Expand Down Expand Up @@ -545,11 +539,8 @@ mod tests {
let filename = "example_stream.arrow";
let path = format!("tests/data/{filename}");
let path_str = path.as_str();
let mut file = File::open(path_str)?;
let file_size = file.metadata()?.len();

let mut buffer = Vec::new();
file.read_to_end(&mut buffer)?;
let buffer = std::fs::read(path_str)?;
let file_size = buffer.len() as u64;
let bytes = Bytes::from(buffer);

let object_store = Arc::new(InMemory::new());
Expand Down Expand Up @@ -610,11 +601,8 @@ mod tests {
let filename = "example_stream.arrow";
let path = format!("tests/data/{filename}");
let path_str = path.as_str();
let mut file = File::open(path_str)?;
let file_size = file.metadata()?.len();

let mut buffer = Vec::new();
file.read_to_end(&mut buffer)?;
let buffer = std::fs::read(path_str)?;
let file_size = buffer.len() as u64;
let bytes = Bytes::from(buffer);

let object_store = Arc::new(InMemory::new());
Expand Down
2 changes: 1 addition & 1 deletion datafusion/datasource-json/src/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const JSON_CONVERTER_BUFFER_SIZE: usize = 2 * 1024 * 1024;
/// A stream wrapper that holds SpawnedTask handles to keep them alive
/// until the stream is fully consumed or dropped.
///
/// This ensures cancel-safety: when the stream is dropped, the tasks
/// This makes the stream cancel-safe: when the stream is dropped, the tasks
/// are properly aborted via SpawnedTask's Drop implementation.
struct JsonArrayStream {
inner: ReceiverStream<std::result::Result<RecordBatch, arrow::error::ArrowError>>,
Expand Down
4 changes: 2 additions & 2 deletions datafusion/datasource-parquet/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1488,8 +1488,8 @@ mod tests {
#[test]
fn test_distinct_count_from_real_parquet_file() {
// Path to test file created by DuckDB with distinct_count statistics
let mut path = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
path.push("src/test_data/ndv_test.parquet");
let path = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("src/test_data/ndv_test.parquet");

let file = File::open(&path).expect("Failed to open test parquet file");
let reader =
Expand Down
2 changes: 0 additions & 2 deletions datafusion/expr/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@
//!
//! The [expr_fn] module contains functions for creating expressions.

extern crate core;

mod higher_order_function;
mod literal;
mod operation;
Expand Down
2 changes: 1 addition & 1 deletion datafusion/expr/src/logical_plan/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2177,7 +2177,7 @@ pub fn wrap_projection_for_join_if_necessary(
// Expr contains Arc with interior mutability but is intentionally used as hash key
let join_key_items = alias_join_keys
.iter()
.flat_map(|expr| expr.try_as_col().is_none().then_some(expr))
.filter(|expr| expr.try_as_col().is_none())
.cloned()
.collect::<HashSet<Expr>>();
projection.extend(join_key_items);
Expand Down
1 change: 1 addition & 0 deletions datafusion/ffi/src/tests/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ pub fn get_module() -> Result<ForeignLibraryModule> {
assert_eq!((module.version)(), expected_version);

// Leak the library to keep it loaded for the duration of the test
#[expect(clippy::mem_forget)]
std::mem::forget(lib);

Ok(module)
Expand Down
2 changes: 1 addition & 1 deletion datafusion/functions-aggregate/src/percentile_cont.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use crate::utils::validate_percentile_expr;

/// Precision multiplier for linear interpolation calculations.
///
/// This value of 1,000,000 was chosen to balance precision with overflow safety:
/// This value of 1,000,000 was chosen to balance precision against overflow risk:
/// - Provides 6 decimal places of precision for the fractional component
/// - Small enough to avoid overflow when multiplied with typical numeric values
/// - Sufficient precision for most statistical applications
Expand Down
8 changes: 4 additions & 4 deletions datafusion/functions-nested/src/range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ impl Range {
let stop = cast_to_ns(stop)?;
let stop = as_timestamp_nanosecond_array(&stop)?;

let start_tz = parse_tz(&start.timezone())?;
let stop_tz = parse_tz(&stop.timezone())?;
let start_tz = parse_tz(start.timezone())?;
let stop_tz = parse_tz(stop.timezone())?;

// values are timestamps
let values_builder = start
Expand Down Expand Up @@ -609,8 +609,8 @@ fn generate_range_values(
Ok(())
}

fn parse_tz(tz: &Option<&str>) -> Result<Tz> {
let tz = tz.unwrap_or_else(|| "+00");
fn parse_tz(tz: Option<&str>) -> Result<Tz> {
let tz = tz.unwrap_or("+00");

Tz::from_str(tz)
.map_err(|op| exec_datafusion_err!("failed to parse timezone {tz}: {:?}", op))
Expand Down
2 changes: 0 additions & 2 deletions datafusion/functions/benches/atan2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
// specific language governing permissions and limitations
// under the License.

extern crate criterion;

use arrow::datatypes::{DataType, Field, Float32Type, Float64Type};
use arrow::util::bench_util::create_primitive_array;
use criterion::{Criterion, criterion_group, criterion_main};
Expand Down
Loading
Loading