-
Notifications
You must be signed in to change notification settings - Fork 1.8k
User Guide: Combine CLI pages #3133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,25 +17,11 @@ | |
| under the License. | ||
| --> | ||
|
|
||
| # DataFusion Command-line Interface | ||
| # DataFusion Command-line SQL Utility | ||
|
|
||
| The DataFusion CLI allows SQL queries to be executed by an in-process DataFusion context. | ||
|
|
||
| ``` | ||
| USAGE: | ||
| datafusion-cli [FLAGS] [OPTIONS] | ||
|
|
||
| FLAGS: | ||
| -h, --help Prints help information | ||
| -q, --quiet Reduce printing other than the results and work quietly | ||
| -V, --version Prints version information | ||
|
|
||
| OPTIONS: | ||
| -c, --batch-size <batch-size> The batch size of each query, or use DataFusion default | ||
| -p, --data-path <data-path> Path to your data, default to current directory | ||
| -f, --file <file>... Execute commands from file(s), then exit | ||
| --format <format> Output format [default: table] [possible values: csv, tsv, table, json, ndjson] | ||
| ``` | ||
| The DataFusion CLI is a command-line interactive SQL utility that allows | ||
| queries to be executed against any supported data files. It is a convenient way to | ||
| try DataFusion out with your own data sources. | ||
|
|
||
| ## Example | ||
|
|
||
|
|
@@ -47,31 +33,125 @@ $ echo "1,2" > data.csv | |
|
|
||
| ```bash | ||
| $ datafusion-cli | ||
| DataFusion CLI v11.0.0 | ||
| ❯ CREATE EXTERNAL TABLE foo STORED AS CSV LOCATION 'data.csv'; | ||
| 0 rows in set. Query took 0.017 seconds. | ||
| ❯ select * from foo; | ||
| +----------+----------+ | ||
| | column_1 | column_2 | | ||
| +----------+----------+ | ||
| | 1 | 2 | | ||
| +----------+----------+ | ||
| 1 row in set. Query took 0.012 seconds. | ||
| ``` | ||
|
|
||
| ## Installation | ||
|
|
||
| DataFusion CLI v8.0.0 | ||
| ### Install and run using Cargo | ||
|
|
||
| > CREATE EXTERNAL TABLE foo (a INT, b INT) STORED AS CSV LOCATION 'data.csv'; | ||
| 0 rows in set. Query took 0.001 seconds. | ||
| The easiest way to install DataFusion CLI a spin is via `cargo install datafusion-cli`. | ||
|
|
||
| > SELECT * FROM foo; | ||
| +---+---+ | ||
| | a | b | | ||
| +---+---+ | ||
| | 1 | 2 | | ||
| +---+---+ | ||
| 1 row in set. Query took 0.017 seconds. | ||
| ### Install and run using Homebrew (on MacOS) | ||
|
|
||
| DataFusion CLI can also be installed via Homebrew (on MacOS). Install it as any other pre-built software like this: | ||
|
|
||
| ```bash | ||
| brew install datafusion | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TIL the homebrew formuale is still updated 🎉 10.0.0 👍 alamb@MacBook-Pro-8 datafusion-cli % brew install datafusion
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 3 taps (homebrew/core, homebrew/cask and homebrew/services).
==> New Formulae
cargo-crev crytic-compile git-sync lucky-commit slither-analyzer
censys gcc@11 [email protected] ouch solc-select
cql-proxy gcem libvatek rush-parallel svt-av1
==> New Casks
aliwangwang imhex moderndeck playcover-community yubihsm2-sdk
gittyup micromamba nanoem virtualbuddy
You have 28 outdated formulae installed.
You can upgrade them with brew upgrade
or list them with brew outdated.
==> Downloading https://ghcr.io/v2/homebrew/core/datafusion/manifests/10.0.0
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/datafusion/blobs/sha256:030d1c76aabdc29cbb29c8538512ea5dd6e051
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:030d1c76aabdc29cbb29c85385
######################################################################## 100.0%
==> Pouring datafusion--10.0.0.monterey.bottle.tar.gz
🍺 /usr/local/Cellar/datafusion/10.0.0: 9 files, 28.9MB
==> Running `brew cleanup datafusion`... |
||
| # ==> Downloading https://ghcr.io/v2/homebrew/core/datafusion/manifests/5.0.0 | ||
| # ######################################################################## 100.0% | ||
| # ==> Downloading https://ghcr.io/v2/homebrew/core/datafusion/blobs/sha256:9ecc8a01be47ceb9a53b39976696afa87c0a8 | ||
| # ==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:9ecc8a01be47ceb9a53b39976 | ||
| # ######################################################################## 100.0% | ||
| # ==> Pouring datafusion--5.0.0.big_sur.bottle.tar.gz | ||
| # 🍺 /usr/local/Cellar/datafusion/5.0.0: 9 files, 17.4MB | ||
|
|
||
| datafusion-cli | ||
| ``` | ||
|
|
||
| ## DataFusion-Cli | ||
| ### Run using Docker | ||
|
|
||
| There is no officially published Docker image for the DataFusion CLI, so it is necessary to build from source | ||
| instead. | ||
|
|
||
| Build the `datafusion-cli`: | ||
| 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. | ||
|
|
||
| ```bash | ||
| cd arrow-datafusion/datafusion-cli | ||
| cargo build | ||
| git clone https://github.com/apache/arrow-datafusion | ||
| git checkout 8.0.0 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might make sense to update this version |
||
| cd arrow-datafusion | ||
| docker build -f datafusion-cli/Dockerfile . --tag datafusion-cli | ||
| docker run -it -v $(your_data_location):/data datafusion-cli | ||
| ``` | ||
|
|
||
| ## Cli commands | ||
| ## Usage | ||
|
|
||
| ```bash | ||
| Apache Arrow <[email protected]> | ||
| Command Line Client for DataFusion query engine. | ||
|
|
||
| USAGE: | ||
| datafusion-cli [OPTIONS] | ||
|
|
||
| OPTIONS: | ||
| -c, --batch-size <BATCH_SIZE> The batch size of each query, or use DataFusion default | ||
| -f, --file <FILE>... Execute commands from file(s), then exit | ||
| --format <FORMAT> [default: table] [possible values: csv, tsv, table, json, | ||
| nd-json] | ||
| -h, --help Print help information | ||
| -p, --data-path <DATA_PATH> Path to your data, default to current directory | ||
| -q, --quiet Reduce printing other than the results and work quietly | ||
| -r, --rc <RC>... Run the provided files on startup instead of ~/.datafusionrc | ||
| -V, --version Print version information | ||
|
|
||
| Type `exit` or `quit` to exit the CLI. | ||
| ``` | ||
|
|
||
| ## Registering Parquet Data Sources | ||
|
|
||
| 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. | ||
|
|
||
| ```sql | ||
| CREATE EXTERNAL TABLE taxi | ||
| STORED AS PARQUET | ||
| LOCATION '/mnt/nyctaxi/tripdata.parquet'; | ||
| ``` | ||
|
|
||
| ## Registering CSV Data Sources | ||
|
|
||
| CSV data sources can be registered by executing a `CREATE EXTERNAL TABLE` SQL statement. | ||
|
|
||
| ```sql | ||
| CREATE EXTERNAL TABLE test | ||
| STORED AS CSV | ||
| WITH HEADER ROW | ||
| LOCATION '/path/to/aggregate_test_100.csv'; | ||
| ``` | ||
|
|
||
| It is also possible to provide schema information. | ||
|
|
||
| ```sql | ||
| 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 | ||
| LOCATION '/path/to/aggregate_test_100.csv'; | ||
| ``` | ||
|
|
||
| ## Commands | ||
|
|
||
| Available commands inside DataFusion CLI are: | ||
|
|
||
|
|
@@ -101,7 +181,7 @@ Available commands inside DataFusion CLI are: | |
|
|
||
| - QuietMode | ||
|
|
||
| ``` | ||
| ```bash | ||
| > \quiet [true|false] | ||
| ``` | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
11.0has a nice ring to it!