Skip to content

Commit ba419f8

Browse files
committed
remove lazylock
1 parent 0d7d9c8 commit ba419f8

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/common_union.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::collections::HashMap;
2-
use std::sync::{Arc, LazyLock, OnceLock};
2+
use std::sync::{Arc, OnceLock};
33

44
use datafusion::arrow::array::{
55
Array, ArrayRef, AsArray, BooleanArray, Float64Array, Int64Array, NullArray, StringArray, UnionArray,
@@ -155,13 +155,12 @@ const TYPE_ID_STR: i8 = 4;
155155
const TYPE_ID_ARRAY: i8 = 5;
156156
const TYPE_ID_OBJECT: i8 = 6;
157157

158-
static JSON_METADATA: LazyLock<HashMap<String, String>> =
159-
LazyLock::new(|| HashMap::from_iter(vec![("is_json".to_string(), "true".to_string())]));
160-
161158
fn union_fields() -> UnionFields {
162159
static FIELDS: OnceLock<UnionFields> = OnceLock::new();
163160
FIELDS
164161
.get_or_init(|| {
162+
let json_metadata: HashMap<String, String> =
163+
HashMap::from_iter(vec![("is_json".to_string(), "true".to_string())]);
165164
UnionFields::from_iter([
166165
(TYPE_ID_NULL, Arc::new(Field::new("null", DataType::Null, true))),
167166
(TYPE_ID_BOOL, Arc::new(Field::new("bool", DataType::Boolean, false))),
@@ -170,11 +169,11 @@ fn union_fields() -> UnionFields {
170169
(TYPE_ID_STR, Arc::new(Field::new("str", DataType::Utf8, false))),
171170
(
172171
TYPE_ID_ARRAY,
173-
Arc::new(Field::new("array", DataType::Utf8, false).with_metadata(JSON_METADATA.clone())),
172+
Arc::new(Field::new("array", DataType::Utf8, false).with_metadata(json_metadata.clone())),
174173
),
175174
(
176175
TYPE_ID_OBJECT,
177-
Arc::new(Field::new("object", DataType::Utf8, false).with_metadata(JSON_METADATA.clone())),
176+
Arc::new(Field::new("object", DataType::Utf8, false).with_metadata(json_metadata.clone())),
178177
),
179178
])
180179
})

0 commit comments

Comments
 (0)