Skip to content

Commit 91e623b

Browse files
timsauceralamb
andauthored
chore: upgrade expr and execution crates to rust 2024 edition (#19047)
## Which issue does this PR close? This addresses part of #15804 but does not close it. ## Rationale for this change Now that we are on MSRV 1.88 we can use rust edition 2024, which brings let chains and other nice features. It also improves `unsafe` checking. In order to introduce these changes in slower way instead of one massive PR that is too difficult to manage we are updating a few crates at a time. ## What changes are included in this PR? Updates 2 crates to 2024. - expr - execution ## Are these changes tested? Existing unit tests. There are no functional code changes. ## Are there any user-facing changes? None. Co-authored-by: Andrew Lamb <[email protected]>
1 parent 9af6858 commit 91e623b

Some content is hidden

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

46 files changed

+511
-393
lines changed

datafusion/execution/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ description = "Execution configuration support for DataFusion query engine"
2121
keywords = ["arrow", "query", "sql"]
2222
readme = "README.md"
2323
version = { workspace = true }
24-
edition = { workspace = true }
24+
edition = "2024"
2525
homepage = { workspace = true }
2626
repository = { workspace = true }
2727
license = { workspace = true }

datafusion/execution/src/cache/cache_manager.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use crate::cache::cache_unit::DefaultFilesMetadataCache;
1918
use crate::cache::CacheAccessor;
19+
use crate::cache::cache_unit::DefaultFilesMetadataCache;
2020
use datafusion_common::{Result, Statistics};
21-
use object_store::path::Path;
2221
use object_store::ObjectMeta;
22+
use object_store::path::Path;
2323
use std::any::Any;
2424
use std::collections::HashMap;
2525
use std::fmt::{Debug, Formatter};

datafusion/execution/src/cache/cache_unit.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
use std::collections::HashMap;
1919
use std::sync::{Arc, Mutex};
2020

21+
use crate::cache::CacheAccessor;
2122
use crate::cache::cache_manager::{
2223
FileMetadata, FileMetadataCache, FileMetadataCacheEntry,
2324
};
2425
use crate::cache::lru_queue::LruQueue;
25-
use crate::cache::CacheAccessor;
2626

2727
use datafusion_common::Statistics;
2828

2929
use dashmap::DashMap;
30-
use object_store::path::Path;
3130
use object_store::ObjectMeta;
31+
use object_store::path::Path;
3232

3333
/// Default implementation of [`FileStatisticsCache`]
3434
///
@@ -88,7 +88,7 @@ impl CacheAccessor<Path, Arc<Statistics>> for DefaultFileStatisticsCache {
8888
}
8989

9090
fn remove(&self, k: &Path) -> Option<Arc<Statistics>> {
91-
self.statistics.remove(k).map(|x| x.1 .1)
91+
self.statistics.remove(k).map(|x| x.1.1)
9292
}
9393

9494
fn contains_key(&self, k: &Path) -> bool {
@@ -253,7 +253,7 @@ impl DefaultFilesMetadataCacheState {
253253
fn evict_entries(&mut self) {
254254
while self.memory_used > self.memory_limit {
255255
if let Some(removed) = self.lru_queue.pop() {
256-
let metadata: Arc<dyn FileMetadata> = removed.1 .1;
256+
let metadata: Arc<dyn FileMetadata> = removed.1.1;
257257
self.memory_used -= metadata.memory_size();
258258
} else {
259259
// cache is empty while memory_used > memory_limit, cannot happen
@@ -429,18 +429,18 @@ mod tests {
429429
use std::collections::HashMap;
430430
use std::sync::Arc;
431431

432+
use crate::cache::CacheAccessor;
432433
use crate::cache::cache_manager::{
433434
FileMetadata, FileMetadataCache, FileMetadataCacheEntry,
434435
};
435436
use crate::cache::cache_unit::{
436437
DefaultFileStatisticsCache, DefaultFilesMetadataCache, DefaultListFilesCache,
437438
};
438-
use crate::cache::CacheAccessor;
439439
use arrow::datatypes::{DataType, Field, Schema, TimeUnit};
440440
use chrono::DateTime;
441441
use datafusion_common::Statistics;
442-
use object_store::path::Path;
443442
use object_store::ObjectMeta;
443+
use object_store::path::Path;
444444

445445
#[test]
446446
fn test_statistics_cache() {

datafusion/execution/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ use std::{
2323
};
2424

2525
use datafusion_common::{
26-
config::{ConfigExtension, ConfigOptions, SpillCompression},
2726
Result, ScalarValue,
27+
config::{ConfigExtension, ConfigOptions, SpillCompression},
2828
};
2929

3030
/// Configuration options for [`SessionContext`].

datafusion/execution/src/disk_manager.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@
1818
//! [`DiskManager`]: Manages files generated during query execution
1919
2020
use datafusion_common::{
21-
config_err, resources_datafusion_err, resources_err, DataFusionError, Result,
21+
DataFusionError, Result, config_err, resources_datafusion_err, resources_err,
2222
};
2323
use log::debug;
2424
use parking_lot::Mutex;
25-
use rand::{rng, Rng};
25+
use rand::{Rng, rng};
2626
use std::path::{Path, PathBuf};
27-
use std::sync::atomic::{AtomicU64, Ordering};
2827
use std::sync::Arc;
28+
use std::sync::atomic::{AtomicU64, Ordering};
2929
use tempfile::{Builder, NamedTempFile, TempDir};
3030

3131
use crate::memory_pool::human_readable_size;
@@ -508,7 +508,10 @@ mod tests {
508508
);
509509
assert!(!manager.tmp_files_enabled());
510510
assert_eq!(
511-
manager.create_tmp_file("Testing").unwrap_err().strip_backtrace(),
511+
manager
512+
.create_tmp_file("Testing")
513+
.unwrap_err()
514+
.strip_backtrace(),
512515
"Resources exhausted: Memory Exhausted while Testing (DiskManager is disabled)",
513516
)
514517
}

datafusion/execution/src/memory_pool/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
//! [`MemoryPool`] for memory management during query execution, [`proxy`] for
1919
//! help with allocation accounting.
2020
21-
use datafusion_common::{internal_err, Result};
21+
use datafusion_common::{Result, internal_err};
2222
use std::hash::{Hash, Hasher};
23-
use std::{cmp::Ordering, sync::atomic, sync::Arc};
23+
use std::{cmp::Ordering, sync::Arc, sync::atomic};
2424

2525
mod pool;
2626
pub mod proxy {

datafusion/execution/src/memory_pool/pool.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
// under the License.
1717

1818
use crate::memory_pool::{
19-
human_readable_size, MemoryConsumer, MemoryLimit, MemoryPool, MemoryReservation,
19+
MemoryConsumer, MemoryLimit, MemoryPool, MemoryReservation, human_readable_size,
2020
};
2121
use datafusion_common::HashMap;
22-
use datafusion_common::{resources_datafusion_err, DataFusionError, Result};
22+
use datafusion_common::{DataFusionError, Result, resources_datafusion_err};
2323
use log::debug;
2424
use parking_lot::Mutex;
2525
use std::{
@@ -260,8 +260,13 @@ fn insufficient_capacity_err(
260260
additional: usize,
261261
available: usize,
262262
) -> DataFusionError {
263-
resources_datafusion_err!("Failed to allocate additional {} for {} with {} already allocated for this reservation - {} remain available for the total pool",
264-
human_readable_size(additional), reservation.registration.consumer.name, human_readable_size(reservation.size), human_readable_size(available))
263+
resources_datafusion_err!(
264+
"Failed to allocate additional {} for {} with {} already allocated for this reservation - {} remain available for the total pool",
265+
human_readable_size(additional),
266+
reservation.registration.consumer.name,
267+
human_readable_size(reservation.size),
268+
human_readable_size(available)
269+
)
265270
}
266271

267272
#[derive(Debug)]
@@ -497,13 +502,15 @@ fn provide_top_memory_consumers_to_error_msg(
497502
error_msg: &str,
498503
top_consumers: &str,
499504
) -> String {
500-
format!("Additional allocation failed for {consumer_name} with top memory consumers (across reservations) as:\n{top_consumers}\nError: {error_msg}")
505+
format!(
506+
"Additional allocation failed for {consumer_name} with top memory consumers (across reservations) as:\n{top_consumers}\nError: {error_msg}"
507+
)
501508
}
502509

503510
#[cfg(test)]
504511
mod tests {
505512
use super::*;
506-
use insta::{allow_duplicates, assert_snapshot, Settings};
513+
use insta::{Settings, allow_duplicates, assert_snapshot};
507514
use std::sync::Arc;
508515

509516
fn make_settings() -> Settings {

datafusion/execution/src/object_store.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@
2121
2222
use dashmap::DashMap;
2323
use datafusion_common::{
24-
exec_err, internal_datafusion_err, not_impl_err, DataFusionError, Result,
24+
DataFusionError, Result, exec_err, internal_datafusion_err, not_impl_err,
2525
};
26+
use object_store::ObjectStore;
2627
#[cfg(not(target_arch = "wasm32"))]
2728
use object_store::local::LocalFileSystem;
28-
use object_store::ObjectStore;
2929
use std::sync::Arc;
3030
use url::Url;
3131

@@ -160,7 +160,9 @@ pub trait ObjectStoreRegistry: Send + Sync + std::fmt::Debug + 'static {
160160
/// deregistered store if it existed.
161161
#[allow(unused_variables)]
162162
fn deregister_store(&self, url: &Url) -> Result<Arc<dyn ObjectStore>> {
163-
not_impl_err!("ObjectStoreRegistry::deregister_store is not implemented for this ObjectStoreRegistry")
163+
not_impl_err!(
164+
"ObjectStoreRegistry::deregister_store is not implemented for this ObjectStoreRegistry"
165+
)
164166
}
165167

166168
/// Get a suitable store for the provided URL. For example:
@@ -290,17 +292,29 @@ mod tests {
290292
assert_eq!(err.strip_backtrace(), "External error: invalid port number");
291293

292294
let err = ObjectStoreUrl::parse("s3://bucket?").unwrap_err();
293-
assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?");
295+
assert_eq!(
296+
err.strip_backtrace(),
297+
"Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?"
298+
);
294299

295300
let err = ObjectStoreUrl::parse("s3://bucket?foo=bar").unwrap_err();
296-
assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?foo=bar");
301+
assert_eq!(
302+
err.strip_backtrace(),
303+
"Execution error: ObjectStoreUrl must only contain scheme and authority, got: ?foo=bar"
304+
);
297305

298306
let err = ObjectStoreUrl::parse("s3://host:123/foo").unwrap_err();
299-
assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo");
307+
assert_eq!(
308+
err.strip_backtrace(),
309+
"Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo"
310+
);
300311

301312
let err =
302313
ObjectStoreUrl::parse("s3://username:password@host:123/foo").unwrap_err();
303-
assert_eq!(err.strip_backtrace(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo");
314+
assert_eq!(
315+
err.strip_backtrace(),
316+
"Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo"
317+
);
304318
}
305319

306320
#[test]

datafusion/execution/src/runtime_env.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::{
3131
use crate::cache::cache_manager::{CacheManager, CacheManagerConfig};
3232
#[cfg(feature = "parquet_encryption")]
3333
use crate::parquet_encryption::{EncryptionFactory, EncryptionFactoryRegistry};
34-
use datafusion_common::{config::ConfigEntry, Result};
34+
use datafusion_common::{Result, config::ConfigEntry};
3535
use object_store::ObjectStore;
3636
use std::path::PathBuf;
3737
use std::sync::Arc;
@@ -122,7 +122,7 @@ fn create_runtime_config_entries(
122122
key: "datafusion.runtime.metadata_cache_limit".to_string(),
123123
value: metadata_cache_limit,
124124
description: "Maximum memory to use for file metadata cache such as Parquet metadata. Supports suffixes K (kilobytes), M (megabytes), and G (gigabytes). Example: '2G' for 2 gigabytes.",
125-
}
125+
},
126126
]
127127
}
128128

datafusion/execution/src/task.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::{
1919
config::SessionConfig, memory_pool::MemoryPool, registry::FunctionRegistry,
2020
runtime_env::RuntimeEnv,
2121
};
22-
use datafusion_common::{internal_datafusion_err, plan_datafusion_err, Result};
22+
use datafusion_common::{Result, internal_datafusion_err, plan_datafusion_err};
2323
use datafusion_expr::planner::ExprPlanner;
2424
use datafusion_expr::{AggregateUDF, ScalarUDF, WindowUDF};
2525
use std::collections::HashSet;

0 commit comments

Comments
 (0)