You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@beam.apache.org by "ahmedabu98 (via GitHub)" <gi...@apache.org> on 2026/06/09 18:57:01 UTC
[PR] [IcebergIO] Support TableIdentifiers with special characters [beam]
ahmedabu98 opened a new pull request, #38876:
URL: https://github.com/apache/beam/pull/38876
An attempt at a more efficient replication of #33293, which had some performance issues because it was eagerly parsing with JSON, and was reverted in #33575.
This PR only does JSON parsing when the table id has JSON-like characters or a dot in the namespace / name.
------------------------
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
- [ ] Mention the appropriate issue in your description (for example: `addresses #123`), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment `fixes #<ISSUE NUMBER>` instead.
- [ ] Update `CHANGES.md` with noteworthy changes.
- [ ] If this contribution is large, please file an Apache [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
See the [Contributor Guide](https://beam.apache.org/contribute) for more tips on [how to make review process smoother](https://github.com/apache/beam/blob/master/CONTRIBUTING.md#make-the-reviewers-job-easier).
To check the build health, please visit [https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md](https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md)
GitHub Actions Tests Status (on master branch)
------------------------------------------------------------------------------------------------
[](https://github.com/apache/beam/actions?query=workflow%3A%22Build+python+source+distribution+and+wheels%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Python+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Java+Tests%22+branch%3Amaster+event%3Aschedule)
[](https://github.com/apache/beam/actions?query=workflow%3A%22Go+tests%22+branch%3Amaster+event%3Aschedule)
See [CI.md](https://github.com/apache/beam/blob/master/CI.md) for more information about GitHub Actions CI or the [workflows README](https://github.com/apache/beam/blob/master/.github/workflows/README.md) to see a list of phrases to trigger workflows.
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [IcebergIO] Support TableIdentifiers with special characters [beam]
Posted by "ahmedabu98 (via GitHub)" <gi...@apache.org>.
ahmedabu98 commented on PR #38876:
URL: https://github.com/apache/beam/pull/38876#issuecomment-4663050881
R: @regadas
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [IcebergIO] Support TableIdentifiers with special characters [beam]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #38876:
URL: https://github.com/apache/beam/pull/38876#issuecomment-4663062355
Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment `assign set of reviewers`
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [IcebergIO] Support TableIdentifiers with special characters [beam]
Posted by "ahmedabu98 (via GitHub)" <gi...@apache.org>.
ahmedabu98 merged PR #38876:
URL: https://github.com/apache/beam/pull/38876
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [IcebergIO] Support TableIdentifiers with special characters [beam]
Posted by "ahmedabu98 (via GitHub)" <gi...@apache.org>.
ahmedabu98 commented on PR #38876:
URL: https://github.com/apache/beam/pull/38876#issuecomment-4960404675
@clairemcginty PTAL
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [IcebergIO] Support TableIdentifiers with special characters [beam]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on PR #38876:
URL: https://github.com/apache/beam/pull/38876#issuecomment-4663049888
## Summary of Changes
Hello, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!
This pull request improves the handling of Iceberg table identifiers in the Beam Iceberg IO connector. By introducing a conditional JSON parsing strategy, it enables support for table names and namespaces containing dots or other special characters while avoiding the performance overhead of eager JSON parsing for standard identifiers. This change ensures robust compatibility with complex table naming conventions.
### Highlights
* **Improved TableIdentifier Parsing**: Introduced `IcebergUtils.parseTableIdentifier` and `IcebergUtils.tableIdentifierToString` to handle Iceberg table identifiers containing special characters like dots, using JSON serialization only when necessary to maintain performance.
* **Refactored IO Classes**: Updated multiple Iceberg IO classes (AddFiles, AppendFilesToTables, AssignDestinationsAndPartitions, etc.) to use the new utility methods instead of direct `TableIdentifier.parse` calls.
* **Enhanced Test Coverage**: Added comprehensive unit tests in `IcebergUtilsTest` to verify correct parsing and round-tripping of table identifiers with special characters.
<details>
<summary><b>New Features</b></summary>
🧠You can now enable **Memory** (public preview) to help **Gemini Code Assist** learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. **Click [here](https://codeassist.google/code-review/login) to enable Memory in your admin console.**
</details>
<details>
<summary><b>Using Gemini Code Assist</b></summary>
<br>
The full guide for Gemini Code Assist can be found on our [documentation page](https://developers.google.com/gemini-code-assist/docs/review-github-code), here are some quick tips.
<b>Invoking Gemini</b>
You can request assistance from Gemini at any point by creating a comment using either `/gemini <command>` or `@gemini-code-assist <command>`. Below is a summary of the supported commands on the current page.
Feature | Command | Description
--- | --- | ---
Code Review | `/gemini review` | Performs a code review for the current pull request in its current state.
Pull Request Summary | `/gemini summary` | Provides a summary of the current pull request in its current state.
Comment | @gemini-code-assist | Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help | `/gemini help` | Displays a list of available commands.
<b>Customization</b>
To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a `.gemini/` folder in the base of the repository. Detailed instructions can be found [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github).
<b>Limitations & Feedback</b>
Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up [here](https://google.qualtrics.com/jfe/form/SV_2cyuGuTWsEw84yG).
</details>
[^1]: Review the [Privacy Notices](https://policies.google.com/privacy), [Generative AI Prohibited Use Policy](https://policies.google.com/terms/generative-ai/use-policy), [Terms of Service](https://policies.google.com/terms), and learn how to configure Gemini Code Assist in GitHub [here](https://developers.google.com/gemini-code-assist/docs/customize-gemini-behavior-github). Gemini can make mistakes, so double check it and [use code with caution](https://support.google.com/legal/answer/13505487).
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [IcebergIO] Support TableIdentifiers with special characters [beam]
Posted by "ahmedabu98 (via GitHub)" <gi...@apache.org>.
ahmedabu98 commented on code in PR #38876:
URL: https://github.com/apache/beam/pull/38876#discussion_r3383266217
##########
sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/IcebergUtils.java:
##########
@@ -631,6 +633,51 @@ private static Object getLogicalTypeValue(Object icebergValue, Schema.FieldType
return icebergValue;
}
+ /** Serializes a table identifier without losing dots or other special characters in each part. */
+ public static String tableIdentifierToString(TableIdentifier tableIdentifier) {
+ TableIdentifier identifier = checkArgumentNotNull(tableIdentifier);
+ return requiresJsonTableIdentifier(identifier)
+ ? TableIdentifierParser.toJson(identifier)
+ : identifier.toString();
+ }
+
+ /** Parses either Iceberg's JSON table identifier representation or the legacy dotted form. */
+ public static TableIdentifier parseTableIdentifier(String table) {
+ if (startsWithJsonObject(table)) {
+ return TableIdentifierParser.fromJson(table);
+ }
+
+ return TableIdentifier.parse(table);
+ }
+
+ private static boolean startsWithJsonObject(@Nullable String value) {
+ if (value == null) {
+ return false;
+ }
+
+ for (int i = 0; i < value.length(); i++) {
+ if (!Character.isWhitespace(value.charAt(i))) {
+ return value.charAt(i) == '{';
+ }
+ }
+
+ return false;
+ }
Review Comment:
Done
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [IcebergIO] Support TableIdentifiers with special characters [beam]
Posted by "gemini-code-assist[bot] (via GitHub)" <gi...@apache.org>.
gemini-code-assist[bot] commented on code in PR #38876:
URL: https://github.com/apache/beam/pull/38876#discussion_r3383122705
##########
sdks/java/io/iceberg/src/main/java/org/apache/beam/sdk/io/iceberg/IcebergUtils.java:
##########
@@ -631,6 +633,51 @@ private static Object getLogicalTypeValue(Object icebergValue, Schema.FieldType
return icebergValue;
}
+ /** Serializes a table identifier without losing dots or other special characters in each part. */
+ public static String tableIdentifierToString(TableIdentifier tableIdentifier) {
+ TableIdentifier identifier = checkArgumentNotNull(tableIdentifier);
+ return requiresJsonTableIdentifier(identifier)
+ ? TableIdentifierParser.toJson(identifier)
+ : identifier.toString();
+ }
+
+ /** Parses either Iceberg's JSON table identifier representation or the legacy dotted form. */
+ public static TableIdentifier parseTableIdentifier(String table) {
+ if (startsWithJsonObject(table)) {
+ return TableIdentifierParser.fromJson(table);
+ }
+
+ return TableIdentifier.parse(table);
+ }
+
+ private static boolean startsWithJsonObject(@Nullable String value) {
+ if (value == null) {
+ return false;
+ }
+
+ for (int i = 0; i < value.length(); i++) {
+ if (!Character.isWhitespace(value.charAt(i))) {
+ return value.charAt(i) == '{';
+ }
+ }
+
+ return false;
+ }
Review Comment:

The current implementation of `startsWithJsonObject` only checks if the first non-whitespace character is `{`. This can lead to false positives for legacy table identifiers that start with `{` but are not JSON (e.g., `{dogs}.food`). If such an identifier is passed to `parseTableIdentifier`, it will incorrectly attempt to parse it as JSON and fail.
We can make this check much more robust by verifying that the string both starts with `{` and ends with `}` (ignoring leading/trailing whitespace). This ensures that only actual JSON-like strings are treated as JSON, while legacy dotted strings like `{dogs}.food` are safely parsed using the legacy parser.
```java
private static boolean startsWithJsonObject(@Nullable String value) {
if (value == null) {
return false;
}
int start = 0;
while (start < value.length() && Character.isWhitespace(value.charAt(start))) {
start++;
}
if (start == value.length() || value.charAt(start) != '{') {
return false;
}
int end = value.length() - 1;
while (end >= 0 && Character.isWhitespace(value.charAt(end))) {
end--;
}
return end >= 0 && value.charAt(end) == '}';
}
```
##########
sdks/java/io/iceberg/src/test/java/org/apache/beam/sdk/io/iceberg/IcebergUtilsTest.java:
##########
@@ -60,6 +65,57 @@
@RunWith(Enclosed.class)
public class IcebergUtilsTest {
+ @RunWith(JUnit4.class)
+ public static class TableIdentifierTests {
+
+ @Test
+ public void parseTableIdentifierParsesJson() {
+ TableIdentifier identifier =
+ parseTableIdentifier(
+ " {\"namespace\": [\"dogs\", \"owners.and.handlers\"],"
+ + " \"name\": \"food.with.dots\"}");
+
+ assertArrayEquals(
+ new String[] {"dogs", "owners.and.handlers"}, identifier.namespace().levels());
+ assertEquals("food.with.dots", identifier.name());
+ }
+
+ @Test
+ public void parseTableIdentifierParsesLegacyDottedString() {
+ TableIdentifier identifier = parseTableIdentifier("dogs.owners.and.handlers.food");
+
+ assertArrayEquals(
+ new String[] {"dogs", "owners", "and", "handlers"}, identifier.namespace().levels());
+ assertEquals("food", identifier.name());
+ }
+
+ @Test
+ public void tableIdentifierToStringRoundTripsSpecialCharacters() {
+ TableIdentifier expected =
+ TableIdentifier.of("dogs", "owners.and.handlers", "food.with.dots");
+
+ assertEquals(expected, parseTableIdentifier(tableIdentifierToString(expected)));
+ }
+
+ @Test
+ public void tableIdentifierToStringUsesLegacyFormWhenUnambiguous() {
+ assertEquals("dogs.food", tableIdentifierToString(TableIdentifier.of("dogs", "food")));
+ }
+
+ @Test
+ public void tableIdentifierToStringUsesJsonForLegacyStringsThatLookLikeJson() {
+ TableIdentifier expected = TableIdentifier.of("{dogs}", "food");
+
+ assertEquals(expected, parseTableIdentifier(tableIdentifierToString(expected)));
+ }
Review Comment:

With the improved `startsWithJsonObject` check, a table identifier like `TableIdentifier.of("{dogs}", "food")` will no longer be serialized as JSON because its legacy string representation `"{dogs}.food"` does not end with `}`. To keep the test's intent of verifying JSON serialization for strings that look like JSON, we should update the expected identifier to `TableIdentifier.of("{dogs}", "{food}")` (which starts with `{` and ends with `}`). We can also add a test to verify that partial JSON-like strings correctly fall back to the legacy dotted format.
```java
@Test
public void tableIdentifierToStringUsesJsonForLegacyStringsThatLookLikeJson() {
TableIdentifier expected = TableIdentifier.of("{dogs}", "{food}");
assertEquals(expected, parseTableIdentifier(tableIdentifierToString(expected)));
}
@Test
public void tableIdentifierToStringDoesNotUseJsonForPartialJsonLikeStrings() {
TableIdentifier expected = TableIdentifier.of("{dogs}", "food");
assertEquals("{dogs}.food", tableIdentifierToString(expected));
assertEquals(expected, parseTableIdentifier(tableIdentifierToString(expected)));
}
```
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [IcebergIO] Support TableIdentifiers with special characters [beam]
Posted by "derrickaw (via GitHub)" <gi...@apache.org>.
derrickaw commented on PR #38876:
URL: https://github.com/apache/beam/pull/38876#issuecomment-4916181381
Hi @ahmedabu98, can you fix these conflicts and then ping reviewer again? Thanks!
--
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: github-unsubscribe@beam.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org