Use these examples to implement common user-defined function (UDF) scenarios in MaxCompute, including Hive compatibility, complex type handling, string manipulation, and resource referencing.
Java UDFs
-
Write a Hive UDF in Java — Write a Java UDF in MaxCompute that is compatible with the Hive UDF interface.
-
Use complex data types in Java UDFs — Work with ARRAY, MAP, and STRUCT types as UDF input or output parameters.
String operations
-
Replace strings by using regular expressions — Apply pattern-based string substitution in a UDF using regular expressions.
-
Obtain the values of strings that have no delimiters — Extract substrings from undelimited input strings.
-
Obtain the values of strings that have delimiters — Parse and extract values from delimiter-separated strings.
Resource references
-
Reference a file resource — Read an external file inside a UDF by referencing it as a file resource.
-
Reference a table resource — Access MaxCompute table data inside a UDF by referencing it as a table resource.
Python UDFs
-
Reference third-party packages in Python UDFs — Import and use external Python packages in a UDF.