This topic describes how to encode an input string in the application/x-www-form-urlencoded MIME format and return the encoded 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_ENCODE(VARCHAR input)
VARCHAR URL_ENCODE(VARCHAR input, VARCHAR encoding)Input parameters
Parameter | Data type | Description |
input | VARCHAR | The input string. |
encoding | VARCHAR | The encoding format. The value can be 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 or the input parameters are in an invalid encoding format, NULL is returned.
Example 1
Test data
Table 1 T1
input
input(VARCHAR)
1
http://calcite.apache.org
2
http://test?a=b&c=d
3
http://Hello
4
test
Test statement
SELECT id, URL_ENCODE(input) AS `value` FROM T1;Test result
id (INT)
value (VARCHAR)
1
https%3A%2F%2Fcalcite.apache.org
2
http%3A%2F%2Ftest%3Fa%3Db%26c%3Dd
3
http%3A%2F%2F%E4%BD%A0%E5%A5%BD
4
test
Example 2
Test data
Table 1. T2
id (INT)
input(VARCHAR)
encoding(VARCHAR)
1
http://Hello
gb2312
2
http://test?a=b&c=d
UNKNOWN
Test statement
SELECT id, URL_ENCODE(input, encoding) AS `value` FROM T2;Test result
id (INT)
value (VARCHAR)
1
http%3A%2F%2F%C4%E3%BA%C3
2
NULL
References
For more information about the built-in functions that are supported by fully managed Flink, see Supported functions.
For more information about user-defined functions (UDFs), see UDFs and Manage UDFs.