dilipbiswal commented on a change in pull request #25894:
[SPARK-28793][DOC][SQL] Document CREATE FUNCTION in SQL Reference
URL: https://github.com/apache/spark/pull/25894#discussion_r326950965
##########
File path: docs/sql-ref-syntax-ddl-create-function.md
##########
@@ -19,4 +19,148 @@ license: |
limitations under the License.
---
-**This page is under construction**
+### Description
+`CREATE FUNCTION` statement is used to create a temporary or permanent function
+in Spark. Temporary functions are scoped at a session level where as permanent
+functions are created in the persistent catalog and are made available to
+all sessions. The resources specified in the `USING` clause are made available
+to all executors when they are executed for the first time.
+
+### Syntax
+{% highlight sql %}
+CREATE [ OR REPLACE ] [ TEMPORARY ] FUNCTION [ IF NOT EXISTS ]
+ function_name AS class_name [ resource_locations ]
+{% endhighlight %}
+
+### Parameters
+<dl>
+ <dt><code><em>OR REPLACE</em></code></dt>
+ <dd>
+ If specified, the resources for function are reloaded. This is mainly
useful
+ to pick up any changes made to the implementation of the function. This
+ parameter is mutually exclusive to <code>IF NOT EXISTS</code> and can not
+ be specified together.
+ </dd>
+ <dt><code><em>TEMPORARY</em></code></dt>
+ <dd>
+ Indicates the scope of function being created. When TEMPORARY is
specified, the
+ created function is valid in the current session. No persistent entry is
made
+ in the catalog for these kind of functions.
+ </dd>
+ <dt><code><em>IF NOT EXISTS</em></code></dt>
+ <dd>
+ If specified, creates the function only when it does not exist. The
creation
+ of function succeeds (no error is thrown), if the specified function
already
+ exists in the system. This parameter is mutually exclusive to <code> OR
REPLACE</code>
+ and can not be specified together.
+ </dd>
+ <dt><code><em>function_name</em></code></dt>
+ <dd>
+ Specifies a name of funnction to be created. The function name may be
+ optionally qualified with a database name. <br><br>
+ <b>Syntax:</b>
+ <code>
+ [database_name.]function_name
+ </code>
+ </dd>
+ <dt><code><em>class_name</em></code></dt>
+ <dd>
+ Specifies the name of the class that provides the implementation for
function to be created.
+ The implementing class should extend from one of the base classes in
`Hive` as follows:
+ <ul>
+ <li>Should extend UDF or UDAF in org.apache.hadoop.hive.ql.exec</li>
+ <li>Should extend AbstractGenericUDAFResolver, GenericUDF, or
GenericUDTF in org.apache.hadoop.hive.ql.udf.generic.</li>
+ </ul>
+ </dd>
+ <dt><code><em>resource_locations</em></code></dt>
+ <dd>
+ Specifies the list of resources that contain the implementation of the
function
+ along with its dependencies. <br><br>
+ <b>Syntax:</b>
+ <code>
+ USING { { (JAR | FILE ) resource_uri} , ...}
+ </code>
+ </dd>
+</dl>
+
+### Examples
+{% highlight sql %}
+-- 1. Create a simple UDF `SimpleUdf` that adds the supplied integet value by
10.
Review comment:
@gatorsmile fixed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]