Skip to content

Apache DataFusion SQL Query Engine

Add documentation for `SHOW FUNCTIONS` (#13868)

Andrew Lamb2639fe045a7a
diff --git a/docs/source/user-guide/sql/information_schema.md b/docs/source/user-guide/sql/information_schema.md
index bf4aa00e1d..db74ec0708 100644
--- a/docs/source/user-guide/sql/information_schema.md
+++ b/docs/source/user-guide/sql/information_schema.md
@@ -22,7 +22,10 @@
DataFusion supports showing metadata about the tables and views 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.
-To show tables in the DataFusion catalog, use the `SHOW TABLES` command or the `information_schema.tables` view:
+## `SHOW TABLES`
+
+To show tables in the DataFusion catalog, use the `SHOW TABLES` command or the
+`information_schema.tables` view:
```sql
> show tables;
@@ -39,7 +42,10 @@ or
```
-To show the schema of a table in DataFusion, use the `SHOW COLUMNS` command or the `information_schema.columns` view:
+## `SHOW COLUMNS`
+
+To show the schema of a table in DataFusion, use the `SHOW COLUMNS` command or
+the `information_schema.columns` view.
```sql
> show columns from t;
@@ -52,7 +58,10 @@ or
+---------------+--------------+------------+-------------+-----------+-------------+
```
-To show the current session configuration options, use the `SHOW ALL` command or the `information_schema.df_settings` view:
+## `SHOW ALL` (configuration options)
+
+To show the current session configuration options, use the `SHOW ALL` command or
+the `information_schema.df_settings` view:
```sql
select * from information_schema.df_settings;
@@ -65,7 +74,48 @@ select * from information_schema.df_settings;
| datafusion.execution.time_zone | UTC |
| datafusion.explain.logical_plan_only | false |
| datafusion.explain.physical_plan_only | false |
+...
| datafusion.optimizer.filter_null_join_keys | false |
| datafusion.optimizer.skip_failed_rules | true |
+-------------------------------------------------+---------+
```
+
+## `SHOW FUNCTIONS`
+
+To show the list of functions available, use the `SHOW FUNCTIONS` command or the
+
+- `information_schema.information_schema.routines` view: functions and descriptions
+- `information_schema.information_schema.parameters` view: parameters and descriptions
+
+Syntax:
+
+```sql
+SHOW FUNCTIONS [ LIKE <pattern> ];
+```
+
+Example output
+
+```sql
+> show functions like '%datetrunc';
++---------------+-------------------------------------+-------------------------+-------------------------------------------------+---------------+-------------------------------------------------------+-----------------------------------+
+| function_name | return_type | parameters | parameter_types | function_type | description | syntax_example |
++---------------+-------------------------------------+-------------------------+-------------------------------------------------+---------------+-------------------------------------------------------+-----------------------------------+
+| datetrunc | Timestamp(Microsecond, Some("+TZ")) | [precision, expression] | [Utf8, Timestamp(Microsecond, Some("+TZ"))] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Nanosecond, None) | [precision, expression] | [Utf8View, Timestamp(Nanosecond, None)] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Second, Some("+TZ")) | [precision, expression] | [Utf8View, Timestamp(Second, Some("+TZ"))] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Microsecond, None) | [precision, expression] | [Utf8View, Timestamp(Microsecond, None)] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Second, None) | [precision, expression] | [Utf8View, Timestamp(Second, None)] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Microsecond, None) | [precision, expression] | [Utf8, Timestamp(Microsecond, None)] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Second, None) | [precision, expression] | [Utf8, Timestamp(Second, None)] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Microsecond, Some("+TZ")) | [precision, expression] | [Utf8View, Timestamp(Microsecond, Some("+TZ"))] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Nanosecond, Some("+TZ")) | [precision, expression] | [Utf8, Timestamp(Nanosecond, Some("+TZ"))] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Millisecond, None) | [precision, expression] | [Utf8, Timestamp(Millisecond, None)] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Millisecond, Some("+TZ")) | [precision, expression] | [Utf8, Timestamp(Millisecond, Some("+TZ"))] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Second, Some("+TZ")) | [precision, expression] | [Utf8, Timestamp(Second, Some("+TZ"))] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Nanosecond, None) | [precision, expression] | [Utf8, Timestamp(Nanosecond, None)] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Millisecond, None) | [precision, expression] | [Utf8View, Timestamp(Millisecond, None)] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Millisecond, Some("+TZ")) | [precision, expression] | [Utf8View, Timestamp(Millisecond, Some("+TZ"))] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
+| datetrunc | Timestamp(Nanosecond, Some("+TZ")) | [precision, expression] | [Utf8View, Timestamp(Nanosecond, Some("+TZ"))] | SCALAR | Truncates a timestamp value to a specified precision. | date_trunc(precision, expression) |
++---------------+-------------------------------------+-------------------------+-------------------------------------------------+---------------+-------------------------------------------------------+-----------------------------------+
+16 row(s) fetched.
+```