You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by mb...@apache.org on 2025/06/16 09:06:25 UTC
(arrow-rs) branch main updated: Remove `lazy_static` dependency (#7669)
This is an automated email from the ASF dual-hosted git repository.
mbrobbel pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/arrow-rs.git
The following commit(s) were added to refs/heads/main by this push:
new 58b34cbabb Remove `lazy_static` dependency (#7669)
58b34cbabb is described below
commit 58b34cbabbb431d33a592e216579ec24a18b8d38
Author: Expyron <51...@users.noreply.github.com>
AuthorDate: Mon Jun 16 11:06:20 2025 +0200
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.
---
arrow-csv/Cargo.toml | 1 -
arrow-csv/src/reader/mod.rs | 18 +++++++++---------
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/arrow-csv/Cargo.toml b/arrow-csv/Cargo.toml
index a9de0e634c..c44ec01ce3 100644
--- a/arrow-csv/Cargo.toml
+++ b/arrow-csv/Cargo.toml
@@ -42,7 +42,6 @@ arrow-schema = { workspace = true }
chrono = { workspace = true }
csv = { version = "1.1", default-features = false }
csv-core = { version = "0.1" }
-lazy_static = { version = "1.4", default-features = false }
regex = { version = "1.7.0", default-features = false, features = ["std", "unicode", "perf"] }
[dev-dependencies]
diff --git a/arrow-csv/src/reader/mod.rs b/arrow-csv/src/reader/mod.rs
index 5440c7a86b..e9f612557e 100644
--- a/arrow-csv/src/reader/mod.rs
+++ b/arrow-csv/src/reader/mod.rs
@@ -132,30 +132,30 @@ use arrow_cast::parse::{parse_decimal, string_to_datetime, Parser};
use arrow_schema::*;
use chrono::{TimeZone, Utc};
use csv::StringRecord;
-use lazy_static::lazy_static;
use regex::{Regex, RegexSet};
use std::fmt::{self, Debug};
use std::fs::File;
use std::io::{BufRead, BufReader as StdBufReader, Read};
-use std::sync::Arc;
+use std::sync::{Arc, LazyLock};
use crate::map_csv_error;
use crate::reader::records::{RecordDecoder, StringRecords};
use arrow_array::timezone::Tz;
-lazy_static! {
- /// Order should match [`InferredDataType`]
- static ref REGEX_SET: RegexSet = RegexSet::new([
+/// Order should match [`InferredDataType`]
+static REGEX_SET: LazyLock<RegexSet> = LazyLock::new(|| {
+ RegexSet::new([
r"(?i)^(true)$|^(false)$(?-i)", //BOOLEAN
- r"^-?(\d+)$", //INTEGER
+ r"^-?(\d+)$", //INTEGER
r"^-?((\d*\.\d+|\d+\.\d*)([eE][-+]?\d+)?|\d+([eE][-+]?\d+))$", //DECIMAL
- r"^\d{4}-\d\d-\d\d$", //DATE32
+ r"^\d{4}-\d\d-\d\d$", //DATE32
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d(?:[^\d\.].*)?$", //Timestamp(Second)
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d\.\d{1,3}(?:[^\d].*)?$", //Timestamp(Millisecond)
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d\.\d{1,6}(?:[^\d].*)?$", //Timestamp(Microsecond)
r"^\d{4}-\d\d-\d\d[T ]\d\d:\d\d:\d\d\.\d{1,9}(?:[^\d].*)?$", //Timestamp(Nanosecond)
- ]).unwrap();
-}
+ ])
+ .unwrap()
+});
/// A wrapper over `Option<Regex>` to check if the value is `NULL`.
#[derive(Debug, Clone, Default)]