Skip to content

Commit 561c52e

Browse files
committed
chore: remove lazy_static & once_cell dependencies
LazyLock has been available since 1.80 which is less than MSRV Signed-off-by: Yuri Astrakhan <[email protected]>
1 parent 82ef6bf commit 561c52e

File tree

25 files changed

+294
-303
lines changed

25 files changed

+294
-303
lines changed

crates/aws/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ aws-credential-types = { version="1.2", features = ["hardcoded-credentials"]}
1919
aws-config = { version = "1.5", default-features = false, features = ["behavior-version-latest","rt-tokio", "credentials-process", "sso"] }
2020
aws-sdk-dynamodb = {version = "1.45", default-features = false, features = ["behavior-version-latest", "rt-tokio"] }
2121
aws-sdk-sts = {version = "1.42", default-features = false, features = ["behavior-version-latest", "rt-tokio"] }
22-
lazy_static = "1"
2322
maplit = "1"
2423

2524
# workspace dependencies

crates/aws/src/constants.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//! delta-rs
33
//!
44
5-
use lazy_static::lazy_static;
5+
use std::sync::LazyLock;
66
use std::time::Duration;
77

88
/// Custom S3 endpoint.
@@ -150,15 +150,15 @@ pub const STRING_TYPE: &str = "S";
150150
pub const KEY_TYPE_HASH: &str = "HASH";
151151
pub const KEY_TYPE_RANGE: &str = "RANGE";
152152

153-
lazy_static! {
154-
pub static ref CONDITION_EXPR_CREATE: String = format!(
155-
"attribute_not_exists({ATTR_TABLE_PATH}) and attribute_not_exists({ATTR_FILE_NAME})"
156-
);
153+
pub static CONDITION_EXPR_CREATE: LazyLock<String> = LazyLock::new(|| {
154+
format!("attribute_not_exists({ATTR_TABLE_PATH}) and attribute_not_exists({ATTR_FILE_NAME})")
155+
});
157156

158-
pub static ref CONDITION_DELETE_INCOMPLETE: String = format!(
159-
"(complete = :f) or (attribute_not_exists({ATTR_TABLE_PATH}) and attribute_not_exists({ATTR_FILE_NAME}))"
160-
);
161-
}
157+
pub static CONDITION_DELETE_INCOMPLETE: LazyLock<String> = LazyLock::new(|| {
158+
format!(
159+
"(complete = :f) or (attribute_not_exists({ATTR_TABLE_PATH}) and attribute_not_exists({ATTR_FILE_NAME}))"
160+
)
161+
});
162162

163163
pub const CONDITION_UPDATE_INCOMPLETE: &str = "complete = :f";
164164
pub const DEFAULT_COMMIT_ENTRY_EXPIRATION_DELAY: Duration = Duration::from_secs(86_400);

crates/aws/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ use deltalake_core::storage::object_store::aws::AmazonS3ConfigKey;
3030
use deltalake_core::storage::{factories, url_prefix_handler, ObjectStoreRef, StorageOptions};
3131
use deltalake_core::{DeltaResult, Path};
3232
use errors::{DynamoDbConfigError, LockClientError};
33-
use lazy_static::lazy_static;
3433
use regex::Regex;
3534
use std::{
3635
collections::HashMap,
3736
str::FromStr,
38-
sync::Arc,
37+
sync::{Arc, LazyLock},
3938
time::{Duration, SystemTime},
4039
};
4140
use storage::S3StorageOptionsConversion;
@@ -703,10 +702,9 @@ fn num_attr<T: ToString>(n: T) -> AttributeValue {
703702
AttributeValue::N(n.to_string())
704703
}
705704

706-
lazy_static! {
707-
static ref DELTA_LOG_PATH: Path = Path::from("_delta_log");
708-
static ref DELTA_LOG_REGEX: Regex = Regex::new(r"(\d{20})\.(json|checkpoint).*$").unwrap();
709-
}
705+
static DELTA_LOG_PATH: LazyLock<Path> = LazyLock::new(|| Path::from("_delta_log"));
706+
static DELTA_LOG_REGEX: LazyLock<Regex> =
707+
LazyLock::new(|| Regex::new(r"(\d{20})\.(json|checkpoint).*$").unwrap());
710708

