Skip to content

feat(writer): URL encode field names for partition paths#2875

Open
hsiang-c wants to merge 2 commits into
apache:mainfrom
hsiang-c:fix_partition_with_special_chars
Open

feat(writer): URL encode field names for partition paths#2875
hsiang-c wants to merge 2 commits into
apache:mainfrom
hsiang-c:fix_partition_with_special_chars

Conversation

@hsiang-c

@hsiang-c hsiang-c commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Which issue does this PR close?

What changes are included in this PR?

  • URL encoded the string components used in the partition_to_path function so that we can tolerate schema with special characters in the fields.

Are these changes tested?

Unit tests

@hsiang-c
hsiang-c marked this pull request as ready for review July 21, 2026 23:49

@CTTY CTTY left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I have left some comments

field
.transform
.to_human_string(&field_types[i].field_type, value)
urlencoding::encode(field.name.as_str()).into_owned(),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took a look at Java's code and noticed that java's URLEncoder actually follows application/x-www-form-urlencoded rather than RFC 3986. If we want to be as close as to java's behavior, then we should use form_urlencoded, which implements the application/x-www-form-urlencoded serializer

This actually makes a difference as form_urlencoded and java URLEncoder will convert space to +, while urlencoding will convert space to %20. and space is the most common special character used

Comment thread crates/iceberg/Cargo.toml
typed-builder = { workspace = true }
typetag = { workspace = true }
url = { workspace = true }
urlencoding = "2.1.3"

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should maintain this version in the root Cargo.toml

}

#[test]
fn test_location_generate_with_special_characters_partitionq() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo:

Suggested change
fn test_location_generate_with_special_characters_partitionq() {
fn test_location_generate_with_special_characters_partition() {

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

URL encode field names with special characters for partition paths

2 participants