-
Notifications
You must be signed in to change notification settings - Fork 25.6k
ESQL: URL encoding changes #134503
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ESQL: URL encoding changes #134503
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances URL encoding functionality in ESQL by modifying existing functions and adding a new URL encoding variant. The main purpose is to provide more compliant URL encoding with different space encoding behaviors.
Key changes:
- Modified
URL_ENCODEto encode spaces as+instead of%20 - Added new
URL_ENCODE_COMPONENTfunction that encodes spaces as%20 - Enhanced
URL_DECODEto gracefully handle invalid input by returning null and adding warnings
Reviewed Changes
Copilot reviewed 31 out of 34 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| UrlEncodeComponent.java | New scalar function implementation for component-style URL encoding |
| UrlEncode.java | Updated to use custom encoding that produces + for spaces |
| UrlDecode.java | Enhanced with exception handling for graceful failure |
| UrlCodecUtils.java | New utility class providing custom URL encoding codecs |
| EsqlFunctionRegistry.java | Registered the new URL_ENCODE_COMPONENT function |
| string.csv-spec | Updated test cases and examples for new encoding behaviors |
| Various test files | Added comprehensive test coverage for the new function |
| Documentation files | Updated function descriptions and examples |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
...t/java/org/elasticsearch/xpack/esql/expression/function/AbstractUrlEncodeDecodeTestCase.java
Outdated
Show resolved
Hide resolved
ℹ️ Important: Docs version tagging👋 Thanks for updating the docs! Just a friendly reminder that our docs are now cumulative. This means all 9.x versions are documented on the same page and published off of the main branch, instead of creating separate pages for each minor version. We use applies_to tags to mark version-specific features and changes. Expand for a quick overviewWhen to use applies_to tags:✅ At the page level to indicate which products/deployments the content applies to (mandatory) What NOT to do:❌ Don't remove or replace information that applies to an older version 🤔 Need help?
|
5945402 to
58925f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 31 out of 34 changed files in this pull request and generated 3 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/60_usage.yml
Outdated
Show resolved
Hide resolved
...est/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/UrlDecodeTests.java
Outdated
Show resolved
Hide resolved
...t/java/org/elasticsearch/xpack/esql/expression/function/AbstractUrlEncodeDecodeTestCase.java
Outdated
Show resolved
Hide resolved
58925f6 to
ae03646
Compare
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
|
Pinging @elastic/kibana-esql (ES|QL-ui) |
97fb60a to
9048842
Compare
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/util/UrlCodecUtils.java
Outdated
Show resolved
Hide resolved
9048842 to
6d5b121
Compare
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/util/UrlCodecUtils.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/util/UrlCodecUtils.java
Outdated
Show resolved
Hide resolved
x-pack/plugin/esql-core/src/main/java/org/elasticsearch/xpack/esql/core/util/UrlCodecUtils.java
Outdated
Show resolved
Hide resolved
...t/java/org/elasticsearch/xpack/esql/expression/function/AbstractUrlEncodeDecodeTestCase.java
Outdated
Show resolved
Hide resolved
...est/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/UrlDecodeTests.java
Show resolved
Hide resolved
...t/java/org/elasticsearch/xpack/esql/expression/function/AbstractUrlEncodeDecodeTestCase.java
Outdated
Show resolved
Hide resolved
...java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/UrlEncodeComponent.java
Show resolved
Hide resolved
...src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/UrlEncode.java
Outdated
Show resolved
Hide resolved
21fe748 to
96fd1a2
Compare
3cd4855 to
9a44483
Compare
...src/main/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/UrlEncode.java
Show resolved
Hide resolved
9a44483 to
88802bc
Compare
0214f71 to
0516afa
Compare
- Change URL_ENCODE to encode spaces as +. - Add a new URL_ENCODE_COMPONENT scalar function, which encodes spaces as %20. - Both encoding functions encode all characters in the input except for alphanumerics, ., -, _, and ~. - Allow URL_DECODE to fail gracefully if the input can't be decoded, by returning null and adding a warning in the header, similar to other scalar functions. - Update csv-tests: - Test decoding for both + and %20 back to space. - Reduce the length of doc lines to less than 76 chars, as mentioned in the contribution guide. - Minor changes to the documentation.
- Manually perform percent-encoding directly on the BreakingBytesRefBuilder scratch area, and only if the input was gonna change after encoding. - Use Apache's PercentEncode as the ground truth during unit testing. - Add test cases with fixed strings.
- Add fixed test cases that fail decoding - Randomize the encoder used in decoding tests - Add url_encode_component capability to some encode/decode tests whose behavior changed to ensure they only run if the url_encode_component capability is available
0516afa to
6b2e950
Compare
- Change URL_ENCODE to encode spaces as +. - Add a new URL_ENCODE_COMPONENT scalar function, which encodes spaces as %20. - Both encoding functions encode all characters in the input except for alphanumerics, ., -, _, and ~. - Allow URL_DECODE to fail gracefully if the input can't be decoded, by returning null and adding a warning in the header, similar to other scalar functions. - Manually perform percent-encoding directly on the BreakingBytesRefBuilder scratch area, and only if the input was gonna change after encoding. - Update csv-tests: - Test decoding for both + and %20 back to space. - Reduce the length of doc lines to less than 76 chars, as mentioned in the contribution guide. - Add test cases with fixed strings - Minor changes to the documentation. - Update Unit tests: - Add fixed test cases that fail decoding - Randomize the encoder used in decoding tests - Use Apache's PercentEncode as the ground truth during unit testing.
- Change URL_ENCODE to encode spaces as +. - Add a new URL_ENCODE_COMPONENT scalar function, which encodes spaces as %20. - Both encoding functions encode all characters in the input except for alphanumerics, ., -, _, and ~. - Allow URL_DECODE to fail gracefully if the input can't be decoded, by returning null and adding a warning in the header, similar to other scalar functions. - Manually perform percent-encoding directly on the BreakingBytesRefBuilder scratch area, and only if the input was gonna change after encoding. - Update csv-tests: - Test decoding for both + and %20 back to space. - Reduce the length of doc lines to less than 76 chars, as mentioned in the contribution guide. - Add test cases with fixed strings - Minor changes to the documentation. - Update Unit tests: - Add fixed test cases that fail decoding - Randomize the encoder used in decoding tests - Use Apache's PercentEncode as the ground truth during unit testing.
BASE=62e53cd13c8846f0729390450a5cfbd0304e7f40 HEAD=6b2e950488ed317736d19f100fbcf58bb587fea4 Branch=main
BASE=62e53cd13c8846f0729390450a5cfbd0304e7f40 HEAD=6b2e950488ed317736d19f100fbcf58bb587fea4 Branch=main
BASE=62e53cd13c8846f0729390450a5cfbd0304e7f40 HEAD=6b2e950488ed317736d19f100fbcf58bb587fea4 Branch=main
BASE=62e53cd13c8846f0729390450a5cfbd0304e7f40 HEAD=6b2e950488ed317736d19f100fbcf58bb587fea4 Branch=main
URL_ENCODEto encode spaces as+.URL_ENCODE_COMPONENTscalar function, which encodes spaces as%20..,-,_, and~.URL_DECODEto fail gracefully if the input can't be decoded, by returning null and adding a warning in the header, similar to other scalar functions.- Test decoding for both
+and%20back to space.- Reduce the length of doc lines to less than 76 chars, as mentioned in the contribution guide.