This is an automated email from the ASF dual-hosted git repository.
Jefffrey 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 d3363e7308 deps: removed unneeded once_cell dependency if favor of
std::sync::LazyLock (#11066)
d3363e7308 is described below
commit d3363e7308bd8e149fa8d64d8d181c659262c387
Author: Egor Markov <[email protected]>
AuthorDate: Tue Sep 15 06:40:50 2026 +0300
deps: removed unneeded once_cell dependency if favor of std::sync::LazyLock
(#11066)
# Rationale for this change
There is no reason to keep external crate dependency since the same
functionality is included in std.
# What changes are included in this PR?
Drop-in replacements of `once_cell::sync::Lazy` to `std::sync::LazyLock`
# Are these changes tested?
Not needed, functionality not changed
# Are there any user-facing changes?
No user-facing changes
---
Cargo.lock | 2 --
arrow-avro/Cargo.toml | 1 -
arrow-avro/benches/avro_writer.rs | 47 ++++++++++++++--------------
arrow-avro/benches/decoder.rs | 6 ++--
arrow-avro/benches/encoder.rs | 7 ++---
arrow-flight/Cargo.toml | 3 +-
arrow-flight/examples/flight_sql_server.rs | 9 +++---
arrow-flight/src/sql/metadata/catalogs.rs | 5 ++-
arrow-flight/src/sql/metadata/db_schemas.rs | 5 ++-
arrow-flight/src/sql/metadata/sql_info.rs | 7 ++---
arrow-flight/src/sql/metadata/table_types.rs | 5 ++-
arrow-flight/src/sql/metadata/tables.rs | 7 ++---
arrow-flight/src/sql/metadata/xdbc_info.rs | 7 ++---
13 files changed, 49 insertions(+), 62 deletions(-)
diff --git a/Cargo.lock b/Cargo.lock
index 651ea32938..08a3d64f12 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -258,7 +258,6 @@ dependencies = [
"liblzma",
"md5",
"object_store",
- "once_cell",
"rand 0.10.2",
"serde",
"serde_json",
@@ -372,7 +371,6 @@ dependencies = [
"http",
"http-body",
"hyper-util",
- "once_cell",
"pin-project-lite",
"prost",
"prost-types",
diff --git a/arrow-avro/Cargo.toml b/arrow-avro/Cargo.toml
index d776a20a56..bfdeb74903 100644
--- a/arrow-avro/Cargo.toml
+++ b/arrow-avro/Cargo.toml
@@ -95,7 +95,6 @@ futures = "0.3.31"
async-stream = "0.3.6"
apache-avro = "0.22.0"
object_store = { workspace = true, features = ["fs"] }
-once_cell = "1.21.3"
half = { version = "2.1", default-features = false }
tokio = { version = "1.0", default-features = false, features = ["macros",
"rt-multi-thread", "io-util", "fs"] }
diff --git a/arrow-avro/benches/avro_writer.rs
b/arrow-avro/benches/avro_writer.rs
index 397bbce34a..f7eea8983a 100644
--- a/arrow-avro/benches/avro_writer.rs
+++ b/arrow-avro/benches/avro_writer.rs
@@ -29,16 +29,15 @@ use arrow_avro::writer::AvroWriter;
use arrow_buffer::{Buffer, i256};
use arrow_schema::{DataType, Field, IntervalUnit, Schema, TimeUnit,
UnionFields, UnionMode};
use criterion::{BatchSize, BenchmarkId, Criterion, Throughput,
criterion_group, criterion_main};
-use once_cell::sync::Lazy;
use rand::{
RngExt, SeedableRng,
distr::uniform::{SampleRange, SampleUniform},
rngs::StdRng,
};
-use std::collections::HashMap;
use std::io::Cursor;
use std::sync::Arc;
use std::time::Duration;
+use std::{collections::HashMap, sync::LazyLock};
use tempfile::tempfile;
const SIZES: [usize; 4] = [4_096, 8_192, 100_000, 1_000_000];
@@ -371,7 +370,7 @@ fn schema_decimal_with_size(name: &str, dt: DataType,
size_meta: Option<usize>)
Arc::new(Schema::new(vec![field]))
}
-static BOOLEAN_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static BOOLEAN_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_single("field1", DataType::Boolean);
SIZES
.iter()
@@ -382,7 +381,7 @@ static BOOLEAN_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static INT32_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static INT32_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_single("field1", DataType::Int32);
SIZES
.iter()
@@ -393,7 +392,7 @@ static INT32_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static INT64_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static INT64_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_single("field1", DataType::Int64);
SIZES
.iter()
@@ -404,7 +403,7 @@ static INT64_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static FLOAT32_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static FLOAT32_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_single("field1", DataType::Float32);
SIZES
.iter()
@@ -415,7 +414,7 @@ static FLOAT32_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static FLOAT64_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static FLOAT64_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_single("field1", DataType::Float64);
SIZES
.iter()
@@ -426,7 +425,7 @@ static FLOAT64_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static BINARY_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static BINARY_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_single("field1", DataType::Binary);
SIZES
.iter()
@@ -437,7 +436,7 @@ static BINARY_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static FIXED16_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static FIXED16_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_fixed16();
SIZES
.iter()
@@ -448,7 +447,7 @@ static FIXED16_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static UUID16_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static UUID16_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_uuid16();
SIZES
.iter()
@@ -460,7 +459,7 @@ static UUID16_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static INTERVAL_MDN_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static INTERVAL_MDN_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_interval_mdn();
SIZES
.iter()
@@ -471,7 +470,7 @@ static INTERVAL_MDN_DATA: Lazy<Vec<RecordBatch>> =
Lazy::new(|| {
.collect()
});
-static TIMESTAMP_US_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static TIMESTAMP_US_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_single("field1",
DataType::Timestamp(TimeUnit::Microsecond, None));
SIZES
.iter()
@@ -482,7 +481,7 @@ static TIMESTAMP_US_DATA: Lazy<Vec<RecordBatch>> =
Lazy::new(|| {
.collect()
});
-static MIXED_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static MIXED_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_mixed();
SIZES
.iter()
@@ -496,7 +495,7 @@ static MIXED_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static UTF8_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static UTF8_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let schema = schema_single("field1", DataType::Utf8);
SIZES
.iter()
@@ -507,7 +506,7 @@ static UTF8_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static LIST_UTF8_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static LIST_UTF8_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
// IMPORTANT: ListBuilder creates a child field named "item" that is
nullable by default.
// Make the schema's list item nullable to match the array we construct.
let item_field = Arc::new(Field::new("item", DataType::Utf8, true));
@@ -521,7 +520,7 @@ static LIST_UTF8_DATA: Lazy<Vec<RecordBatch>> =
Lazy::new(|| {
.collect()
});
-static STRUCT_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static STRUCT_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let struct_dt = DataType::Struct(
vec![
Field::new("s1", DataType::Utf8, false),
@@ -541,7 +540,7 @@ static STRUCT_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
});
#[cfg(feature = "small_decimals")]
-static DECIMAL32_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static DECIMAL32_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
// Choose a representative precision/scale within Decimal32 limits
let precision: u8 = 7;
let scale: i8 = 2;
@@ -557,7 +556,7 @@ static DECIMAL32_DATA: Lazy<Vec<RecordBatch>> =
Lazy::new(|| {
});
#[cfg(feature = "small_decimals")]
-static DECIMAL64_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static DECIMAL64_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let precision: u8 = 13;
let scale: i8 = 3;
let schema = schema_single("amount", DataType::Decimal64(precision,
scale));
@@ -571,7 +570,7 @@ static DECIMAL64_DATA: Lazy<Vec<RecordBatch>> =
Lazy::new(|| {
.collect()
});
-static DECIMAL128_BYTES_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static DECIMAL128_BYTES_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
let precision: u8 = 25;
let scale: i8 = 6;
let schema = schema_single("amount", DataType::Decimal128(precision,
scale));
@@ -585,7 +584,7 @@ static DECIMAL128_BYTES_DATA: Lazy<Vec<RecordBatch>> =
Lazy::new(|| {
.collect()
});
-static DECIMAL128_FIXED16_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static DECIMAL128_FIXED16_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
// Same logical type as above but force Avro fixed(16) via metadata
"size": "16"
let precision: u8 = 25;
let scale: i8 = 6;
@@ -601,7 +600,7 @@ static DECIMAL128_FIXED16_DATA: Lazy<Vec<RecordBatch>> =
Lazy::new(|| {
.collect()
});
-static DECIMAL256_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static DECIMAL256_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
// Use a higher precision typical of 256-bit decimals
let precision: u8 = 50;
let scale: i8 = 10;
@@ -616,7 +615,7 @@ static DECIMAL256_DATA: Lazy<Vec<RecordBatch>> =
Lazy::new(|| {
.collect()
});
-static MAP_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static MAP_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
use arrow_array::builder::{MapBuilder, StringBuilder};
let key_field = Arc::new(Field::new(
@@ -660,7 +659,7 @@ static MAP_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static ENUM_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static ENUM_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
// To represent an Avro enum, the Arrow writer expects a Dictionary<Int32,
Utf8>
// field with metadata specifying the enum symbols.
let enum_symbols = r#"["RED", "GREEN", "BLUE"]"#;
@@ -690,7 +689,7 @@ static ENUM_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
.collect()
});
-static UNION_DATA: Lazy<Vec<RecordBatch>> = Lazy::new(|| {
+static UNION_DATA: LazyLock<Vec<RecordBatch>> = LazyLock::new(|| {
// Basic Dense Union of three types: Utf8, Int32, Float64
let union_fields = UnionFields::try_new(
vec![0, 1, 2],
diff --git a/arrow-avro/benches/decoder.rs b/arrow-avro/benches/decoder.rs
index b91994afce..9bbf50739b 100644
--- a/arrow-avro/benches/decoder.rs
+++ b/arrow-avro/benches/decoder.rs
@@ -24,7 +24,7 @@ use apache_avro::{Decimal, Schema as ApacheSchema};
use arrow_avro::schema::{CONFLUENT_MAGIC, Fingerprint, FingerprintAlgorithm,
SINGLE_OBJECT_MAGIC};
use arrow_avro::{reader::ReaderBuilder, schema::AvroSchema};
use criterion::{BatchSize, BenchmarkId, Criterion, Throughput,
criterion_group, criterion_main};
-use once_cell::sync::Lazy;
+use std::sync::LazyLock;
use std::{hint::black_box, time::Duration};
use uuid::Uuid;
@@ -448,7 +448,7 @@ const SPARSE_NEST_SCHEMA: &str =
r#"{"type":"record","name":"SparseNestRec","fie
macro_rules! dataset {
($name:ident, $schema_json:expr, $gen_fn:ident) => {
- static $name: Lazy<Vec<Vec<u8>>> = Lazy::new(|| {
+ static $name: LazyLock<Vec<Vec<u8>>> = LazyLock::new(|| {
let schema =
ApacheSchema::parse_str($schema_json).expect("invalid schema
for generator");
let arrow_schema = AvroSchema::new($schema_json.parse().unwrap());
@@ -467,7 +467,7 @@ macro_rules! dataset {
/// Additional helper for Confluent's ID-based wire format (00 + BE u32).
macro_rules! dataset_id {
($name:ident, $schema_json:expr, $gen_fn:ident, $id:expr) => {
- static $name: Lazy<Vec<Vec<u8>>> = Lazy::new(|| {
+ static $name: LazyLock<Vec<Vec<u8>>> = LazyLock::new(|| {
let schema =
ApacheSchema::parse_str($schema_json).expect("invalid schema
for generator");
let prefix = make_prefix(Fingerprint::Id($id));
diff --git a/arrow-avro/benches/encoder.rs b/arrow-avro/benches/encoder.rs
index 2e0a7d1a3e..1e9df7ec14 100644
--- a/arrow-avro/benches/encoder.rs
+++ b/arrow-avro/benches/encoder.rs
@@ -22,16 +22,15 @@ use arrow_avro::writer::format::AvroSoeFormat;
use arrow_avro::writer::{EncodedRows, WriterBuilder};
use arrow_schema::{DataType, Field, Schema};
use criterion::{BenchmarkId, Criterion, Throughput, criterion_group,
criterion_main};
-use once_cell::sync::Lazy;
use std::hint::black_box;
-use std::sync::Arc;
+use std::sync::{Arc, LazyLock};
use std::time::Duration;
const SIZES: [usize; 4] = [1_000, 10_000, 100_000, 1_000_000];
/// Pre-generate EncodedRows for each size to avoid setup overhead in
benchmarks.
-static ENCODED_DATA: Lazy<Vec<EncodedRows>> =
- Lazy::new(|| SIZES.iter().map(|&n| make_encoded_rows(n)).collect());
+static ENCODED_DATA: LazyLock<Vec<EncodedRows>> =
+ LazyLock::new(|| SIZES.iter().map(|&n| make_encoded_rows(n)).collect());
/// Create an EncodedRows with `n` rows of Int32 data.
fn make_encoded_rows(n: usize) -> EncodedRows {
diff --git a/arrow-flight/Cargo.toml b/arrow-flight/Cargo.toml
index 763c73efef..4c47d4f338 100644
--- a/arrow-flight/Cargo.toml
+++ b/arrow-flight/Cargo.toml
@@ -42,7 +42,6 @@ arrow-string = { workspace = true, optional = true }
base64 = { version = "0.23", default-features = false, features = ["std"] }
bytes = { version = "1", default-features = false }
futures = { version = "0.3", default-features = false, features = ["alloc"] }
-once_cell = { version = "1", optional = true }
prost = { version = "0.14.1", default-features = false, features = ["derive"] }
# For Timestamp type
prost-types = { version = "0.14.1", default-features = false }
@@ -61,7 +60,7 @@ all-features = true
[features]
default = []
-flight-sql = ["dep:arrow-arith", "dep:arrow-ord", "dep:arrow-row",
"dep:arrow-select", "dep:arrow-string", "dep:once_cell"]
+flight-sql = ["dep:arrow-arith", "dep:arrow-ord", "dep:arrow-row",
"dep:arrow-select", "dep:arrow-string"]
tls-aws-lc= ["tonic/tls-aws-lc"]
tls-native-roots = ["tonic/tls-native-roots"]
tls-ring = ["tonic/tls-ring"]
diff --git a/arrow-flight/examples/flight_sql_server.rs
b/arrow-flight/examples/flight_sql_server.rs
index 6f31070ab9..f85e1ee280 100644
--- a/arrow-flight/examples/flight_sql_server.rs
+++ b/arrow-flight/examples/flight_sql_server.rs
@@ -21,12 +21,11 @@ use base64::Engine;
use base64::prelude::BASE64_STANDARD;
use core::str;
use futures::{Stream, TryStreamExt, stream};
-use once_cell::sync::Lazy;
use prost::Message;
use std::collections::HashSet;
use std::pin::Pin;
use std::str::FromStr;
-use std::sync::Arc;
+use std::sync::{Arc, LazyLock};
use tonic::metadata::MetadataValue;
use tonic::transport::Server;
use tonic::transport::{Certificate, Identity, ServerTlsConfig};
@@ -70,7 +69,7 @@ const FAKE_TOKEN: &str = "uuid_token";
const FAKE_HANDLE: &str = "uuid_handle";
const FAKE_UPDATE_RESULT: i64 = 1;
-static INSTANCE_SQL_DATA: Lazy<SqlInfoData> = Lazy::new(|| {
+static INSTANCE_SQL_DATA: LazyLock<SqlInfoData> = LazyLock::new(|| {
let mut builder = SqlInfoDataBuilder::new();
// Server information
builder.append(SqlInfo::FlightSqlServerName, "Example Flight SQL Server");
@@ -80,7 +79,7 @@ static INSTANCE_SQL_DATA: Lazy<SqlInfoData> = Lazy::new(|| {
builder.build().unwrap()
});
-static INSTANCE_XBDC_DATA: Lazy<XdbcTypeInfoData> = Lazy::new(|| {
+static INSTANCE_XBDC_DATA: LazyLock<XdbcTypeInfoData> = LazyLock::new(|| {
let mut builder = XdbcTypeInfoDataBuilder::new();
builder.append(XdbcTypeInfo {
type_name: "INTEGER".into(),
@@ -106,7 +105,7 @@ static INSTANCE_XBDC_DATA: Lazy<XdbcTypeInfoData> =
Lazy::new(|| {
builder.build().unwrap()
});
-static TABLES: Lazy<Vec<&'static str>> = Lazy::new(||
vec!["flight_sql.example.table"]);
+static TABLES: LazyLock<Vec<&'static str>> = LazyLock::new(||
vec!["flight_sql.example.table"]);
#[derive(Clone)]
pub struct FlightSqlServiceImpl {}
diff --git a/arrow-flight/src/sql/metadata/catalogs.rs
b/arrow-flight/src/sql/metadata/catalogs.rs
index e27c63c393..930fbab190 100644
--- a/arrow-flight/src/sql/metadata/catalogs.rs
+++ b/arrow-flight/src/sql/metadata/catalogs.rs
@@ -15,11 +15,10 @@
// specific language governing permissions and limitations
// under the License.
-use std::sync::Arc;
+use std::sync::{Arc, LazyLock};
use arrow_array::{RecordBatch, StringArray};
use arrow_schema::{DataType, Field, Schema, SchemaRef};
-use once_cell::sync::Lazy;
use crate::error::Result;
use crate::sql::CommandGetCatalogs;
@@ -92,7 +91,7 @@ fn get_catalogs_schema() -> SchemaRef {
}
/// The schema for GetCatalogs
-static GET_CATALOG_SCHEMA: Lazy<SchemaRef> = Lazy::new(|| {
+static GET_CATALOG_SCHEMA: LazyLock<SchemaRef> = LazyLock::new(|| {
Arc::new(Schema::new(vec![Field::new(
"catalog_name",
DataType::Utf8,
diff --git a/arrow-flight/src/sql/metadata/db_schemas.rs
b/arrow-flight/src/sql/metadata/db_schemas.rs
index c182140e58..3c1b7c6a87 100644
--- a/arrow-flight/src/sql/metadata/db_schemas.rs
+++ b/arrow-flight/src/sql/metadata/db_schemas.rs
@@ -19,7 +19,7 @@
//!
//! [`CommandGetDbSchemas`]: crate::sql::CommandGetDbSchemas
-use std::sync::Arc;
+use std::sync::{Arc, LazyLock};
use arrow_arith::boolean::and;
use arrow_array::{ArrayRef, RecordBatch, StringArray, builder::StringBuilder};
@@ -27,7 +27,6 @@ use arrow_ord::cmp::eq;
use arrow_schema::{DataType, Field, Schema, SchemaRef};
use arrow_select::{filter::filter_record_batch, take::take};
use arrow_string::like::like;
-use once_cell::sync::Lazy;
use super::lexsort_to_indices;
use crate::error::*;
@@ -175,7 +174,7 @@ fn get_db_schemas_schema() -> SchemaRef {
}
/// The schema for GetDbSchemas
-static GET_DB_SCHEMAS_SCHEMA: Lazy<SchemaRef> = Lazy::new(|| {
+static GET_DB_SCHEMAS_SCHEMA: LazyLock<SchemaRef> = LazyLock::new(|| {
Arc::new(Schema::new(vec![
Field::new("catalog_name", DataType::Utf8, true),
Field::new("db_schema_name", DataType::Utf8, false),
diff --git a/arrow-flight/src/sql/metadata/sql_info.rs
b/arrow-flight/src/sql/metadata/sql_info.rs
index 04bfc63cd5..1a7913cbaf 100644
--- a/arrow-flight/src/sql/metadata/sql_info.rs
+++ b/arrow-flight/src/sql/metadata/sql_info.rs
@@ -25,7 +25,7 @@
//!
use std::collections::{BTreeMap, HashMap};
-use std::sync::Arc;
+use std::sync::{Arc, LazyLock};
use arrow_arith::boolean::or;
use arrow_array::array::{Array, UInt32Array, UnionArray};
@@ -38,7 +38,6 @@ use arrow_data::ArrayData;
use arrow_ord::cmp::eq;
use arrow_schema::{DataType, Field, Fields, Schema, SchemaRef, UnionFields,
UnionMode};
use arrow_select::filter::filter_record_batch;
-use once_cell::sync::Lazy;
use crate::error::Result;
use crate::sql::{CommandGetSqlInfo, SqlInfo};
@@ -163,7 +162,7 @@ struct SqlInfoUnionBuilder {
}
/// [`DataType`] for the output union array
-static UNION_TYPE: Lazy<DataType> = Lazy::new(|| {
+static UNION_TYPE: LazyLock<DataType> = LazyLock::new(|| {
let fields = vec![
Field::new("string_value", DataType::Utf8, false),
Field::new("bool_value", DataType::Boolean, false),
@@ -460,7 +459,7 @@ impl GetSqlInfoBuilder<'_> {
}
// The schema produced by [`SqlInfoData`]
-static SQL_INFO_SCHEMA: Lazy<Schema> = Lazy::new(|| {
+static SQL_INFO_SCHEMA: LazyLock<Schema> = LazyLock::new(|| {
Schema::new(vec![
Field::new("info_name", DataType::UInt32, false),
Field::new("value", SqlInfoUnionBuilder::schema().clone(), false),
diff --git a/arrow-flight/src/sql/metadata/table_types.rs
b/arrow-flight/src/sql/metadata/table_types.rs
index 7f525da05f..c7c629a31f 100644
--- a/arrow-flight/src/sql/metadata/table_types.rs
+++ b/arrow-flight/src/sql/metadata/table_types.rs
@@ -19,12 +19,11 @@
//!
//! [`CommandGetTableTypes`]: crate::sql::CommandGetTableTypes
-use std::sync::Arc;
+use std::sync::{Arc, LazyLock};
use arrow_array::{ArrayRef, RecordBatch, builder::StringBuilder};
use arrow_schema::{DataType, Field, Schema, SchemaRef};
use arrow_select::take::take;
-use once_cell::sync::Lazy;
use crate::error::*;
use crate::sql::CommandGetTableTypes;
@@ -101,7 +100,7 @@ fn get_table_types_schema() -> SchemaRef {
}
/// The schema for [`CommandGetTableTypes`].
-static GET_TABLE_TYPES_SCHEMA: Lazy<SchemaRef> = Lazy::new(|| {
+static GET_TABLE_TYPES_SCHEMA: LazyLock<SchemaRef> = LazyLock::new(|| {
Arc::new(Schema::new(vec![Field::new(
"table_type",
DataType::Utf8,
diff --git a/arrow-flight/src/sql/metadata/tables.rs
b/arrow-flight/src/sql/metadata/tables.rs
index 7ab8bba955..a0fca4961a 100644
--- a/arrow-flight/src/sql/metadata/tables.rs
+++ b/arrow-flight/src/sql/metadata/tables.rs
@@ -19,7 +19,7 @@
//!
//! [`CommandGetTables`]: crate::sql::CommandGetTables
-use std::sync::Arc;
+use std::sync::{Arc, LazyLock};
use arrow_arith::boolean::{and, or};
use arrow_array::builder::{BinaryBuilder, StringBuilder};
@@ -28,7 +28,6 @@ use arrow_ord::cmp::eq;
use arrow_schema::{DataType, Field, Schema, SchemaRef};
use arrow_select::{filter::filter_record_batch, take::take};
use arrow_string::like::like;
-use once_cell::sync::Lazy;
use super::lexsort_to_indices;
use crate::error::*;
@@ -289,7 +288,7 @@ fn get_tables_schema(include_schema: bool) -> SchemaRef {
}
/// The schema for GetTables without `table_schema` column
-static GET_TABLES_SCHEMA_WITHOUT_TABLE_SCHEMA: Lazy<SchemaRef> = Lazy::new(|| {
+static GET_TABLES_SCHEMA_WITHOUT_TABLE_SCHEMA: LazyLock<SchemaRef> =
LazyLock::new(|| {
Arc::new(Schema::new(vec![
Field::new("catalog_name", DataType::Utf8, true),
Field::new("db_schema_name", DataType::Utf8, true),
@@ -299,7 +298,7 @@ static GET_TABLES_SCHEMA_WITHOUT_TABLE_SCHEMA:
Lazy<SchemaRef> = Lazy::new(|| {
});
/// The schema for GetTables with `table_schema` column
-static GET_TABLES_SCHEMA_WITH_TABLE_SCHEMA: Lazy<SchemaRef> = Lazy::new(|| {
+static GET_TABLES_SCHEMA_WITH_TABLE_SCHEMA: LazyLock<SchemaRef> =
LazyLock::new(|| {
Arc::new(Schema::new(vec![
Field::new("catalog_name", DataType::Utf8, true),
Field::new("db_schema_name", DataType::Utf8, true),
diff --git a/arrow-flight/src/sql/metadata/xdbc_info.rs
b/arrow-flight/src/sql/metadata/xdbc_info.rs
index 53ff16e9a4..583185244f 100644
--- a/arrow-flight/src/sql/metadata/xdbc_info.rs
+++ b/arrow-flight/src/sql/metadata/xdbc_info.rs
@@ -24,7 +24,7 @@
//! used for storing xdbc server metadata.
//! - [`GetXdbcTypeInfoBuilder`] - a builder for constructing
[`CommandGetXdbcTypeInfo`] responses.
//!
-use std::sync::Arc;
+use std::sync::{Arc, LazyLock};
use arrow_array::builder::{BooleanBuilder, Int32Builder, ListBuilder,
StringBuilder};
use arrow_array::{ArrayRef, Int32Array, ListArray, RecordBatch, Scalar};
@@ -32,7 +32,6 @@ use arrow_ord::cmp::eq;
use arrow_schema::{DataType, Field, Schema, SchemaRef};
use arrow_select::filter::filter_record_batch;
use arrow_select::take::take;
-use once_cell::sync::Lazy;
use super::lexsort_to_indices;
use crate::error::*;
@@ -119,7 +118,7 @@ impl XdbcTypeInfoData {
/// use arrow_flight::sql::{Nullable, Searchable, XdbcDataType};
/// use arrow_flight::sql::metadata::{XdbcTypeInfo, XdbcTypeInfoDataBuilder};
/// // Create the list of metadata describing the server. Since this would not
change at
-/// // runtime, using once_cell::Lazy or similar patterns to construct the
list is a common approach.
+/// // runtime, using LazyLock or similar patterns to construct the list is a
common approach.
/// let mut builder = XdbcTypeInfoDataBuilder::new();
/// builder.append(XdbcTypeInfo {
/// type_name: "INTEGER".into(),
@@ -321,7 +320,7 @@ impl GetXdbcTypeInfoBuilder<'_> {
}
/// The schema for GetXdbcTypeInfo
-static GET_XDBC_INFO_SCHEMA: Lazy<SchemaRef> = Lazy::new(|| {
+static GET_XDBC_INFO_SCHEMA: LazyLock<SchemaRef> = LazyLock::new(|| {
Arc::new(Schema::new(vec![
Field::new("type_name", DataType::Utf8, false),
Field::new("data_type", DataType::Int32, false),