Crates.io | datafusion-objectstore-hdfs-no-test |
lib.rs | datafusion-objectstore-hdfs-no-test |
version | 0.1.6 |
source | src |
created_at | 2023-09-10 10:45:36.881954 |
updated_at | 2023-09-11 06:02:41.890091 |
description | A hdfs object store implemented the object store without zip test |
homepage | |
repository | https://github.com/momhiar/datafusion-objectstore-hdfs-no-zip |
max_upload_size | |
id | 968748 |
size | 30,907 |
HDFS as a remote ObjectStore for Datafusion.
This crate introduces HadoopFileSystem
as a remote ObjectStore which provides the ability of querying on HDFS files.
For the HDFS access, We leverage the library fs-hdfs. Basically, the library only provides Rust FFI APIs for the libhdfs
which can be compiled by a set of C files provided by the official Hadoop Community.
Since the libhdfs
is also just a C interface wrapper and the real implementation for the HDFS access is a set of Java jars, in order to make this crate work, we need to prepare the Hadoop client jars and the JRE environment.
Install Java.
Specify and export JAVA_HOME
.
To get a Hadoop distribution, download a recent stable release from one of the Apache Download Mirrors. Currently, we support Hadoop-2 and Hadoop-3.
Unpack the downloaded Hadoop distribution. For example, the folder is /opt/hadoop. Then prepare some environment variables:
export HADOOP_HOME=/opt/hadoop
export PATH=$PATH:$HADOOP_HOME/bin
export DYLD_LIBRARY_PATH=$JAVA_HOME/jre/lib/server
export CLASSPATH=$CLASSPATH:`hadoop classpath --glob`
Suppose there's a hdfs directory,
let hdfs_file_uri = "hdfs://localhost:8020/testing/tpch_1g/parquet/line_item";
in which there're a list of parquet files. Then we can query on these parquet files as follows:
let ctx = SessionContext::new();
let url = Url::parse("hdfs://").unwrap();
ctx.runtime_env().register_object_store(&url, Arc::new(HadoopFileSystem));
let table_name = "line_item";
println!(
"Register table {} with parquet file {}",
table_name, hdfs_file_uri
);
ctx.register_parquet(table_name, &hdfs_file_uri, ParquetReadOptions::default()).await?;
let sql = "SELECT count(*) FROM line_item";
let result = ctx.sql(sql).await?.collect().await?;
git submodule update --init --recursive
cargo test
During the testing, a HDFS cluster will be mocked and started automatically.
cargo build --no-default-features --features datafusion-objectstore-hdfs/hdfs3,datafusion-objectstore-hdfs-testing/hdfs3,datafusion-hdfs-examples/hdfs3
cargo test --no-default-features --features datafusion-objectstore-hdfs/hdfs3,datafusion-objectstore-hdfs-testing/hdfs3,datafusion-hdfs-examples/hdfs3
Run the ballista-sql test by
cargo run --bin ballista-sql --no-default-features --features hdfs3