tencent cloud

Feedback

CREATE FUNCTION

Last updated: 2023-11-08 15:12:12
    For a SQL job, you can upload a custom package and reference this package when configuring parameters for the job in the console. You can either upload a local package or use resources in the COS buckets (must be in the same region) of the current account.
    The package can be used as additional connector features. You can also use it to create user-defined functions (UDFs).

    Syntax

    Currently, Stream Compute Service supports packages written in Java and Scala. After uploading a custom package and referencing it in the console, you can use the following CREATE FUNCTION statement to declare it:
    CREATE TEMPORARY SYSTEM FUNCTION function name
    AS 'Full function class name' [LANGUAGE JAVA|SCALA]
    You can determine your own function name. Make sure it is unique. Full function class name should be the full name of a Java or Scala class, such as 'com.example.flink.MyCustomFunction'.

    Overwriting in case of identical names

    If there is a built-in function with the same name, it will be overwritten by the UDF created using the above statement. Therefore, please avoid using a function name that is identical to a built-in function, unless you intend to overwrite the built-in function.

    Function types

    Flink supports the following functions.

    Scalar function

    A user-defined scalar function converts one value to another value (one-to-one). Examples include the built-in string handling functions SUBSTRING and REPLACE.

    Table function

    A user-defined table function converts a value to a row of data (one-to-many) so that it can be used as the right table in JOIN operations.

    Aggregate function

    A user-defined aggregate function aggregates a set of values from multiple data rows into one value (many-to-one). Examples include the built-in functions MAX, MIN, and AVG.

    Table aggregate function

    A table aggregate function aggregates a set of values from multiple data rows into a new set of data rows (many-to-many).

    Async table function

    An async table function can be used as a special data source. For example, you can use it to connect to an external database or storage.

    UDF development

    Flink updates its APIs and documentation on a regular basis. For details, see the Flink document User-defined Functions. Stream Compute Service is compatible with the APIs of the open-source Flink 1.11.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support