From f218124c866ea10f222c516dc530dad2efe74279 Mon Sep 17 00:00:00 2001
From: Andy Grove <andygrove73@gmail.com>
Date: Sat, 13 Aug 2022 10:49:58 -0600
Subject: [PATCH 1/6] Move Data Types and Information Schema to their own pages

---
 docs/source/user-guide/sql/data_types.md      |  51 +++++++++
 docs/source/user-guide/sql/index.rst          |   4 +-
 .../user-guide/sql/information_schema.md      |  68 ++++++++++++
 docs/source/user-guide/sql/sql_status.md      | 101 ------------------
 4 files changed, 122 insertions(+), 102 deletions(-)
 create mode 100644 docs/source/user-guide/sql/data_types.md
 create mode 100644 docs/source/user-guide/sql/information_schema.md

diff --git a/docs/source/user-guide/sql/data_types.md b/docs/source/user-guide/sql/data_types.md
new file mode 100644
index 000000000000..d7b8699956af
--- /dev/null
+++ b/docs/source/user-guide/sql/data_types.md
@@ -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::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_               |
diff --git a/docs/source/user-guide/sql/index.rst b/docs/source/user-guide/sql/index.rst
index 97753d708e1b..8ce337718b69 100644
--- a/docs/source/user-guide/sql/index.rst
+++ b/docs/source/user-guide/sql/index.rst
@@ -21,8 +21,10 @@ SQL Reference
 .. toctree::
    :maxdepth: 2
 
-   sql_status
+   data_types
    select
    ddl
+   information_schema
    aggregate_functions
    scalar_functions
