From df30de261bfc15c9eec787d971ee5172647e8484 Mon Sep 17 00:00:00 2001 From: Ruihang Xia Date: Fri, 12 Jan 2024 22:58:57 +0800 Subject: [PATCH] feat: add datafusion to the list Signed-off-by: Ruihang Xia --- datafusion/core/Cargo.toml | 7 ++++--- datafusion/core/src/datasource/listing/url.rs | 4 ++++ datafusion/wasmtest/Cargo.toml | 1 + datafusion/wasmtest/README.md | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/datafusion/core/Cargo.toml b/datafusion/core/Cargo.toml index 9de6a7f7d6a0..c2e8c2b44531 100644 --- a/datafusion/core/Cargo.toml +++ b/datafusion/core/Cargo.toml @@ -37,7 +37,7 @@ path = "src/lib.rs" # Used to enable the avro format avro = ["apache-avro", "num-traits", "datafusion-common/avro"] backtrace = ["datafusion-common/backtrace"] -compression = ["xz2", "bzip2", "flate2", "zstd", "async-compression"] +compression = ["xz2", "bzip2", "flate2", "zstd", "async-compression", "tokio-util"] crypto_expressions = ["datafusion-physical-expr/crypto_expressions", "datafusion-optimizer/crypto_expressions"] default = ["crypto_expressions", "encoding_expressions", "regex_expressions", "unicode_expressions", "compression", "parquet"] encoding_expressions = ["datafusion-physical-expr/encoding_expressions"] @@ -87,8 +87,8 @@ pin-project-lite = "^0.2.7" rand = { workspace = true } sqlparser = { workspace = true } tempfile = { workspace = true } -tokio = { version = "1.28", features = ["macros", "rt", "rt-multi-thread", "sync", "fs", "parking_lot"] } -tokio-util = { version = "0.7.4", features = ["io"] } +tokio = { version = "1.28", features = ["macros", "rt", "sync"] } +tokio-util = { version = "0.7.4", features = ["io"], optional = true } url = { workspace = true } uuid = { version = "1.0", features = ["v4"] } xz2 = { version = "0.1", optional = true } @@ -113,6 +113,7 @@ rust_decimal = { version = "1.27.0", features = ["tokio-pg"] } serde_json = { workspace = true } test-utils = { path = "../../test-utils" } thiserror = { workspace = true } +tokio = { version = "1.28", features = ["macros", "rt", "rt-multi-thread", "sync", "fs", "parking_lot"] } tokio-postgres = "0.7.7" [target.'cfg(not(target_os = "windows"))'.dev-dependencies] nix = { version = "0.27.1", features = ["fs"] } diff --git a/datafusion/core/src/datasource/listing/url.rs b/datafusion/core/src/datasource/listing/url.rs index 766dee7de901..6421edf77972 100644 --- a/datafusion/core/src/datasource/listing/url.rs +++ b/datafusion/core/src/datasource/listing/url.rs @@ -103,12 +103,14 @@ impl ListingTableUrl { let s = s.as_ref(); // This is necessary to handle the case of a path starting with a drive letter + #[cfg(not(target_arch = "wasm32"))] if std::path::Path::new(s).is_absolute() { return Self::parse_path(s); } match Url::parse(s) { Ok(url) => Self::try_new(url, None), + #[cfg(not(target_arch = "wasm32"))] Err(url::ParseError::RelativeUrlWithoutBase) => Self::parse_path(s), Err(e) => Err(DataFusionError::External(Box::new(e))), } @@ -146,6 +148,7 @@ impl ListingTableUrl { } /// Creates a new [`ListingTableUrl`] interpreting `s` as a filesystem path + #[cfg(not(target_arch = "wasm32"))] fn parse_path(s: &str) -> Result { let (path, glob) = match split_glob_expression(s) { Some((prefix, glob)) => { @@ -282,6 +285,7 @@ impl ListingTableUrl { } /// Creates a file URL from a potentially relative filesystem path +#[cfg(not(target_arch = "wasm32"))] fn url_from_filesystem_path(s: &str) -> Option { let path = std::path::Path::new(s); let is_dir = match path.exists() { diff --git a/datafusion/wasmtest/Cargo.toml b/datafusion/wasmtest/Cargo.toml index cc39cb031b54..e1664825f798 100644 --- a/datafusion/wasmtest/Cargo.toml +++ b/datafusion/wasmtest/Cargo.toml @@ -45,6 +45,7 @@ datafusion-physical-expr = { workspace = true } datafusion-sql = { workspace = true } datafusion-execution = { workspace = true } datafusion-physical-plan = { workspace = true } +datafusion = { path = "../core", default-features = false } # getrandom must be compiled with js feature getrandom = { version = "0.2.8", features = ["js"] } diff --git a/datafusion/wasmtest/README.md b/datafusion/wasmtest/README.md index c1624fb60fee..4af0f94db9e9 100644 --- a/datafusion/wasmtest/README.md +++ b/datafusion/wasmtest/README.md @@ -59,6 +59,7 @@ Then open http://localhost:8080/ in a web browser and check the console to see t The following DataFusion crates are verified to work in a wasm-pack environment using the default `wasm32-unknown-unknown` target: +- `datafusion` (datafusion-core) with default-features disabled to remove `bzip2-sys` from `async-compression` - `datafusion-common` with default-features disabled to remove the `parquet` dependency (see below) - `datafusion-expr` - `datafusion-execution`