Skip to content

Apache DataFusion SQL Query Engine

minor: Update data type support documentation (#4984)

Andrew Lamb03601bee5455
diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml
index 74ca70006c..f8786adad6 100644
--- a/.github/workflows/dev.yml
+++ b/.github/workflows/dev.yml
@@ -42,8 +42,7 @@ jobs:
node-version: "14"
- name: Prettier check
run: |
- # if you encounter error, try rerun the command below with --write instead of --check
- # and commit the changes
+ # if you encounter error, rerun the command below and commit the changes
#
# ignore subproject CHANGELOG.md because they are machine generated
npx [email protected] --write \
diff --git a/docs/source/user-guide/sql/data_types.md b/docs/source/user-guide/sql/data_types.md
index 1d5c0f9fc0..968dcda532 100644
--- a/docs/source/user-guide/sql/data_types.md
+++ b/docs/source/user-guide/sql/data_types.md
@@ -25,6 +25,18 @@ execution. The SQL types from
are mapped to [Arrow data types](https://docs.rs/arrow/latest/arrow/datatypes/enum.DataType.html) according to the following table.
This mapping occurs when defining the schema in a `CREATE EXTERNAL TABLE` command or when performing a SQL `CAST` operation.
+You can see the corresponding Arrow type for any SQL expression using
+the `arrow_typeof` function. For example:
+
+```sql
+❯ select arrow_typeof(interval '1 month');
++-------------------------------------+
+| arrowtypeof(IntervalYearMonth("1")) |
++-------------------------------------+
+| Interval(YearMonth) |
++-------------------------------------+
+```
+
## Character Types
| SQL DataType | Arrow DataType |
@@ -32,6 +44,7 @@ This mapping occurs when defining the schema in a `CREATE EXTERNAL TABLE` comman
| `CHAR` | `Utf8` |
| `VARCHAR` | `Utf8` |
| `TEXT` | `Utf8` |
+| `STRING` | `Utf8` |
## Numeric Types
@@ -52,11 +65,12 @@ This mapping occurs when defining the schema in a `CREATE EXTERNAL TABLE` comman
## Date/Time Types
-| SQL DataType | Arrow DataType |
-| ------------ | :-------------------------------------- |
-| `DATE` | `Date32` |
-| `TIME` | `Time64(TimeUnit::Nanosecond)` |
-| `TIMESTAMP` | `Timestamp(TimeUnit::Nanosecond, None)` |
+| SQL DataType | Arrow DataType |
+| ------------ | :----------------------------------------------------------------------- |
+| `DATE` | `Date32` |
+| `TIME` | `Time64(TimeUnit::Nanosecond)` |
+| `TIMESTAMP` | `Timestamp(TimeUnit::Nanosecond, None)` |
+| `INTERVAL` | `Interval(IntervalUnit::YearMonth)` or `Interval(IntervalUnit::DayTime)` |
## Boolean Types
@@ -81,10 +95,8 @@ This mapping occurs when defining the schema in a `CREATE EXTERNAL TABLE` comman
| `VARBINARY` | _Not yet supported_ |
| `REGCLASS` | _Not yet supported_ |
| `NVARCHAR` | _Not yet supported_ |
-| `STRING` | _Not yet supported_ |
| `CUSTOM` | _Not yet supported_ |
| `ARRAY` | _Not yet supported_ |
| `ENUM` | _Not yet supported_ |
| `SET` | _Not yet supported_ |
-| `INTERVAL` | _Not yet supported_ |
| `DATETIME` | _Not yet supported_ |
diff --git a/docs/source/user-guide/sql/scalar_functions.md b/docs/source/user-guide/sql/scalar_functions.md
index 11725f90d9..aa4d13004c 100644
--- a/docs/source/user-guide/sql/scalar_functions.md
+++ b/docs/source/user-guide/sql/scalar_functions.md
@@ -280,6 +280,19 @@ wherever it appears in the statement, using a value chosen at planning time.
### `array`
+### `arrow_typeof`
+
+Returns the underlying Arrow type of the the expression:
+
+```sql
+❯ select arrow_typeof(4 + 4.3);
++--------------------------------------+
+| arrowtypeof(Int64(4) + Float64(4.3)) |
++--------------------------------------+
+| Float64 |
++--------------------------------------+
+```
+
### `in_list`
### `random`