This topic describes how to convert an input string in the application/x-www-form-urlencoded MIME format into a standard string.
Limits
This function is 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)Input parameters
Parameter | Data type | Description |
input | VARCHAR | The input string. |
encoding | VARCHAR | The decoding format. such as GBK or UTF-8. If you do not configure this parameter, the default value UTF-8 is used. This parameter is optional. |
If the input parameters contain invalid values, the decoding fails and NULL is returned.
The decoding format must be the same as the encoding format. Otherwise, data may fail to be parsed.
Example 1
Test data
Table 1 T1
input
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;Test result
id (INT)
value (VARCHAR)
1
https://calcite.apache.org
2
https://calcite.apache.org
3
http://test?a=b&c=d
4
http://Hello
5
test
6
NULL
Example 2
Test data
Table 1. 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;Test result
id (INT)
value (VARCHAR)
1
NULL
2
http://Hello
References
For more information about the built-in functions that are supported by Realtime Compute for Apache Flink, see Supported functions.
For more information about user-defined functions (UDFs), see UDFs and Manage UDFs.