Updated on 2026-11-06 GMT+08:00

URL_ENCODE

Syntax

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

Description

The URL_ENCODE function is used to encode an input string in application/x-www-form-urlencoded MIME format and return the encoded string.

Input Parameters

Parameter

Data Type

Description

input

VARCHAR

This parameter specifies the input string.

encoding

VARCHAR

This parameter is optional. It specifies the encoding format, which can be GBK or UTF-8. If this parameter is not specified, the default value UTF-8 is used.

Example

CREATE TABLE source (
  f_sequence INT
) WITH (
  'connector' = 'datagen',
  'rows-per-second' = '1'
);
CREATE TABLE print with(
'connector' = 'print'
) as select
  URL_ENCODE ('http://calcite.apache.org') as value1,
  URL_ENCODE ('http://test?a=b&c=d') as value2,
  URL_ENCODE ('http://Hello') as value3,
  URL_ENCODE ('test') as value4,
  URL_ENCODE ('http://Hello', 'gb2312') as value5
from source;
Table 1 Returned Result

value1(VARCHAR)

value2(VARCHAR)

value3(VARCHAR)

value4(VARCHAR)

value5(VARCHAR)

http%3A%2F%2Fcalcite.apache.org

http%3A%2F%2Ftest%3Fa%3Db%26c%3Dd

http%3A%2F%2F%E4%BD%A0%E5%A5%BD

test

http%3A%2F%2F%C4%E3%BA%C3