Skip to content

Commit 58b34cb

Browse files
authored
Remove lazy_static dependency (#7669)
# Which issue does this PR close? None # Rationale for this change This removes a dependency by using the new LazyLock feature available since Rust 1.80. This crate already has an MSRV of 1.81, so this is not a breaking change. # Are there any user-facing changes? No user-facing changes.
1 parent 1029974 commit 58b34cb

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

arrow-csv/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ arrow-schema = { workspace = true }
4242
chrono = { workspace = true }
4343
csv = { version = "1.1", default-features = false }
4444
csv-core = { version = "0.1" }
45-
lazy_static = { version = "1.4", default-features = false }
4645
regex = { version = "1.7.0", default-features = false, features = ["std", "unicode", "perf"] }
4746

4847
[dev-dependencies]

arrow-csv/src/reader/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -132,30 +132,30 @@ use arrow_cast::parse::{parse_decimal, string_to_datetime, Parser};
132132
use arrow_schema::*;
133133
use chrono::{TimeZone, Utc};
134134
use csv::StringRecord;
135-
use lazy_static::lazy_static;
136135
use regex::{Regex, RegexSet};
137136
use std::fmt::{self, Debug};
138137
use std::fs::File;
139138
use std::io::{BufRead, BufReader as StdBufReader, Read};
140-
use std::sync::Arc;
139+
use std::sync::{Arc, LazyLock};
141140

142141
use crate::map_csv_error;
143142
use crate::reader::records::{RecordDecoder, StringRecords};
144143
use arrow_array::timezone::Tz;
145144

146-
lazy_static! {
147-
/// Order should match [`InferredDataType`]
148-
static ref REGEX_SET: RegexSet = RegexSet::new([
145+
/// Order should match [`InferredDataType`]
146+
static REGEX_SET: LazyLock<RegexSet> = LazyLock::new(|| {
147+
RegexSet::new([
149148
r"(?i)^(true)$|^(false)$(?-i)", //BOOLEAN
150-
r"^-?(\d+)$", //INTEGER
149+
r"^-?(\d+)$", //INTEGER
151150
r"^-?((\d*\.\d+|\d+\.\d*)([eE][-+]?\d+)?|\d+([eE][-+]?\d+))$", //DECIMAL
152-
r"^\d{4}-\d\d-\d\d$", //DATE32
151+
r"^\d{4}-\d\d-\d\d$", //DATE32
153152
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d(?:[^\d\.].*)?$", //Timestamp(Second)
154153
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d\.\d{1,3}(?:[^\d].*)?$", //Timestamp(Millisecond)
155154
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d\.\d{1,6}(?:[^\d].*)?$", //Timestamp(Microsecond)
156155
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d\.\d{1,9}(?:[^\d].*)?$", //Timestamp(Nanosecond)
157-
]).unwrap();
158-
}
156+
])
157+
.unwrap()
158+
});
159159

160160
/// A wrapper over `Option<Regex>` to check if the value is `NULL`.
161161
#[derive(Debug, Clone, Default)]

0 commit comments

Comments
 (0)