edit-icon download-icon

Process data by using UDF

Last Updated: Mar 15, 2018

If your data stored in Table Store is uniquely structured and you want to define development logic to process each line of data (for example, parsing a specific JSON string), you can use User Defined Function (UDF).


  1. Install MaxCompute-Java/MaxCompute-Studio plug-in in IntelliJ. Development can be started when the plug-in is installed.

    The following figure shows a simple UDF definition, which connects two strings. MaxCompute supports more complex UDF, for example, user-defined window execution logic.


  2. Upload the resource to MaxCompute after packaging.

    Select File > Project Structure > Artifacts. Enter the Name and the Output directory, then click + to select the output module. After packaging, upload the resource and create a function using ODPS Project Explorer, and then you can call it in SQL.


  3. Run bin/odpscmd.bat.

    1. // Select a line of data, and pass name/name into the UDF. A connection of the two strings is returned.
    2. select cloud_metric_extract_md5(name, name) as udf_test from test_table limit 1;

    The returned result is displayed as follows.


Thank you! We've received your feedback.