featzhang opened a new pull request, #27351:
URL: https://github.com/apache/flink/pull/27351
**Background**
Apache Flink SQL currently provides `URL_DECODE(str)` to decode strings in
`application/x-www-form-urlencoded` format (introduced in [FLINK-34108]). In
practice, log data, tracking data, or external system inputs may contain
multi-level URL-encoded values, e.g., strings encoded multiple times by
upstream systems or due to redirects/proxies. The existing function only
performs a single decoding pass, requiring manual repeated calls for full
decoding.
**Problem**
* Single-pass decoding is insufficient for multi-level encoded values.
* Users must repeatedly apply `URL_DECODE`, reducing SQL readability and
increasing error risk.
**Solution**
* Extend `URL_DECODE` with an optional boolean parameter `recursive`.
* Signature:
```sql
URL_DECODE(str) -- existing behavior
URL_DECODE(str, recursive) -- new recursive option
```
* Behavior:
* `recursive = false` (default): single-pass decoding.
* `recursive = true`: repeatedly decodes until the result no longer
changes.
**Examples**
```sql
-- Single-pass decoding
SELECT URL_DECODE('%252Fpath%252Fto%252Fresource');
-- Result: '%2Fpath%2Fto%2Fresource'
-- Recursive decoding
SELECT URL_DECODE('%252Fpath%252Fto%252Fresource', true);
-- Result: '/path/to/resource'
```
**Compatibility**
* Fully backward-compatible; existing queries using `URL_DECODE(str)` remain
unchanged.
* The new parameter is optional and extends functionality without breaking
existing pipelines.
**Notes**
* Recursive decoding stops when the decoded result matches the previous
value.
* Useful for data cleansing, normalization, and multi-level encoded input
scenarios.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]