The DataFusion CLI is a command-line interactive SQL utility that allows queries to be executed against CSV and Parquet files. It is a convenient way to try DataFusion out with your own data sources.
Use the following commands to clone this repository and run the CLI. This will require the Rust toolchain to be installed. Rust can be installed from https://rustup.rs/.
git clone https://github.com/apache/arrow cd arrow/rust/datafusion cargo run --bin datafusion-cli --release
Use the following commands to clone this repository and build a Docker image containing the CLI tool. Note that there is .dockerignore
file in the root of the repository that may need to be deleted in order for this to work.
git clone https://github.com/apache/arrow cd arrow docker build -f rust/datafusion/Dockerfile . --tag datafusion-cli docker run -it -v $(your_data_location):/data datafusion-cli
USAGE: datafusion-cli [OPTIONS] FLAGS: -h, --help Prints help information -V, --version Prints version information OPTIONS: -c, --batch-size <batch-size> The batch size of each query, default value is 1048576 -p, --data-path <data-path> Path to your data, default to current directory
Type exit
or quit
to exit the CLI.
Parquet data sources can be registered by executing a CREATE EXTERNAL TABLE
SQL statement. It is not necessary to provide schema information for Parquet files.
CREATE EXTERNAL TABLE taxi STORED AS PARQUET LOCATION '/mnt/nyctaxi/tripdata.parquet';
CSV data sources can be registered by executing a CREATE EXTERNAL TABLE
SQL statement. It is necessary to provide schema information for CSV files since DataFusion does not automatically infer the schema when using SQL to query CSV files.
CREATE EXTERNAL TABLE test ( c1 VARCHAR NOT NULL, c2 INT NOT NULL, c3 SMALLINT NOT NULL, c4 SMALLINT NOT NULL, c5 INT NOT NULL, c6 BIGINT NOT NULL, c7 SMALLINT NOT NULL, c8 INT NOT NULL, c9 BIGINT NOT NULL, c10 VARCHAR NOT NULL, c11 FLOAT NOT NULL, c12 DOUBLE NOT NULL, c13 VARCHAR NOT NULL ) STORED AS CSV WITH HEADER ROW LOCATION '/path/to/aggregate_test_100.csv';