All Products
Search
Document Center

MaxCompute:SPLIT

最終更新日:Aug 21, 2023

Returns an array after str is split with pat.

Syntax

split(<str>, <pat>, [<trimTailEmpty>])

Parameters

  • str: required. A value of the STRING type. This parameter specifies the string that you want to split.

  • pat: required. A delimiter of the STRING type. Regular expressions are supported. For more information about regular expressions, see Regular expressions.

  • trimTailEmpty: optional. The default value is true. If you set this parameter to false, the empty string at the end of the array is reserved. This rule applies when the hive-compatible data type edition is enabled.

Return value

An array is returned. The elements in the array are of the STRING type.

Examples

-- The return value is ["a"," b"," c"]. 
select split("a, b, c", ",");

-- No empty string is returned by default.
select split("a, b, c,,", ",");
-- The following result is returned:
+------------+
| _c0        |
+------------+
| ["a"," b"," c"] |
+------------+

-- If you need to return an empty string, execute the following statement:
select split("a, b, c,,", ",", false);
-- The following result is returned:
+------------+
| _c0        |
+------------+
| ["a"," b"," c","",""] |
+------------+

Related functions

SPLIT is a complex type function. For more information about the functions that are used to process data of complex data types, such as ARRAY, MAP, STRUCT, and JSON, see Complex type functions.