Skip to content

Apache DataFusion SQL Query Engine

Minor: Move `ObjectStoreRegistry` to datafusion_execution crate (#5478)

Andrew Lamb55c7c4d8e9d6
diff --git a/datafusion-cli/Cargo.lock b/datafusion-cli/Cargo.lock
index 4c98ad11bb..784b470e2e 100644
--- a/datafusion-cli/Cargo.lock
+++ b/datafusion-cli/Cargo.lock
@@ -592,9 +592,9 @@ dependencies = [
[[package]]
name = "csv"
-version = "1.2.0"
+version = "1.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af91f40b7355f82b0a891f50e70399475945bb0b0da4f1700ce60761c9d3e359"
+checksum = "0b015497079b9a9d69c02ad25de6c0a6edef051ea6360a327d0bd05802ef64ad"
dependencies = [
"csv-core",
"itoa",
@@ -749,13 +749,16 @@ dependencies = [
name = "datafusion-execution"
version = "19.0.0"
dependencies = [
+ "dashmap",
"datafusion-common",
"datafusion-expr",
"hashbrown 0.13.2",
"log",
+ "object_store",
"parking_lot",
"rand",
"tempfile",
+ "url",
]
[[package]]
@@ -2171,18 +2174,18 @@ checksum = "e6b44e8fc93a14e66336d230954dda83d18b4605ccace8fe09bc7514a71ad0bc"
[[package]]
name = "serde"
-version = "1.0.152"
+version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bb7d1f0d3021d347a83e556fc4683dea2ea09d87bccdf88ff5c12545d89d5efb"
+checksum = "8cdd151213925e7f1ab45a9bbfb129316bd00799784b174b7cc7bcd16961c49e"
dependencies = [
"serde_derive",
]
[[package]]
name = "serde_derive"
-version = "1.0.152"
+version = "1.0.154"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "af487d118eecd09402d70a5d72551860e788df87b464af30e5ea6a38c75c541e"
+checksum = "4fc80d722935453bcafdc2c9a73cd6fac4dc1938f0346035d84bf99fa9e33217"
dependencies = [
"proc-macro2",
"quote",
@@ -2568,9 +2571,9 @@ checksum = "497961ef93d974e23eb6f433eb5fe1b7930b659f06d12dec6fc44a8f554c0bba"
[[package]]
name = "unicode-bidi"
-version = "0.3.10"
+version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d54675592c1dbefd78cbd98db9bacd89886e1ca50692a0692baefffdeb92dd58"
+checksum = "524b68aca1d05e03fdf03fcdce2c6c94b6daf6d16861ddaa7e4f2b6638a9052c"
[[package]]
name = "unicode-ident"
diff --git a/datafusion/core/src/datasource/listing/mod.rs b/datafusion/core/src/datasource/listing/mod.rs
index 27cf141226..d5374d1edc 100644
--- a/datafusion/core/src/datasource/listing/mod.rs
+++ b/datafusion/core/src/datasource/listing/mod.rs
@@ -59,7 +59,7 @@ pub struct PartitionedFile {
pub partition_values: Vec<ScalarValue>,
/// An optional file range for a more fine-grained parallel execution
pub range: Option<FileRange>,
- /// An optional field for user defined per object metadata
+ /// An optional field for user defined per object metadata
pub extensions: Option<Arc<dyn std::any::Any + Send + Sync>>,
}
@@ -103,3 +103,52 @@ impl From<ObjectMeta> for PartitionedFile {
}
}
}
+
+#[cfg(test)]
+mod tests {
+ use datafusion_execution::object_store::ObjectStoreRegistry;
+ use object_store::local::LocalFileSystem;
+
+ use super::*;
+
+ #[test]
+ fn test_object_store_listing_url() {
+ let listing = ListingTableUrl::parse("file:///").unwrap();
+ let store = listing.object_store();
+ assert_eq!(store.as_str(), "file:///");
+
+ let listing = ListingTableUrl::parse("s3://bucket/").unwrap();
+ let store = listing.object_store();
+ assert_eq!(store.as_str(), "s3://bucket/");
+ }
+
+ #[test]
+ fn test_get_by_url_hdfs() {
+ let sut = ObjectStoreRegistry::default();
+ sut.register_store("hdfs", "localhost:8020", Arc::new(LocalFileSystem::new()));
+ let url = ListingTableUrl::parse("hdfs://localhost:8020/key").unwrap();
+ sut.get_by_url(&url).unwrap();
+ }
+
+ #[test]
+ fn test_get_by_url_s3() {
+ let sut = ObjectStoreRegistry::default();
+ sut.register_store("s3", "bucket", Arc::new(LocalFileSystem::new()));
+ let url = ListingTableUrl::parse("s3://bucket/key").unwrap();
+ sut.get_by_url(&url).unwrap();
+ }
+
+ #[test]
+ fn test_get_by_url_file() {
+ let sut = ObjectStoreRegistry::default();
+ let url = ListingTableUrl::parse("file:///bucket/key").unwrap();
+ sut.get_by_url(&url).unwrap();
+ }
+
+ #[test]
+ fn test_get_by_url_local() {
+ let sut = ObjectStoreRegistry::default();
+ let url = ListingTableUrl::parse("../").unwrap();
+ sut.get_by_url(&url).unwrap();
+ }
+}
diff --git a/datafusion/core/src/datasource/mod.rs b/datafusion/core/src/datasource/mod.rs
index a0d5121090..6fa15ab021 100644
--- a/datafusion/core/src/datasource/mod.rs
+++ b/datafusion/core/src/datasource/mod.rs
@@ -25,10 +25,12 @@ pub mod file_format;
pub mod listing;
pub mod listing_table_factory;
pub mod memory;
-pub mod object_store;
pub mod streaming;
pub mod view;
+// backwards compatibility
+pub use datafusion_execution::object_store;
+
use futures::Stream;
pub use self::datasource::TableProvider;
diff --git a/datafusion/core/src/execution/runtime_env.rs b/datafusion/core/src/execution/runtime_env.rs
index 1a738cdd32..a38d563fac 100644
--- a/datafusion/core/src/execution/runtime_env.rs
+++ b/datafusion/core/src/execution/runtime_env.rs
@@ -23,9 +23,11 @@ use crate::{
execution::disk_manager::{DiskManager, DiskManagerConfig},
};
-use crate::datasource::object_store::ObjectStoreRegistry;
-use crate::execution::memory_pool::{GreedyMemoryPool, MemoryPool, UnboundedMemoryPool};
use datafusion_common::DataFusionError;
+use datafusion_execution::{
+ memory_pool::{GreedyMemoryPool, MemoryPool, UnboundedMemoryPool},
+ object_store::ObjectStoreRegistry,
+};
use object_store::ObjectStore;
use std::fmt::{Debug, Formatter};
use std::path::PathBuf;
diff --git a/datafusion/execution/Cargo.toml b/datafusion/execution/Cargo.toml
index 3753d40df5..9e68acc7d9 100644
--- a/datafusion/execution/Cargo.toml
+++ b/datafusion/execution/Cargo.toml
@@ -34,10 +34,13 @@ path = "src/lib.rs"
[dependencies]
+dashmap = "5.4.0"
datafusion-common = { path = "../common", version = "19.0.0" }
datafusion-expr = { path = "../expr", version = "19.0.0" }
hashbrown = { version = "0.13", features = ["raw"] }
log = "^0.4"
+object_store = "0.5.4"
parking_lot = "0.12"
rand = "0.8"
tempfile = "3"
+url = "2.2"
diff --git a/datafusion/execution/src/lib.rs b/datafusion/execution/src/lib.rs
index b8e6debb92..55db55cf0a 100644
--- a/datafusion/execution/src/lib.rs
+++ b/datafusion/execution/src/lib.rs
@@ -17,4 +17,5 @@
pub mod disk_manager;
pub mod memory_pool;
+pub mod object_store;
pub mod registry;
diff --git a/datafusion/core/src/datasource/object_store.rs b/datafusion/execution/src/object_store.rs
similarity index 87%
rename from datafusion/core/src/datasource/object_store.rs
rename to datafusion/execution/src/object_store.rs
index 8f1fc30f97..9c5cca8479 100644
--- a/datafusion/core/src/datasource/object_store.rs
+++ b/datafusion/execution/src/object_store.rs
@@ -217,22 +217,12 @@ impl ObjectStoreRegistry {
#[cfg(test)]
mod tests {
use super::*;
- use crate::datasource::listing::ListingTableUrl;
- use std::sync::Arc;
#[test]
fn test_object_store_url() {
- let listing = ListingTableUrl::parse("file:///").unwrap();
- let store = listing.object_store();
- assert_eq!(store.as_str(), "file:///");
-
let file = ObjectStoreUrl::parse("file://").unwrap();
assert_eq!(file.as_str(), "file:///");
- let listing = ListingTableUrl::parse("s3://bucket/").unwrap();
- let store = listing.object_store();
- assert_eq!(store.as_str(), "s3://bucket/");
-
let url = ObjectStoreUrl::parse("s3://bucket").unwrap();
assert_eq!(url.as_str(), "s3://bucket/");
@@ -255,34 +245,4 @@ mod tests {
ObjectStoreUrl::parse("s3://username:password@host:123/foo").unwrap_err();
assert_eq!(err.to_string(), "Execution error: ObjectStoreUrl must only contain scheme and authority, got: /foo");
}
-
- #[test]
- fn test_get_by_url_hdfs() {
- let sut = ObjectStoreRegistry::default();
- sut.register_store("hdfs", "localhost:8020", Arc::new(LocalFileSystem::new()));
- let url = ListingTableUrl::parse("hdfs://localhost:8020/key").unwrap();
- sut.get_by_url(&url).unwrap();
- }
-
- #[test]
- fn test_get_by_url_s3() {
- let sut = ObjectStoreRegistry::default();
- sut.register_store("s3", "bucket", Arc::new(LocalFileSystem::new()));
- let url = ListingTableUrl::parse("s3://bucket/key").unwrap();
- sut.get_by_url(&url).unwrap();
- }
-
- #[test]
- fn test_get_by_url_file() {
- let sut = ObjectStoreRegistry::default();
- let url = ListingTableUrl::parse("file:///bucket/key").unwrap();
- sut.get_by_url(&url).unwrap();
- }
-
- #[test]
- fn test_get_by_url_local() {
- let sut = ObjectStoreRegistry::default();
- let url = ListingTableUrl::parse("../").unwrap();
- sut.get_by_url(&url).unwrap();
- }
}