+   sql_status
diff --git a/docs/source/user-guide/sql/information_schema.md b/docs/source/user-guide/sql/information_schema.md
new file mode 100644
index 000000000000..ee0fbfd37336
--- /dev/null
+++ b/docs/source/user-guide/sql/information_schema.md
@@ -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   |
++------------+-------------+------------------+-------------+-----------+
+```
diff --git a/docs/source/user-guide/sql/sql_status.md b/docs/source/user-guide/sql/sql_status.md
index 686ba73b70c2..70747b5d041e 100644
--- a/docs/source/user-guide/sql/sql_status.md
+++ b/docs/source/user-guide/sql/sql_status.md
@@ -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
-
-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_               |

From 63e087519706f149f37b2c25bdd8716625ddb946 Mon Sep 17 00:00:00 2001
From: Andy Grove <andygrove73@gmail.com>
Date: Mon, 15 Aug 2022 13:25:09 -0600
Subject: [PATCH 2/6] Update docs/source/user-guide/sql/data_types.md

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
---
 docs/source/user-guide/sql/data_types.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/source/user-guide/sql/data_types.md b/docs/source/user-guide/sql/data_types.md
index d7b8699956af..f4d2bf79e4da 100644
--- a/docs/source/user-guide/sql/data_types.md
+++ b/docs/source/user-guide/sql/data_types.md
@@ -41,7 +41,7 @@ are mapped to Arrow types according to the following table
 | `DOUBLE`      | `Float64`                         |
 | `BOOLEAN`     | `Boolean`                         |
 | `DATE`        | `Date32`                          |
-| `TIME`        | `Time64(TimeUnit::Millisecond)`   |
+| `TIME`        | `Time64(TimeUnit::Nanosecond)`   |
 | `TIMESTAMP`   | `Timestamp(TimeUnit::Nanosecond)` |
 | `INTERVAL`    | _Not yet supported_               |
 | `REGCLASS`    | _Not yet supported_               |

From 28bc50927e4be440b7b74339c066c3ba6171bdc4 Mon Sep 17 00:00:00 2001
From: Andy Grove <andygrove73@gmail.com>
Date: Mon, 15 Aug 2022 13:25:23 -0600
Subject: [PATCH 3/6] Update docs/source/user-guide/sql/data_types.md

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
---
 docs/source/user-guide/sql/data_types.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/source/user-guide/sql/data_types.md b/docs/source/user-guide/sql/data_types.md
index f4d2bf79e4da..5f3516bbe035 100644
--- a/docs/source/user-guide/sql/data_types.md
+++ b/docs/source/user-guide/sql/data_types.md
@@ -43,7 +43,7 @@ are mapped to Arrow types according to the following table
 | `DATE`        | `Date32`                          |
 | `TIME`        | `Time64(TimeUnit::Nanosecond)`   |
 | `TIMESTAMP`   | `Timestamp(TimeUnit::Nanosecond)` |
-| `INTERVAL`    | _Not yet supported_               |
+| `INTERVAL`    | `Interval(YearMonth)` or `Interval(MonthDayNano)` or `Interval(DayTime)`  |
 | `REGCLASS`    | _Not yet supported_               |
 | `TEXT`        | _Not yet supported_               |
 | `BYTEA`       | _Not yet supported_               |

From 4dd80e67c41a7b7cafa371037021796b228a9a4b Mon Sep 17 00:00:00 2001
From: Andy Grove <andygrove73@gmail.com>
Date: Mon, 15 Aug 2022 13:25:30 -0600
Subject: [PATCH 4/6] Update docs/source/user-guide/sql/data_types.md

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
---
 docs/source/user-guide/sql/data_types.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/source/user-guide/sql/data_types.md b/docs/source/user-guide/sql/data_types.md
index 5f3516bbe035..7bc06d114c8d 100644
--- a/docs/source/user-guide/sql/data_types.md
+++ b/docs/source/user-guide/sql/data_types.md
@@ -45,7 +45,7 @@ are mapped to Arrow types according to the following table
 | `TIMESTAMP`   | `Timestamp(TimeUnit::Nanosecond)` |
 | `INTERVAL`    | `Interval(YearMonth)` or `Interval(MonthDayNano)` or `Interval(DayTime)`  |
 | `REGCLASS`    | _Not yet supported_               |
-| `TEXT`        | _Not yet supported_               |
+| `TEXT`        | `Utf8`               |
 | `BYTEA`       | _Not yet supported_               |
 | `CUSTOM`      | _Not yet supported_               |
 | `ARRAY`       | _Not yet supported_               |

From b8d8a3e545f5de952d21a1a0eaa9ed9b59b6f5fb Mon Sep 17 00:00:00 2001
From: Andy Grove <andygrove73@gmail.com>
Date: Mon, 15 Aug 2022 13:25:37 -0600
Subject: [PATCH 5/6] Update docs/source/user-guide/sql/data_types.md

Co-authored-by: Andrew Lamb <andrew@nerdnetworks.org>
---
 docs/source/user-guide/sql/data_types.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/docs/source/user-guide/sql/data_types.md b/docs/source/user-guide/sql/data_types.md
index 7bc06d114c8d..1a65f5ba81e9 100644
--- a/docs/source/user-guide/sql/data_types.md
+++ b/docs/source/user-guide/sql/data_types.md
@@ -46,6 +46,6 @@ are mapped to Arrow types according to the following table
 | `INTERVAL`    | `Interval(YearMonth)` or `Interval(MonthDayNano)` or `Interval(DayTime)`  |
 | `REGCLASS`    | _Not yet supported_               |
 | `TEXT`        | `Utf8`               |
-| `BYTEA`       | _Not yet supported_               |
+| `BYTEA`       | `Binary`               |
 | `CUSTOM`      | _Not yet supported_               |
 | `ARRAY`       | _Not yet supported_               |

From 6fccf69e3ea33343e38e8749df68418bd22a7211 Mon Sep 17 00:00:00 2001
From: Andy Grove <andygrove73@gmail.com>
Date: Mon, 15 Aug 2022 13:26:48 -0600
Subject: [PATCH 6/6] prettier

---
 docs/source/user-guide/sql/data_types.md | 50 ++++++++++++------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/docs/source/user-guide/sql/data_types.md b/docs/source/user-guide/sql/data_types.md
index 1a65f5ba81e9..7a3ed7adb477 100644
--- a/docs/source/user-guide/sql/data_types.md
+++ b/docs/source/user-guide/sql/data_types.md
@@ -24,28 +24,28 @@ 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_               |
+| 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_                                                      |
