Creating a Function

Function

This API is used to create a function.

Syntax

1
2
3
4
5
CREATE [TEMPORARY] FUNCTION [db_name.]function_name AS class_name
  [USING resource,...]

resource: 
  : (JAR|FILE|ARCHIVE)file_uri

Keywords

  • TEMPORARY: The created function is available only in the current session and is not persisted to the underlying metabase, if any. The database name cannot be specified for a temporary function.
  • USING <resources>: resources to be loaded. It can be a list of JARs, files, or URIs.

Precautions

  • If a function with the same name exists in the database, the system reports an error.
  • Only the Hive syntax can be used to create functions.

Example

Create the mergeBill function.

1
2
CREATE FUNCTION mergeBill AS 'com.huawei.cloudbi.hiveudf.MergeBill'
  using jar 'obs://onlyci-7/udf/MergeBill.jar';