You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by li...@apache.org on 2019/09/04 18:47:33 UTC

[spark] branch master updated: [SPARK-28808][DOCS][SQL] Document SHOW FUNCTIONS in SQL Reference

This is an automated email from the ASF dual-hosted git repository.

lixiao pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new f96486b  [SPARK-28808][DOCS][SQL] Document SHOW FUNCTIONS in SQL Reference
f96486b is described below

commit f96486b4aaba36a0f843c8a52801c305b0fa2b16
Author: Dilip Biswal <db...@us.ibm.com>
AuthorDate: Wed Sep 4 11:47:10 2019 -0700

    [SPARK-28808][DOCS][SQL] Document SHOW FUNCTIONS in SQL Reference
    
    ### What changes were proposed in this pull request?
    Document SHOW FUNCTIONS 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.**
    
    ![image](https://user-images.githubusercontent.com/11567269/64281840-e3cc0f00-cf08-11e9-9784-f01392276130.png)
    
    <img width="589" alt="Screen Shot 2019-09-04 at 11 41 44 AM" src="https://user-images.githubusercontent.com/11567269/64281911-0fe79000-cf09-11e9-955f-21b44590707c.png">
    
    <img width="572" alt="Screen Shot 2019-09-04 at 11 41 54 AM" src="https://user-images.githubusercontent.com/11567269/64281916-12e28080-cf09-11e9-9187-688c2c751559.png">
    
    ### How was this patch tested?
    Tested using jykyll build --serve
    
    Closes #25539 from dilipbiswal/ref-doc-show-functions.
    
    Lead-authored-by: Dilip Biswal <db...@us.ibm.com>
    Co-authored-by: Xiao Li <ga...@gmail.com>
    Signed-off-by: Xiao Li <ga...@gmail.com>
---
 docs/sql-ref-syntax-aux-describe-function.md |   2 +-
 docs/sql-ref-syntax-aux-show-functions.md    | 119 ++++++++++++++++++++++++++-
 2 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/docs/sql-ref-syntax-aux-describe-function.md b/docs/sql-ref-syntax-aux-describe-function.md
index 1c50708..d3dc192 100644
--- a/docs/sql-ref-syntax-aux-describe-function.md
+++ b/docs/sql-ref-syntax-aux-describe-function.md
@@ -34,7 +34,7 @@ metadata information is returned along with the extended usage information.
 <dl>
   <dt><code><em>function_name</em></code></dt>
   <dd>
-    Specifies a name of an existing function in the syetem. The function name may be
+    Specifies a name of an existing function in the system. The function name may be
     optionally qualified with a database name. If `function_name` is qualified with
     a database then the function is resolved from the user specified database, otherwise
     it is resolved from the current database.<br><br>
diff --git a/docs/sql-ref-syntax-aux-show-functions.md b/docs/sql-ref-syntax-aux-show-functions.md
index ae689fd..db02607 100644
--- a/docs/sql-ref-syntax-aux-show-functions.md
+++ b/docs/sql-ref-syntax-aux-show-functions.md
@@ -19,4 +19,121 @@ license: |
   limitations under the License.
 ---
 
-**This page is under construction**
+### Description
+Returns the list of functions after applying an optional regex pattern.
+Given number of functions supported by Spark is quite large, this statement
+in conjuction with [describe function](sql-ref-syntax-aux-describe-function.html)
+may be used to quickly find the function and understand its usage. The `LIKE` 
+clause is optional and supported only for compatibility with other systems.
+
+### Syntax
+{% highlight sql %}
+SHOW [ function_kind ] FUNCTIONS ([LIKE] function_name | regex_pattern)
+{% endhighlight %}
+
+### Parameters
+<dl>
+  <dt><code><em>function_kind</em></code></dt>
+  <dd>
+    Specifies the name space of the function to be searched upon. The valid name spaces are :
+    <ul>
+      <li><b>USER</b> - Looks up the function(s) among the user defined functions.</li>
+      <li><b>SYSTEM</b> - Looks up the function(s) among the system defined functions.</li>
+      <li><b>ALL</b> -  Looks up the function(s) among both user and system defined functions.</li>
+    </ul>
+  </dd>
+  <dt><code><em>function_name</em></code></dt>
+  <dd>
+    Specifies a name of an existing function in the system. The function name may be
+    optionally qualified with a database name. If `function_name` is qualified with
+    a database then the function is resolved from the user specified database, otherwise
+    it is resolved from the current database.<br><br>
+    <b>Syntax:</b>
+      <code>
+        [database_name.]function_name
+      </code>
+  </dd>
+  <dt><code><em>regex_pattern</em></code></dt>
+  <dd>
+    Specifies a regular expression pattern that is used to limit the results of the
+    statement.
+    <ul>
+      <li>Only `*` and `|` are allowed as wildcard pattern.</li>
+      <li>Excluding `*` and `|` the remaining pattern follows the regex semantics.</li>
+      <li>The leading and trailing blanks are trimmed in the input pattern before processing.</li> 
+    </ul>
+  </dd>
+</dl>
+
+### Examples
+{% highlight sql %}
+-- List a system function `trim` by searching both user defined and system
+-- defined functions.
+SHOW FUNCTIONS trim;
+  +--------+
+  |function|
+  +--------+
+  |trim    |
+  +--------+
+
+-- List a system function `concat` by searching system defined functions.
+SHOW SYSTEM FUNCTIONS concat;
+  +--------+
+  |function|
+  +--------+
+  |concat  |
+  +--------+
+
+-- List a qualified function `max` from database `salesdb`. 
+SHOW SYSTEM FUNCTIONS salesdb.max;
+  +--------+
+  |function|
+  +--------+
+  |max     |
+  +--------+
+
+-- List all functions starting with `t`
+SHOW FUNCTIONS LIKE 't*';
+  +-----------------+
+  |function         |
+  +-----------------+
+  |tan              |
+  |tanh             |
+  |timestamp        |
+  |tinyint          |
+  |to_csv           |
+  |to_date          |
+  |to_json          |
+  |to_timestamp     |
+  |to_unix_timestamp|
+  |to_utc_timestamp |
+  |transform        |
+  |transform_keys   |
+  |transform_values |
+  |translate        |
+  |trim             |
+  |trunc            |
+  +-----------------+
+
+-- List all functions starting with `yea` or `windo`
+SHOW FUNCTIONS LIKE 'yea*|windo*';
+  +--------+
+  |function|
+  +--------+
+  |window  |
+  |year    |
+  +--------+
+
+-- Use normal regex pattern to list function names that has 4 characters
+-- with `t` as the starting character.
+SHOW FUNCTIONS LIKE 't[a-z][a-z][a-z]';
+  +--------+
+  |function|
+  +--------+
+  |tanh    |
+  |trim    |
+  +--------+
+{% endhighlight %}
+
+### Related statements
+- [DESCRIBE FUNCTION](sql-ref-syntax-aux-describe-function.html)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org