All Products
Search
Document Center

Realtime Compute for Apache Flink:URL_ENCODE

Last Updated:Mar 25, 2026

URL_ENCODE encodes a string in the application/x-www-form-urlencoded MIME format and returns the encoded result. Returns NULL if the input contains invalid values or the encoding is not supported.

Limits

Supported only in Realtime Compute for Apache Flink that uses Ververica Runtime (VVR) 8.0.8 or later.

Syntax

VARCHAR URL_ENCODE(VARCHAR input)
VARCHAR URL_ENCODE(VARCHAR input, VARCHAR encoding)

Parameters

ParameterData typeRequiredDefaultDescription
inputVARCHARYesThe string to encode.
encodingVARCHARNoUTF-8The character encoding to use. Valid values: GBK, UTF-8.

Return type

VARCHAR

Examples

Encode with default UTF-8 encoding

Test data (T1)

id (INT)input (VARCHAR)
1http://calcite.apache.org
2http://test?a=b&c=d
3http://Hello
4test

Test statement

SELECT
    id,
    URL_ENCODE(input) AS `value`
FROM
    T1;

Test result

id (INT)value (VARCHAR)
1https%3A%2F%2Fcalcite.apache.org
2http%3A%2F%2Ftest%3Fa%3Db%26c%3Dd
3http%3A%2F%2F%E4%BD%A0%E5%A5%BD
4test

Encode with a custom encoding

Test data (T2)

id (INT)input (VARCHAR)encoding (VARCHAR)
1http://Hellogb2312
2http://test?a=b&c=dUNKNOWN

Test statement

SELECT
    id,
    URL_ENCODE(input, encoding) AS `value`
FROM
    T2;

Test result

id (INT)value (VARCHAR)
1http%3A%2F%2F%C4%E3%BA%C3
2NULL

Row 2 returns NULL because UNKNOWN is not a supported encoding format.

What's next