All Products
Search
Document Center

Realtime Compute for Apache Flink:URL_DECODE

Last Updated:Mar 26, 2026

Decodes a URL-encoded string in application/x-www-form-urlencoded MIME format into a standard string.

Limits

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

Syntax

VARCHAR URL_DECODE(VARCHAR input)
VARCHAR URL_DECODE(VARCHAR input, VARCHAR encoding)

Parameters

Parameter Data type Description
input VARCHAR The URL-encoded input string.
encoding VARCHAR The character encoding used for decoding, such as GBK or UTF-8. Defaults to UTF-8. Optional.
If input contains invalid percent-encoding sequences, decoding fails and NULL is returned. The encoding specified must match the encoding used when the string was originally encoded, otherwise the output may be garbled or parsing may fail.

Examples

Example 1: Default UTF-8 decoding

Input data (T1)

id input (VARCHAR)
1 http://calcite.apache.org
2 https%3A%2F%2Fcalcite.apache.org
3 http%3A%2F%2Ftest%3Fa%3Db%26c%3Dd
4 http%3A%2F%2F%E4%BD%A0%E5%A5%BD
5 test
6 https%%3A%2F%2Fcalcite.apache.org

Test statement

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

Result

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

Row 1 returns the input unchanged because it is not URL-encoded. Row 6 returns NULL because %% is an invalid percent-encoding sequence.

Example 2: Decoding with a specified character encoding

Input data (T2)

id (INT) input (VARCHAR) encoding (VARCHAR)
1 https%3A%2F%2Fcalcite.apache.org% UTF-8
2 https%3A%2F%2Fcalcite.apache.org gb2312

Test statement

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

Result

id (INT) value (VARCHAR)
1 NULL
2 http://Hello

Row 1 returns NULL because the trailing % is an incomplete percent-encoding sequence.

What's next