Skip to content

Apache DataFusion SQL Query Engine

ARROW-12210: [Rust][DataFusion] Document SHOW TABLES / SHOW COLUMNS / Information Schema

Andrew Lambcb5b0f273c43
diff --git a/rust/datafusion/README.md b/rust/datafusion/README.md
index b7f1e0a0d9..e847f0bce3 100644
--- a/rust/datafusion/README.md
+++ b/rust/datafusion/README.md
@@ -197,6 +197,11 @@ DataFusion also includes a simple command-line interactive SQL utility. See the
- [x] Basic timestamp functions
- nested functions
- [x] Array of columns
+- [x] Schema Queries
+ - [x] SHOW TABLES
+ - [x] SHOW COLUMNS
+ - [x] information_schema.{tables, columns}
+ - [ ] information_schema other views
- [x] Sorting
- [ ] Nested types
- [ ] Lists
@@ -252,9 +257,56 @@ DataFusion strives to implement a subset of the [PostgreSQL SQL dialect](https:/
Currently, only a subset of the PosgreSQL dialect is implemented, and we will document any deviations.
-## Information Schema
+## 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 |
++------------+-------------+------------------+-------------+-----------+
+```
-DataFusion supports the `TABLES` and `COLUMNS` views of the ISO SQL `information_schema` schema to list tables and columns respectively. More information can be found in the [Postgres docs](https://www.postgresql.org/docs/13/infoschema-schema.html)).
## Supported Data Types