Skip to content

Commit 94e6674

Browse files
[SPARK-28805][DOCS][SQL] Document DESCRIBE FUNCTION in SQL Reference
### What changes were proposed in this pull request? Document DESCRIBE FUNCTION statement in SQL Reference Guide. ### Why are the changes needed? Currently Spark lacks documentation on the supported SQL constructs causing confusion among users who sometimes have to look at the code to understand the usage. This is aimed at addressing this issue. ### Does this PR introduce any user-facing change? Yes. **Before:** There was no documentation for this. **After.** <img width="1234" alt="Screen Shot 2019-09-02 at 11 14 09 PM" src="https://user-images.githubusercontent.com/14225158/64148193-85534380-cdd7-11e9-9c07-5956b5e8276e.png"> <img width="1234" alt="Screen Shot 2019-09-02 at 11 14 29 PM" src="https://user-images.githubusercontent.com/14225158/64148201-8a17f780-cdd7-11e9-93d8-10ad9932977c.png"> <img width="1234" alt="Screen Shot 2019-09-02 at 11 14 42 PM" src="https://user-images.githubusercontent.com/14225158/64148208-8dab7e80-cdd7-11e9-97c5-3a4ce12cac7a.png"> ### How was this patch tested? Tested using jykyll build --serve Closes #25530 from dilipbiswal/ref-doc-desc-function. Lead-authored-by: Dilip Biswal <[email protected]> Co-authored-by: Xiao Li <[email protected]> Signed-off-by: Xiao Li <[email protected]>
1 parent 92ae271 commit 94e6674

File tree

1 file changed

+91
-1
lines changed

1 file changed

+91
-1
lines changed

docs/sql-ref-syntax-aux-describe-function.md

Lines changed: 91 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,95 @@ license: |
1818
See the License for the specific language governing permissions and
1919
limitations under the License.
2020
---
21+
### Description
2122

22-
**This page is under construction**
23+
`DESCRIBE FUNCTION` statement returns the basic metadata information of an
24+
existing function. The metadata information includes the function name, implementing
25+
class and the usage details. If the optional `EXTENDED` option is specified, the basic
26+
metadata information is returned along with the extended usage information.
27+
28+
### Syntax
29+
{% highlight sql %}
30+
{DESC | DESCRIBE} FUNCTION [EXTENDED] function_name
31+
{% endhighlight %}
32+
33+
### Parameters
34+
<dl>
35+
<dt><code><em>function_name</em></code></dt>
36+
<dd>
37+
Specifies a name of an existing function in the syetem. The function name may be
38+
optionally qualified with a database name. If `function_name` is qualified with
39+
a database then the function is resolved from the user specified database, otherwise
40+
it is resolved from the current database.<br><br>
41+
<b>Syntax:</b>
42+
<code>
43+
[database_name.]function_name
44+
</code>
45+
</dd>
46+
</dl>
47+
48+
### Examples
49+
{% highlight sql %}
50+
-- Describe a builtin scalar function.
51+
-- Returns function name, implementing class and usage
52+
DESC FUNCTION abs;
53+
+-------------------------------------------------------------------+
54+
|function_desc |
55+
+-------------------------------------------------------------------+
56+
|Function: abs |
57+
|Class: org.apache.spark.sql.catalyst.expressions.Abs |
58+
|Usage: abs(expr) - Returns the absolute value of the numeric value.|
59+
+-------------------------------------------------------------------+
60+
61+
-- Describe a builtin scalar function.
62+
-- Returns function name, implementing class and usage and examples.
63+
DESC FUNCTION EXTENDED abs;
64+
+-------------------------------------------------------------------+
65+
|function_desc |
66+
+-------------------------------------------------------------------+
67+
|Function: abs |
68+
|Class: org.apache.spark.sql.catalyst.expressions.Abs |
69+
|Usage: abs(expr) - Returns the absolute value of the numeric value.|
70+
|Extended Usage: |
71+
| Examples: |
72+
| > SELECT abs(-1); |
73+
| 1 |
74+
| |
75+
+-------------------------------------------------------------------+
76+
77+
-- Describe a builtin aggregate function
78+
DESC FUNCTION max;
79+
+--------------------------------------------------------------+
80+
|function_desc |
81+
+--------------------------------------------------------------+
82+
|Function: max |
83+
|Class: org.apache.spark.sql.catalyst.expressions.aggregate.Max|
84+
|Usage: max(expr) - Returns the maximum value of `expr`. |
85+
+--------------------------------------------------------------+
86+
87+
-- Describe a builtin user defined aggregate function
88+
-- Returns function name, implementing class and usage and examples.
89+
DESC FUNCTION EXTENDED explode
90+
+---------------------------------------------------------------+
91+
|function_desc |
92+
+---------------------------------------------------------------+
93+
|Function: explode |
94+
|Class: org.apache.spark.sql.catalyst.expressions.Explode |
95+
|Usage: explode(expr) - Separates the elements of array `expr` |
96+
| into multiple rows, or the elements of map `expr` into |
97+
| multiple rows and columns. Unless specified otherwise, uses |
98+
| the default column name `col` for elements of the array or |
99+
| `key` and `value` for the elements of the map. |
100+
|Extended Usage: |
101+
| Examples: |
102+
| > SELECT explode(array(10, 20)); |
103+
| 10 |
104+
| 20 |
105+
+---------------------------------------------------------------+
106+
107+
{% endhighlight %}
108+
109+
### Related Statements
110+
- [DESCRIBE DATABASE](sql-ref-syntax-aux-describe-database.html)
111+
- [DESCRIBE TABLE](sql-ref-syntax-aux-describe-table.html)
112+
- [DESCRIBE QUERY](sql-ref-syntax-aux-describe-query.html)

0 commit comments

Comments
 (0)