All Products
Search
Document Center

MaxCompute:CODEPOINT_ARRAY

Last Updated:Mar 26, 2026

Returns an ARRAY<BIGINT> containing the numeric encoding of each character or byte in the input. For STRING, CHAR, and VARCHAR inputs, each element is a Unicode code point. For BINARY inputs, each element is an extended ASCII byte value in [0, 255].

Syntax

ARRAY<BIGINT> CODEPOINT_ARRAY(STRING|BINARY|CHAR|VARCHAR <str>)

Parameters

ParameterTypeRequiredDescription
strSTRING, BINARY, CHAR, or VARCHARYesThe input to convert.

Return value

Returns ARRAY<BIGINT>. The element values depend on the input type:

  • STRING, CHAR, VARCHAR — each element is a Unicode code point in the range [0, 0xD7FF] or [0xE000, 0x10FFFF].

  • BINARY — each element is an extended ASCII byte value in the range [0, 255].

If str is NULL or an unsupported type, the function returns an error.

Usage notes

CODEPOINT_ARRAY behaves differently depending on the input type:

  • For text types (STRING, CHAR, VARCHAR), the function treats the input as a sequence of Unicode characters and returns one code point per character.

  • For BINARY, the function treats the input as a raw byte sequence and returns one byte value per byte.

Examples

The following examples show CODEPOINT_ARRAY applied to all supported input types and the NULL error case.

-- STRING input: returns Unicode code points
SELECT CODEPOINT_ARRAY('foo');
-- [102, 111, 111]

-- CHAR input
SELECT CODEPOINT_ARRAY(CAST('foo' AS CHAR(20)));
-- [102, 111, 111]

-- VARCHAR input
SELECT CODEPOINT_ARRAY(CAST('hello' AS VARCHAR(6500)));
-- [104, 101, 108, 108, 111]

-- BINARY input: returns extended ASCII byte values
SELECT CODEPOINT_ARRAY(CAST('foo' AS BINARY));
-- [102, 111, 111]

-- NULL input: returns an error
SELECT CODEPOINT_ARRAY(null);
-- FAILED: ODPS-0130071:[1,8] Semantic analysis exception - function CODEPOINT_ARRAY is ambiguous with (VOID), candidates are ARRAY<BIGINT> CODEPOINT_ARRAY(BINARY arg0); ARRAY<BIGINT> CODEPOINT_ARRAY(CHAR(255) arg0); ARRAY<BIGINT> CODEPOINT_ARRAY(STRING arg0); ARRAY<BIGINT> CODEPOINT_ARRAY(VARCHAR(65535) arg0

Related functions