711709
/// Extract version from a file name in the delta log
712710
fn extract_version_from_filename(name: &str) -> Option<i64> {

crates/aws/tests/integration_s3_dynamodb.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#![cfg(feature = "integration_test")]
44

55
use std::collections::HashMap;
6+
use std::sync::LazyLock;
67
use std::time::{Duration, SystemTime, UNIX_EPOCH};
78

89
use aws_sdk_dynamodb::types::BillingMode;
@@ -19,7 +20,6 @@ use deltalake_core::storage::StorageOptions;
1920
use deltalake_core::table::builder::ensure_table_uri;
2021
use deltalake_core::{DeltaOps, DeltaTable, DeltaTableBuilder, ObjectStoreError};
2122
use deltalake_test::utils::*;
22-
use lazy_static::lazy_static;
2323
use object_store::path::Path;
2424
use serde_json::Value;
2525
use serial_test::serial;
@@ -35,12 +35,13 @@ use common::*;
3535

3636
pub type TestResult<T> = Result<T, Box<dyn std::error::Error + 'static>>;
3737

38-
lazy_static! {
39-
static ref OPTIONS: HashMap<String, String> = maplit::hashmap! {
38+
static OPTIONS: LazyLock<HashMap<String, String>> = LazyLock::new(|| {
39+
hashmap! {
4040
"allow_http".to_owned() => "true".to_owned(),
41-
};
42-
static ref S3_OPTIONS: S3StorageOptions = S3StorageOptions::from_map(&OPTIONS).unwrap();
43-
}
41+
}
42+
});
43+
static S3_OPTIONS: LazyLock<S3StorageOptions> =
44+
LazyLock::new(|| S3StorageOptions::from_map(&OPTIONS).unwrap());
4445

4546
fn make_client() -> TestResult<DynamoDbLockClient> {
4647
let options: S3StorageOptions = S3StorageOptions::try_default().unwrap();

crates/azure/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ rust-version.workspace = true
1515
deltalake-core = { version = "0.24.0", path = "../core", features = [
1616
"datafusion",
1717
]}
18-
lazy_static = "1"
1918

2019
# workspace depenndecies
2120
async-trait = { workspace = true }

crates/azure/src/config.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66
//! way how we discover valid credentials and some heuristics on how they are prioritized.
77
use std::collections::{hash_map::Entry, HashMap};
88
use std::str::FromStr;
9+
use std::sync::LazyLock;
910

1011
use object_store::azure::AzureConfigKey;
1112
use object_store::Error as ObjectStoreError;
1213

1314
use crate::error::Result;
1415

15-
lazy_static::lazy_static! {
16-
static ref CREDENTIAL_KEYS: Vec<AzureConfigKey> =
16+
static CREDENTIAL_KEYS: LazyLock<Vec<AzureConfigKey>> = LazyLock::new(|| {
1717
Vec::from_iter([
1818
AzureConfigKey::ClientId,
1919
AzureConfigKey::ClientSecret,
@@ -23,8 +23,8 @@ lazy_static::lazy_static! {
2323
AzureConfigKey::MsiEndpoint,
2424
AzureConfigKey::ObjectId,
2525
AzureConfigKey::MsiResourceId,
26-
]);
27-
}
26+
])
27+
});
2828

2929
/// Credential
3030
enum AzureCredential {

crates/core/Cargo.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,10 @@ either = "1.8"
8484
fix-hidden-lifetime-bug = "0.2"
8585
indexmap = "2.2.1"
8686
itertools = "0.14"
87-
lazy_static = "1"
8887
libc = ">=0.2.90, <1"
8988
num-bigint = "0.4"
9089
num-traits = "0.2.15"
9190
object_store = { workspace = true }
92-
once_cell = "1.16.0"
9391
parking_lot = "0.12"
9492
percent-encoding = "2"
9593
roaring = "0.10.1"

crates/core/src/delta_datafusion/cdf/mod.rs

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
//! Logical operators and physical executions for CDF
22
use std::collections::HashMap;
3+
use std::sync::LazyLock;
34

45
use arrow_schema::{DataType, Field, TimeUnit};
5-
use lazy_static::lazy_static;
66

77
pub(crate) use self::scan::*;
88
pub(crate) use self::scan_utils::*;
@@ -19,25 +19,27 @@ pub const COMMIT_VERSION_COL: &str = "_commit_version";
1919
/// Commit Timestamp column name
2020
pub const COMMIT_TIMESTAMP_COL: &str = "_commit_timestamp";
2121

22-
lazy_static! {
23-
pub(crate) static ref CDC_PARTITION_SCHEMA: Vec<Field> = vec![
22+
pub(crate) static CDC_PARTITION_SCHEMA: LazyLock<Vec<Field>> = LazyLock::new(|| {
23+
vec![
2424
Field::new(COMMIT_VERSION_COL, DataType::Int64, true),
2525
Field::new(
2626
COMMIT_TIMESTAMP_COL,
2727
DataType::Timestamp(TimeUnit::Millisecond, None),
28-
true
29-
)
30-
];
31-
pub(crate) static ref ADD_PARTITION_SCHEMA: Vec<Field> = vec![
28+
true,
29+
),
30+
]
31+
});
32+
pub(crate) static ADD_PARTITION_SCHEMA: LazyLock<Vec<Field>> = LazyLock::new(|| {
33+
vec![
3234
Field::new(CHANGE_TYPE_COL, DataType::Utf8, true),
3335
Field::new(COMMIT_VERSION_COL, DataType::Int64, true),
3436
Field::new(
3537
COMMIT_TIMESTAMP_COL,
3638
DataType::Timestamp(TimeUnit::Millisecond, None),
37-
true
39+
true,
3840
),
39-
];
40-
}
41+
]
42+
});
4143

4244
#[derive(Debug)]
4345
pub(crate) struct CdcDataSpec<F: FileAction> {

crates/core/src/kernel/arrow/mod.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
//! Conversions between Delta and Arrow data types
22
3-
use std::sync::Arc;
3+
use std::sync::{Arc, LazyLock};
44

55
use arrow_schema::{
66
DataType as ArrowDataType, Field as ArrowField, FieldRef as ArrowFieldRef,
77
Schema as ArrowSchema, SchemaRef as ArrowSchemaRef,
88
};
9-
use lazy_static::lazy_static;
109

1110
pub(crate) mod extract;
1211
pub(crate) mod json;
@@ -184,8 +183,8 @@ pub(crate) fn delta_log_schema_for_table(
184183
partition_columns: &[String],
185184
use_extended_remove_schema: bool,
186185
) -> ArrowSchemaRef {
187-
lazy_static! {
188-
static ref SCHEMA_FIELDS: Vec<ArrowField> = arrow_defs![
186+
static SCHEMA_FIELDS: LazyLock<Vec<ArrowField>> = LazyLock::new(|| {
187+
arrow_defs![
189188
metaData[
190189
id:Utf8,
191190
name:Utf8,
@@ -206,8 +205,10 @@ pub(crate) fn delta_log_schema_for_table(
206205
appId:Utf8,
207206
version:Int64
208207
]
209-
];
210-
static ref ADD_FIELDS: Vec<ArrowField> = arrow_defs![
208+
]
209+
});
210+
static ADD_FIELDS: LazyLock<Vec<ArrowField>> = LazyLock::new(|| {
211+
arrow_defs![
211212
path:Utf8,
212213
size:Int64,
213214
modificationTime:Int64,
@@ -222,16 +223,18 @@ pub(crate) fn delta_log_schema_for_table(
222223
sizeInBytes:Int32 not_null,
223224
cardinality:Int64 not_null
224225
]
225-
];
226-
static ref REMOVE_FIELDS: Vec<ArrowField> = arrow_defs![
226+
]
227+
});
228+
static REMOVE_FIELDS: LazyLock<Vec<ArrowField>> = LazyLock::new(|| {
229+
arrow_defs![
227230
path: Utf8,
228231
deletionTimestamp: Int64,
229232
dataChange: Boolean,
230233
extendedFileMetadata: Boolean
231-
];
232-
static ref REMOVE_EXTENDED_FILE_METADATA_FIELDS: Vec<ArrowField> =
233-
arrow_defs![size: Int64, partitionValues, tags];
234-
};
234+
]
235+
});
236+
static REMOVE_EXTENDED_FILE_METADATA_FIELDS: LazyLock<Vec<ArrowField>> =
237+
LazyLock::new(|| arrow_defs![size: Int64, partitionValues, tags]);
235238

236239
// create add fields according to the specific data table schema
237240
let (partition_fields, non_partition_fields): (Vec<ArrowFieldRef>, Vec<ArrowFieldRef>) =

crates/core/src/kernel/mod.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
//! Delta Kernel module
22
//!
33
//! The Kernel module contains all the logic for reading and processing the Delta Lake transaction log.
4+
45
use delta_kernel::engine::arrow_expression::ArrowExpressionHandler;
6+
use std::sync::LazyLock;
57

68
pub mod arrow;
79
pub mod error;
@@ -21,6 +23,5 @@ pub trait DataCheck {
2123
fn get_expression(&self) -> &str;
2224
}
2325

24-
lazy_static::lazy_static! {
25-
static ref ARROW_HANDLER: ArrowExpressionHandler = ArrowExpressionHandler {};
26-
}
26+
static ARROW_HANDLER: LazyLock<ArrowExpressionHandler> =
27+
LazyLock::new(|| ArrowExpressionHandler {});

0 commit comments

Comments
 (0)