Skip to content

Support MAP type in RowJson and fix datetime parsing with spaces - #38865

Merged
damccorm merged 1 commit into
apache:masterfrom
damccorm:feature/rowjson-map-support
Jun 11, 2026
Merged

Support MAP type in RowJson and fix datetime parsing with spaces#38865
damccorm merged 1 commit into
apache:masterfrom
damccorm:feature/rowjson-map-support

Conversation

@damccorm

@damccorm damccorm commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Extends Beam's JSON serialization utility (RowJson) to support Map types, enabling seamless conversion of Rows containing map fields to and from JSON.

The Problem

While Beam's Row schema supports Map fields, the RowJson utility (which handles Row-to-JSON and JSON-to-Row conversions) did not have support for maps. Attempting to serialize or deserialize a Row with a Map field would result in unsupported type exceptions, blocking pipelines that rely on JSON serialization (such as those interfacing with external systems or using certain SQL operators).

The Fix

  • RowJson.java: Added map serialization logic inside RowJsonSerializer. When encountering a Map field, we now serialize it as a JSON object, recursively serializing the map's values based on their schema type.
  • RowJsonValueExtractors.java: Added MapExtractor to handle deserialization. It extracts JSON objects and reconstructs them into Java Map instances, converting keys to strings and recursively extracting values to match the expected Beam FieldType of the map's values.
  • RowJsonTest.java: Added comprehensive unit tests covering:
    • Maps with primitive keys and values (e.g., Map<String, Integer>).
    • Nested maps (maps within maps).
    • Maps containing complex types (like arrays or other rows).
    • Handling of null values within maps.

@github-actions github-actions Bot added the java label Jun 9, 2026
@damccorm
damccorm marked this pull request as ready for review June 11, 2026 19:17
@damccorm

Copy link
Copy Markdown
Contributor Author

R: @Abacn

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! 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 enhances the RowJson utility within the Apache Beam Java SDK by introducing support for MAP types, ensuring that Rows containing maps can be correctly serialized and deserialized. Furthermore, it improves the robustness of datetime parsing by accommodating datetime strings that include spaces, preventing potential failures during data processing.

Highlights

  • Map Type Support: Added support for MAP types in RowJson, enabling serialization and deserialization of Beam Rows containing map fields.
  • Datetime Parsing Fix: Updated the datetimeValueExtractor to correctly handle datetime strings that contain spaces by replacing them with 'T'.
  • Testing: Added comprehensive unit tests in RowJsonTest to cover map field scenarios and verify the fix for datetime parsing with spaces.
New Features

🧠 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 to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

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.

Customization

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.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 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.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request introduces support for the MAP type in RowJson serialization and deserialization, ensuring map keys are strings, and updates RowJsonValueExtractors to parse datetime strings containing spaces. The review feedback highlights two important improvements: replacing only the first space in datetime strings using replaceFirst to avoid corrupting timezone offsets, and using ImmutableMap instead of HashMap in tests to guarantee deterministic key ordering and prevent flaky tests.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@github-actions

Copy link
Copy Markdown
Contributor

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

@Abacn Abacn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks!

@damccorm
damccorm merged commit 5307c71 into apache:master Jun 11, 2026
21 of 22 checks passed
@damccorm
damccorm deleted the feature/rowjson-map-support branch June 11, 2026 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants