-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: User Guide: Move Data Types and Information Schema to their own pages #3131
Merged
andygrove
merged 6 commits into
apache:master
from
andygrove:user-guide-types-info-schema
Aug 15, 2022
+122
−102
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f218124
Move Data Types and Information Schema to their own pages
andygrove 63e0875
Update docs/source/user-guide/sql/data_types.md
andygrove 28bc509
Update docs/source/user-guide/sql/data_types.md
andygrove 4dd80e6
Update docs/source/user-guide/sql/data_types.md
andygrove b8d8a3e
Update docs/source/user-guide/sql/data_types.md
andygrove 6fccf69
prettier
andygrove 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 |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!--- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
|
||
# Data Types | ||
|
||
DataFusion uses Arrow, and thus the Arrow type system, for query | ||
execution. The SQL types from | ||
[sqlparser-rs](https://github.com/sqlparser-rs/sqlparser-rs/blob/main/src/ast/data_type.rs#L27) | ||
are mapped to Arrow types according to the following table | ||
|
||
| SQL Data Type | Arrow DataType | | ||
| ------------- | ------------------------------------------------------------------------ | | ||
| `CHAR` | `Utf8` | | ||
| `VARCHAR` | `Utf8` | | ||
| `UUID` | _Not yet supported_ | | ||
| `CLOB` | _Not yet supported_ | | ||
| `BINARY` | _Not yet supported_ | | ||
| `VARBINARY` | _Not yet supported_ | | ||
| `DECIMAL` | `Float64` | | ||
| `FLOAT` | `Float32` | | ||
| `SMALLINT` | `Int16` | | ||
| `INT` | `Int32` | | ||
| `BIGINT` | `Int64` | | ||
| `REAL` | `Float32` | | ||
| `DOUBLE` | `Float64` | | ||
| `BOOLEAN` | `Boolean` | | ||
| `DATE` | `Date32` | | ||
| `TIME` | `Time64(TimeUnit::Nanosecond)` | | ||
| `TIMESTAMP` | `Timestamp(TimeUnit::Nanosecond)` | | ||
| `INTERVAL` | `Interval(YearMonth)` or `Interval(MonthDayNano)` or `Interval(DayTime)` | | ||
| `REGCLASS` | _Not yet supported_ | | ||
| `TEXT` | `Utf8` | | ||
| `BYTEA` | `Binary` | | ||
| `CUSTOM` | _Not yet supported_ | | ||
| `ARRAY` | _Not yet supported_ | |
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
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<!--- | ||
Licensed to the Apache Software Foundation (ASF) under one | ||
or more contributor license agreements. See the NOTICE file | ||
distributed with this work for additional information | ||
regarding copyright ownership. The ASF licenses this file | ||
to you under the Apache License, Version 2.0 (the | ||
"License"); you may not use this file except in compliance | ||
with the License. You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the License is distributed on an | ||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations | ||
under the License. | ||
--> | ||
|
||
# Information Schema | ||
|
||
DataFusion supports showing metadata about the tables available. This information can be accessed using the views | ||
of the ISO SQL `information_schema` schema or the DataFusion specific `SHOW TABLES` and `SHOW COLUMNS` commands. | ||
|
||
More information can be found in the [Postgres docs](https://www.postgresql.org/docs/13/infoschema-schema.html)). | ||
|
||
To show tables available for use in DataFusion, use the `SHOW TABLES` command or the `information_schema.tables` view: | ||
|
||
```sql | ||
> show tables; | ||
+---------------+--------------------+------------+------------+ | ||
| table_catalog | table_schema | table_name | table_type | | ||
+---------------+--------------------+------------+------------+ | ||
| datafusion | public | t | BASE TABLE | | ||
| datafusion | information_schema | tables | VIEW | | ||
+---------------+--------------------+------------+------------+ | ||
|
||
> select * from information_schema.tables; | ||
|
||
+---------------+--------------------+------------+--------------+ | ||
| table_catalog | table_schema | table_name | table_type | | ||
+---------------+--------------------+------------+--------------+ | ||
| datafusion | public | t | BASE TABLE | | ||
| datafusion | information_schema | TABLES | SYSTEM TABLE | | ||
+---------------+--------------------+------------+--------------+ | ||
``` | ||
|
||
To show the schema of a table in DataFusion, use the `SHOW COLUMNS` command or the or `information_schema.columns` view: | ||
|
||
```sql | ||
> show columns from t; | ||
+---------------+--------------+------------+-------------+-----------+-------------+ | ||
| table_catalog | table_schema | table_name | column_name | data_type | is_nullable | | ||
+---------------+--------------+------------+-------------+-----------+-------------+ | ||
| datafusion | public | t | a | Int32 | NO | | ||
| datafusion | public | t | b | Utf8 | NO | | ||
| datafusion | public | t | c | Float32 | NO | | ||
+---------------+--------------+------------+-------------+-----------+-------------+ | ||
|
||
> select table_name, column_name, ordinal_position, is_nullable, data_type from information_schema.columns; | ||
+------------+-------------+------------------+-------------+-----------+ | ||
| table_name | column_name | ordinal_position | is_nullable | data_type | | ||
+------------+-------------+------------------+-------------+-----------+ | ||
| t | a | 0 | NO | Int32 | | ||
| t | b | 1 | NO | Utf8 | | ||
| t | c | 2 | NO | Float32 | | ||
+------------+-------------+------------------+-------------+-----------+ | ||
``` |
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 |
---|---|---|
|
@@ -143,104 +143,3 @@ DataFusion is designed to be extensible at all points. To that end, you can prov | |
## Rust Version Compatibility | ||
|
||
This crate is tested with the latest stable version of Rust. We do not currently test against other, older versions of the Rust compiler. | ||
|
||
# Supported SQL | ||
|
||
This library currently supports many SQL constructs, including | ||
|
||
- `CREATE EXTERNAL TABLE X STORED AS PARQUET LOCATION '...';` to register a table's locations | ||
- `SELECT ... FROM ...` together with any expression | ||
- `ALIAS` to name an expression | ||
- `CAST` to change types, including e.g. `Timestamp(Nanosecond, None)` | ||
- Many mathematical unary and binary expressions such as `+`, `/`, `sqrt`, `tan`, `>=`. | ||
- `WHERE` to filter | ||
- `GROUP BY` together with one of the following aggregations: `MIN`, `MAX`, `COUNT`, `SUM`, `AVG`, `CORR`, `VAR`, `COVAR`, `STDDEV` (sample and population) | ||
- `ORDER BY` together with an expression and optional `ASC` or `DESC` and also optional `NULLS FIRST` or `NULLS LAST` | ||
|
||
## Supported Functions | ||
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. Removed this since most of the functions are now documented in the SQL reference |
||
|
||
DataFusion strives to implement a subset of the [PostgreSQL SQL dialect](https://www.postgresql.org/docs/current/functions.html) where possible. We explicitly choose a single dialect to maximize interoperability with other tools and allow reuse of the PostgreSQL documents and tutorials as much as possible. | ||
|
||
Currently, only a subset of the PostgreSQL dialect is implemented, and we will document any deviations. | ||
|
||
## Schema Metadata / Information Schema Support | ||
|
||
DataFusion supports the showing metadata about the tables available. This information can be accessed using the views of the ISO SQL `information_schema` schema or the DataFusion specific `SHOW TABLES` and `SHOW COLUMNS` commands. | ||
|
||
More information can be found in the [Postgres docs](https://www.postgresql.org/docs/13/infoschema-schema.html)). | ||
|
||
To show tables available for use in DataFusion, use the `SHOW TABLES` command or the `information_schema.tables` view: | ||
|
||
```sql | ||
> show tables; | ||
+---------------+--------------------+------------+------------+ | ||
| table_catalog | table_schema | table_name | table_type | | ||
+---------------+--------------------+------------+------------+ | ||
| datafusion | public | t | BASE TABLE | | ||
| datafusion | information_schema | tables | VIEW | | ||
+---------------+--------------------+------------+------------+ | ||
|
||
> select * from information_schema.tables; | ||
|
||
+---------------+--------------------+------------+--------------+ | ||
| table_catalog | table_schema | table_name | table_type | | ||
+---------------+--------------------+------------+--------------+ | ||
| datafusion | public | t | BASE TABLE | | ||
| datafusion | information_schema | TABLES | SYSTEM TABLE | | ||
+---------------+--------------------+------------+--------------+ | ||
``` | ||
|
||
To show the schema of a table in DataFusion, use the `SHOW COLUMNS` command or the or `information_schema.columns` view: | ||
|
||
```sql | ||
> show columns from t; | ||
+---------------+--------------+------------+-------------+-----------+-------------+ | ||
| table_catalog | table_schema | table_name | column_name | data_type | is_nullable | | ||
+---------------+--------------+------------+-------------+-----------+-------------+ | ||
| datafusion | public | t | a | Int32 | NO | | ||
| datafusion | public | t | b | Utf8 | NO | | ||
| datafusion | public | t | c | Float32 | NO | | ||
+---------------+--------------+------------+-------------+-----------+-------------+ | ||
|
||
> select table_name, column_name, ordinal_position, is_nullable, data_type from information_schema.columns; | ||
+------------+-------------+------------------+-------------+-----------+ | ||
| table_name | column_name | ordinal_position | is_nullable | data_type | | ||
+------------+-------------+------------------+-------------+-----------+ | ||
| t | a | 0 | NO | Int32 | | ||
| t | b | 1 | NO | Utf8 | | ||
| t | c | 2 | NO | Float32 | | ||
+------------+-------------+------------------+-------------+-----------+ | ||
``` | ||
|
||
## Supported Data Types | ||
|
||
DataFusion uses Arrow, and thus the Arrow type system, for query | ||
execution. The SQL types from | ||
[sqlparser-rs](https://github.com/ballista-compute/sqlparser-rs/blob/main/src/ast/data_type.rs#L57) | ||
are mapped to Arrow types according to the following table | ||
|
||
| SQL Data Type | Arrow DataType | | ||
| ------------- | --------------------------------- | | ||
| `CHAR` | `Utf8` | | ||
| `VARCHAR` | `Utf8` | | ||
| `UUID` | _Not yet supported_ | | ||
| `CLOB` | _Not yet supported_ | | ||
| `BINARY` | _Not yet supported_ | | ||
| `VARBINARY` | _Not yet supported_ | | ||
| `DECIMAL` | `Float64` | | ||
| `FLOAT` | `Float32` | | ||
| `SMALLINT` | `Int16` | | ||
| `INT` | `Int32` | | ||
| `BIGINT` | `Int64` | | ||
| `REAL` | `Float32` | | ||
| `DOUBLE` | `Float64` | | ||
| `BOOLEAN` | `Boolean` | | ||
| `DATE` | `Date32` | | ||
| `TIME` | `Time64(TimeUnit::Millisecond)` | | ||
| `TIMESTAMP` | `Timestamp(TimeUnit::Nanosecond)` | | ||
| `INTERVAL` | _Not yet supported_ | | ||
| `REGCLASS` | _Not yet supported_ | | ||
| `TEXT` | _Not yet supported_ | | ||
| `BYTEA` | _Not yet supported_ | | ||
| `CUSTOM` | _Not yet supported_ | | ||
| `ARRAY` | _Not yet supported_ | |
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.
Removed this since this is covered already in "SELECT syntax" page