Skip to content
Open
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
3 changes: 0 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,10 @@ explicit_iter_loop = "allow" # 189 hits
float_cmp = "allow" # 8 hits; exact float comparisons are often intentional here
from_iter_instead_of_collect = "allow" # 51 hits
if_not_else = "allow" # 133 hits
ignored_unit_patterns = "allow" # 52 hits
implicit_clone = "allow" # 198 hits
implicit_hasher = "allow" # 17 hits; some sites feed arrow APIs that require the default hasher
inline_always = "allow" # 45 hits
items_after_statements = "allow" # 171 hits
manual_string_new = "allow" # 84 hits
many_single_char_names = "allow" # 12 hits; short names are idiomatic in the numeric kernels
map_unwrap_or = "allow" # 198 hits
match_bool = "allow" # 46 hits
Expand All @@ -300,7 +298,6 @@ missing_panics_doc = "allow" # 244 hits
must_use_candidate = "allow" # 2726 hits
needless_raw_string_hashes = "allow" # 540 hits
redundant_closure_for_method_calls = "allow" # 686 hits
redundant_else = "allow" # 48 hits
return_self_not_must_use = "allow" # 644 hits
semicolon_if_nothing_returned = "allow" # 1353 hits
similar_names = "allow" # 228 hits; too many false positives, e.g. `expr`/`exprs`
Expand Down
4 changes: 2 additions & 2 deletions benchmarks/src/cancellation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ fn run_test(wait_time: u64, store: Arc<dyn ObjectStore>) -> Result<Duration> {
let store = Arc::clone(&store);
tokio::select! {
biased;
_ = async move {
() = async move {
datafusion(store).await.unwrap();
} => {
println!("matched case doing work");
},
_ = captured_token.cancelled() => {
() = captured_token.cancelled() => {
println!("Received shutdown request");
return;
},
Expand Down
12 changes: 6 additions & 6 deletions benchmarks/src/sql_benchmark.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ impl SqlBenchmark {

while let Some(result) = reader_result {
match result {
Ok(_) => {
Ok(()) => {
if !is_blank_or_comment_line(&line) {
// boxing required because of recursion
Box::pin(self.process_line(ctx, &mut reader, &mut line)).await?;
Expand Down Expand Up @@ -824,7 +824,7 @@ impl BenchmarkDirective {

loop {
match reader_result {
Some(Ok(_)) => {
Some(Ok(())) => {
if is_comment_line(line) {
// comment, ignore
} else if is_blank_line(line) {
Expand Down Expand Up @@ -956,7 +956,7 @@ impl BenchmarkDirective {

loop {
match reader_result {
Some(Ok(_)) => {
Some(Ok(())) => {
if line.trim() == "----" {
found_break = true;
break;
Expand Down Expand Up @@ -1045,7 +1045,7 @@ impl BenchmarkDirective {

loop {
match reader_result {
Some(Ok(_)) => {
Some(Ok(())) => {
if line.trim() == "----" {
found_break = true;
break;
Expand Down Expand Up @@ -1108,7 +1108,7 @@ impl BenchmarkDirective {

loop {
match reader_result {
Some(Ok(_)) => {
Some(Ok(())) => {
if is_comment_line(line) {
// Clear the line buffer for the next iteration.
line.clear();
Expand Down Expand Up @@ -1449,7 +1449,7 @@ fn read_query_from_reader(

loop {
match reader_result {
Some(Ok(_)) => {
Some(Ok(())) => {
if is_comment_line(&line) {
// comment, ignore
} else if is_blank_line(&line) {
Expand Down
8 changes: 4 additions & 4 deletions datafusion-cli/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub async fn exec_from_lines(
reader: &mut BufReader<File>,
print_options: &PrintOptions,
) -> Result<()> {
let mut query = "".to_owned();
let mut query = String::new();

for line in reader.lines() {
match line {
Expand All @@ -79,10 +79,10 @@ pub async fn exec_from_lines(
query.push_str(line);
if line.ends_with(';') {
match exec_and_print(ctx, print_options, query).await {
Ok(_) => {}
Ok(()) => {}
Err(err) => eprintln!("{err}"),
}
query = "".to_string();
query = String::new();
} else {
query.push('\n');
}
Expand Down Expand Up @@ -175,7 +175,7 @@ pub async fn exec_from_repl(
rl.add_history_entry(line.trim_end())?;
tokio::select! {
res = exec_and_print(ctx, print_options, line) => match res {
Ok(_) => {}
Ok(()) => {}
Err(err) => eprintln!("{err}"),
},
_ = signal::ctrl_c() => {
Expand Down
3 changes: 1 addition & 2 deletions datafusion-cli/src/functions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -665,8 +665,7 @@ impl TableFunctionImpl for StatisticsCacheFunc {
{
for (path, entry) in file_statistics_cache.list_entries() {
path_arr.push(path.path.to_string());
table_arr
.push(path.table.map_or_else(|| "".to_string(), |t| t.to_string()));
table_arr.push(path.table.map_or_else(String::new, |t| t.to_string()));
file_modified_arr
.push(Some(entry.value.meta.last_modified.timestamp_millis()));
file_size_bytes_arr.push(entry.value.meta.size);
Expand Down
5 changes: 2 additions & 3 deletions datafusion-cli/src/print_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ fn format_batches_with_maxrows<W: std::io::Write>(
filtered_batches.push(sliced_batch);
over_limit = true;
break;
} else {
filtered_batches.push(batch.clone());
row_count += batch.num_rows();
}
filtered_batches.push(batch.clone());
row_count += batch.num_rows();
}

let formatted =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ async fn read_encrypted_with_sql(ctx: &SessionContext, table_path: &str) -> Resu
extensions_options! {
struct EncryptionConfig {
/// Comma-separated list of columns to encrypt
pub encrypted_columns: String, default = "".to_owned()
pub encrypted_columns: String, default = String::new()
}
}

Expand Down
5 changes: 2 additions & 3 deletions datafusion-examples/examples/udf/simple_udtf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,9 @@ impl TableProvider for LocalCsvTable {
let batch_lines = max_return_lines - lines;
batches.push(batch.slice(0, batch_lines));
break;
} else {
batches.push(batch.clone());
lines += batch_lines;
}
batches.push(batch.clone());
lines += batch_lines;
}
batches
} else {
Expand Down
9 changes: 4 additions & 5 deletions datafusion/catalog-listing/src/table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,12 +425,11 @@ fn derive_common_ordering_from_files(file_groups: &[FileGroup]) -> Option<LexOrd
"Cannot derive common ordering: no common prefix between orderings {current:?} and {ordering:?}"
);
return None;
} else {
let ordering =
LexOrdering::new(current.as_ref()[..prefix_len].to_vec())
.expect("prefix_len > 0, so ordering must be valid");
CurrentOrderingState::SomeOrdering(ordering)
}
let ordering =
LexOrdering::new(current.as_ref()[..prefix_len].to_vec())
.expect("prefix_len > 0, so ordering must be valid");
CurrentOrderingState::SomeOrdering(ordering)
}
// If one file has ordering and another doesn't, no common ordering
// Return None and log a trace message explaining why
Expand Down
8 changes: 4 additions & 4 deletions datafusion/common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2000,7 +2000,7 @@ config_namespace! {
/// instead of being converted into a [`std::fmt::Error`]
pub safe: bool, default = true
/// Format string for nulls
pub null: String, default = "".into()
pub null: String, default = String::new()
/// Date format for date arrays
pub date_format: Option<String>, default = Some("%Y-%m-%d".to_string())
/// Format for DateTime arrays
Expand Down Expand Up @@ -3399,7 +3399,7 @@ impl Default for ConfigFileEncryptionProperties {
config_namespace_with_hashmap! {
pub struct ColumnEncryptionProperties {
/// Per column encryption key
pub column_key_as_hex: String, default = "".to_string()
pub column_key_as_hex: String, default = String::new()
/// Per column encryption key metadata
pub column_metadata_as_hex: Option<String>, default = None
}
Expand Down Expand Up @@ -3578,7 +3578,7 @@ pub struct ConfigFileDecryptionProperties {
config_namespace_with_hashmap! {
pub struct ColumnDecryptionProperties {
/// Per column encryption key
pub column_key_as_hex: String, default = "".to_string()
pub column_key_as_hex: String, default = String::new()
}
}

Expand Down Expand Up @@ -4548,7 +4548,7 @@ mod tests {

let parsed_metadata = table_config.parquet.key_value_metadata.clone();
assert_eq!(parsed_metadata.get("should not exist1"), None);
assert_eq!(parsed_metadata.get("key1"), Some(&Some("".into())));
assert_eq!(parsed_metadata.get("key1"), Some(&Some(String::new())));
assert_eq!(parsed_metadata.get("key2"), Some(&Some("value2".into())));
assert_eq!(
parsed_metadata.get("key3"),
Expand Down
11 changes: 5 additions & 6 deletions datafusion/common/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,11 @@ impl DataFusionError {
return format!("{}{}", Self::BACK_TRACE_SEP, back_trace);
}

"".to_owned()
String::new()
}

#[cfg(not(feature = "backtrace"))]
"".to_owned()
String::new()
}

/// Return a [`DataFusionErrorBuilder`] to build a [`DataFusionError`]
Expand Down Expand Up @@ -606,16 +606,15 @@ impl DataFusionError {
pub fn message(&self) -> Cow<'_, str> {
match *self {
DataFusionError::ArrowError(ref desc, ref backtrace) => {
let backtrace = backtrace.clone().unwrap_or_else(|| "".to_owned());
let backtrace = backtrace.clone().unwrap_or_else(String::new);
Cow::Owned(format!("{desc}{backtrace}"))
}
#[cfg(feature = "parquet")]
DataFusionError::ParquetError(ref desc) => Cow::Owned(desc.to_string()),
DataFusionError::IoError(ref desc) => Cow::Owned(desc.to_string()),
#[cfg(feature = "sql")]
DataFusionError::SQL(ref desc, ref backtrace) => {
let backtrace: String =
backtrace.clone().unwrap_or_else(|| "".to_owned());
let backtrace: String = backtrace.clone().unwrap_or_else(String::new);
Cow::Owned(format!("{desc:?}{backtrace}"))
}
DataFusionError::Configuration(ref desc) => Cow::Owned(desc.to_string()),
Expand All @@ -628,7 +627,7 @@ impl DataFusionError {
DataFusionError::Plan(ref desc) => Cow::Owned(desc.to_string()),
DataFusionError::SchemaError(ref desc, ref backtrace) => {
let backtrace: &str =
&backtrace.as_ref().clone().unwrap_or_else(|| "".to_owned());
&backtrace.as_ref().clone().unwrap_or_else(String::new);
Cow::Owned(format!("{desc}{backtrace}"))
}
DataFusionError::Execution(ref desc) => Cow::Owned(desc.to_string()),
Expand Down
14 changes: 7 additions & 7 deletions datafusion/common/src/scalar/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1703,9 +1703,9 @@ impl ScalarValue {
| DataType::Date64 => ScalarValue::new_zero(datatype),

// String types
DataType::Utf8 => Ok(ScalarValue::Utf8(Some("".to_string()))),
DataType::LargeUtf8 => Ok(ScalarValue::LargeUtf8(Some("".to_string()))),
DataType::Utf8View => Ok(ScalarValue::Utf8View(Some("".to_string()))),
DataType::Utf8 => Ok(ScalarValue::Utf8(Some(String::new()))),
DataType::LargeUtf8 => Ok(ScalarValue::LargeUtf8(Some(String::new()))),
DataType::Utf8View => Ok(ScalarValue::Utf8View(Some(String::new()))),

// Binary types
DataType::Binary => Ok(ScalarValue::Binary(Some(vec![]))),
Expand Down Expand Up @@ -5650,7 +5650,7 @@ impl fmt::Display for ScalarValue {
match epoch.checked_add_signed(Duration::try_days(v as i64).unwrap())
{
Some(date) => date.to_string(),
None => "".to_string(),
None => String::new(),
}
})
)?,
Expand All @@ -5661,7 +5661,7 @@ impl fmt::Display for ScalarValue {
match epoch.checked_add_signed(Duration::try_milliseconds(v).unwrap())
{
Some(date) => date.to_string(),
None => "".to_string(),
None => String::new(),
}
})
)?,
Expand Down Expand Up @@ -10640,11 +10640,11 @@ mod tests {
// Test string types
assert_eq!(
ScalarValue::new_default(&DataType::Utf8).unwrap(),
ScalarValue::Utf8(Some("".to_string()))
ScalarValue::Utf8(Some(String::new()))
);
assert_eq!(
ScalarValue::new_default(&DataType::LargeUtf8).unwrap(),
ScalarValue::LargeUtf8(Some("".to_string()))
ScalarValue::LargeUtf8(Some(String::new()))
);

// Test binary types
Expand Down
10 changes: 5 additions & 5 deletions datafusion/common/src/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,16 +285,16 @@ pub fn get_data_dir(
let trimmed = dir.trim().to_string();
if !trimmed.is_empty() {
let pb = PathBuf::from(trimmed);
if pb.is_dir() {
return Ok(pb);
return if pb.is_dir() {
Ok(pb)
} else {
return Err(format!(
Err(format!(
"the data dir `{}` defined by env {} not found",
pb.display(),
udf_env
)
.into());
}
.into())
};
}
}

Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/bin/print_functions_docs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fn print_docs(
providers: Vec<Box<dyn DocProvider>>,
doc_sections: Vec<DocSection>,
) -> Result<String> {
let mut docs = "".to_string();
let mut docs = String::new();

// Ensure that all providers have documentation
let mut providers_with_no_docs = HashSet::new();
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/datasource/file_format/avro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ mod tests {
assert_eq!(11, batch.num_columns());
assert_eq!(2, batch.num_rows());
})
.fold(0, |acc, _| async move { acc + 1i32 })
.fold(0, |acc, ()| async move { acc + 1i32 })
.await;

assert_eq!(tt_batches, 4 /* 8/2 */);
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/datasource/file_format/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ mod tests {
assert_eq!(12, batch.num_columns());
assert_eq!(2, batch.num_rows());
})
.fold(0, |acc, _| async move { acc + 1i32 })
.fold(0, |acc, ()| async move { acc + 1i32 })
.await;

assert_eq!(tt_batches, 50 /* 100/2 */);
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/datasource/file_format/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ mod tests {
assert_eq!(4, batch.num_columns());
assert_eq!(2, batch.num_rows());
})
.fold(0, |acc, _| async move { acc + 1i32 })
.fold(0, |acc, ()| async move { acc + 1i32 })
.await;

assert_eq!(tt_batches, 6 /* 12/2 */);
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/datasource/file_format/parquet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ mod tests {
assert_eq!(11, batch.num_columns());
assert_eq!(2, batch.num_rows());
})
.fold(0, |acc, _| async move { acc + 1i32 })
.fold(0, |acc, ()| async move { acc + 1i32 })
.await;

assert_eq!(tt_batches, 4 /* 8/2 */);
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/datasource/listing_table_factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ fn get_extension(path: &str) -> String {
let res = Path::new(path).extension().and_then(|ext| ext.to_str());
match res {
Some(ext) => format!(".{ext}"),
None => "".to_string(),
None => String::new(),
}
}

Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/datasource/physical_plan/csv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ mod tests {

// get name of first part
let paths = fs::read_dir(&out_dir).unwrap();
let mut part_0_name: String = "".to_owned();
let mut part_0_name: String = String::new();
for path in paths {
let path = path.unwrap();
let name = path
Expand Down
2 changes: 1 addition & 1 deletion datafusion/core/src/datasource/physical_plan/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ mod tests {

// get name of first part
let paths = fs::read_dir(&out_dir).unwrap();
let mut part_0_name: String = "".to_owned();
let mut part_0_name: String = String::new();
for path in paths {
let name = path
.unwrap()
Expand Down
Loading