-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Minor: add more examples for CREATE EXTERNAL TABLE
doc
#7594
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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 contains 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 | ||||
---|---|---|---|---|---|---|
|
@@ -23,49 +23,6 @@ The DataFusion CLI is a command-line interactive SQL utility for executing | |||||
queries against any supported data files. It is a convenient way to | ||||||
try DataFusion's SQL support with your own data. | ||||||
|
||||||
## Example | ||||||
|
||||||
Create a CSV file to query. | ||||||
|
||||||
```shell | ||||||
$ echo "a,b" > data.csv | ||||||
$ echo "1,2" >> data.csv | ||||||
``` | ||||||
|
||||||
Query that single file (the CLI also supports parquet, compressed csv, avro, json and more) | ||||||
|
||||||
```shell | ||||||
$ datafusion-cli | ||||||
DataFusion CLI v17.0.0 | ||||||
❯ select * from 'data.csv'; | ||||||
+---+---+ | ||||||
| a | b | | ||||||
+---+---+ | ||||||
| 1 | 2 | | ||||||
+---+---+ | ||||||
1 row in set. Query took 0.007 seconds. | ||||||
``` | ||||||
|
||||||
You can also query directories of files with compatible schemas: | ||||||
|
||||||
```shell | ||||||
$ ls data_dir/ | ||||||
data.csv data2.csv | ||||||
``` | ||||||
|
||||||
```shell | ||||||
$ datafusion-cli | ||||||
DataFusion CLI v16.0.0 | ||||||
❯ select * from 'data_dir'; | ||||||
+---+---+ | ||||||
| a | b | | ||||||
+---+---+ | ||||||
| 3 | 4 | | ||||||
| 1 | 2 | | ||||||
+---+---+ | ||||||
2 rows in set. Query took 0.007 seconds. | ||||||
``` | ||||||
|
||||||
## Installation | ||||||
|
||||||
### Install and run using Cargo | ||||||
|
@@ -131,24 +88,87 @@ OPTIONS: | |||||
-V, --version Print version information | ||||||
``` | ||||||
|
||||||
## Selecting files directly | ||||||
## Querying data from the files directly | ||||||
|
||||||
Files can be queried directly by enclosing the file or | ||||||
directory name in single `'` quotes as shown in the example. | ||||||
|
||||||
## Example | ||||||
|
||||||
Create a CSV file to query. | ||||||
|
||||||
```shell | ||||||
$ echo "a,b" > data.csv | ||||||
$ echo "1,2" >> data.csv | ||||||
``` | ||||||
|
||||||
Query that single file (the CLI also supports parquet, compressed csv, avro, json and more) | ||||||
|
||||||
```shell | ||||||
$ datafusion-cli | ||||||
DataFusion CLI v17.0.0 | ||||||
❯ select * from 'data.csv'; | ||||||
+---+---+ | ||||||
| a | b | | ||||||
+---+---+ | ||||||
| 1 | 2 | | ||||||
+---+---+ | ||||||
1 row in set. Query took 0.007 seconds. | ||||||
``` | ||||||
|
||||||
You can also query directories of files with compatible schemas: | ||||||
|
||||||
```shell | ||||||
$ ls data_dir/ | ||||||
data.csv data2.csv | ||||||
``` | ||||||
|
||||||
```shell | ||||||
$ datafusion-cli | ||||||
DataFusion CLI v16.0.0 | ||||||
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 doesn't really matter, but it might be nice to have the versions be consistent
Suggested change
|
||||||
❯ select * from 'data_dir'; | ||||||
+---+---+ | ||||||
| a | b | | ||||||
+---+---+ | ||||||
| 3 | 4 | | ||||||
| 1 | 2 | | ||||||
+---+---+ | ||||||
2 rows in set. Query took 0.007 seconds. | ||||||
``` | ||||||
|
||||||
## Creating external tables | ||||||
|
||||||
It is also possible to create a table backed by files by explicitly | ||||||
via `CREATE EXTERNAL TABLE` as shown below. | ||||||
via `CREATE EXTERNAL TABLE` as shown below. Filemask wildcards supported | ||||||
|
||||||
## 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. | ||||||
Parquet data sources can be registered by executing a `CREATE EXTERNAL TABLE` SQL statement. The schema information will be derived automatically. | ||||||
|
||||||
Register a single file parquet datasource | ||||||
|
||||||
```sql | ||||||
CREATE EXTERNAL TABLE taxi | ||||||
STORED AS PARQUET | ||||||
LOCATION '/mnt/nyctaxi/tripdata.parquet'; | ||||||
``` | ||||||
|
||||||
Register a single folder parquet datasource. All files inside must be valid parquet files! | ||||||
|
||||||
```sql | ||||||
CREATE EXTERNAL TABLE taxi | ||||||
STORED AS PARQUET | ||||||
LOCATION '/mnt/nyctaxi/'; | ||||||
``` | ||||||
|
||||||
Register a single folder parquet datasource by specifying a wildcard for files to read | ||||||
|
||||||
```sql | ||||||
CREATE EXTERNAL TABLE taxi | ||||||
STORED AS PARQUET | ||||||
LOCATION '/mnt/nyctaxi/*.parquet'; | ||||||
``` | ||||||
|
||||||
## Registering CSV Data Sources | ||||||
|
||||||
CSV data sources can be registered by executing a `CREATE EXTERNAL TABLE` SQL statement. | ||||||
|
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.
👍