Back to home page

OSCL-LXR

 
 

    


0001 ---
0002 layout: global
0003 title: Scalar User Defined Functions (UDFs)
0004 displayTitle: Scalar User Defined Functions (UDFs)
0005 license: |
0006   Licensed to the Apache Software Foundation (ASF) under one or more
0007   contributor license agreements.  See the NOTICE file distributed with
0008   this work for additional information regarding copyright ownership.
0009   The ASF licenses this file to You under the Apache License, Version 2.0
0010   (the "License"); you may not use this file except in compliance with
0011   the License.  You may obtain a copy of the License at
0012 
0013      http://www.apache.org/licenses/LICENSE-2.0
0014 
0015   Unless required by applicable law or agreed to in writing, software
0016   distributed under the License is distributed on an "AS IS" BASIS,
0017   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0018   See the License for the specific language governing permissions and
0019   limitations under the License.
0020 ---
0021 
0022 ### Description
0023 
0024 User-Defined Functions (UDFs) are user-programmable routines that act on one row. This documentation lists the classes that are required for creating and registering UDFs. It also contains examples that demonstrate how to define and register UDFs and invoke them in Spark SQL.
0025 
0026 ### UserDefinedFunction
0027 
0028 To define the properties of a user-defined function, the user can use some of the methods defined in this class.
0029 
0030 * **asNonNullable(): UserDefinedFunction**
0031 
0032     Updates UserDefinedFunction to non-nullable.
0033 
0034 * **asNondeterministic(): UserDefinedFunction**
0035 
0036     Updates UserDefinedFunction to nondeterministic.
0037 
0038 * **withName(name: String): UserDefinedFunction**
0039 
0040     Updates UserDefinedFunction with a given name.
0041 
0042 ### Examples
0043 
0044 <div class="codetabs">
0045 <div data-lang="scala"  markdown="1">
0046 {% include_example udf_scalar scala/org/apache/spark/examples/sql/UserDefinedScalar.scala%}
0047 </div>
0048 <div data-lang="java"  markdown="1">
0049   {% include_example udf_scalar java/org/apache/spark/examples/sql/JavaUserDefinedScalar.java%}
0050 </div>
0051 </div>
0052 
0053 ### Related Statements
0054 * [User Defined Aggregate Functions (UDAFs)](sql-ref-functions-udf-aggregate.html)
0055 * [Integration with Hive UDFs/UDAFs/UDTFs](sql-ref-functions-udf-hive.html)