Skip to content

Skip flattening for mutations across imports#480

Open
vish-cs wants to merge 1 commit intodatacommonsorg:masterfrom
vish-cs:mcf
Open

Skip flattening for mutations across imports#480
vish-cs wants to merge 1 commit intodatacommonsorg:masterfrom
vish-cs:mcf

Conversation

@vish-cs
Copy link
Contributor

@vish-cs vish-cs commented Feb 26, 2026

We currently flatten mutations across all imports and write to spanner. This PR processes each import independently to avoid any cross-dependency.
Updated wait signals for spanner writes to perform node writes without waiting for edge/obs deletions to complete.
Added import name to all the dataflow steps for easier debugging.
Also, remove edge generation for dcid property.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @vish-cs, 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 significantly refactors the graph ingestion pipeline by changing how mutations are handled. Instead of aggregating all mutations from various imports and then flattening them for a single write operation, the pipeline now processes and writes mutations for each import individually. This change streamlines the data flow, improves the correctness of dependency handling between delete and write operations, and enhances the clarity of the ingestion process by isolating mutation handling per import.

Highlights

  • Refactored Mutation Processing: The pipeline now processes and writes mutations for each import independently, eliminating the previous approach of collecting and flattening all mutations across multiple imports before writing.
  • Streamlined Dependency Management: Delete operations and subsequent writes for nodes, edges, and observations are now chained directly within the processing of each individual import, ensuring correct order and dependencies.
  • Improved GraphReader Logic: The GraphReader was updated to explicitly skip 'dcid' properties when generating edges, preventing potential incorrect edge creation.
  • Simplified Integration Tests: Integration tests were adjusted to reflect the per-import processing, removing the need for dynamically generated import names.
Changelog
  • pipeline/ingestion/src/main/java/org/datacommons/ingestion/pipeline/GraphIngestionPipeline.java
    • Removed global lists for collecting mutations (delete, observation, node, edge) from buildPipeline.
    • Modified the processImport method signature to remove parameters for mutation collection lists.
    • Implemented per-import delete operations for observations and edges, introducing PCollection<Void> signals (deleteObsWait, deleteEdgesWait) for dependency management.
    • Integrated direct calls to spannerClient.writeMutations within the processImport loop for nodes, edges, and observations, ensuring mutations are written per import and respect dependencies.
    • Updated GraphReader.graphToNodes and GraphReader.graphToEdges calls to include an importName prefix for better identification in the pipeline.
    • Corrected a typo in a variable name from deleteObsWaitt to deleteObsWait.
  • pipeline/ingestion/src/test/java/org/datacommons/ingestion/pipeline/GraphIngestionPipelineIntegrationTest.java
    • Removed the java.util.UUID import.
    • Changed the importName initialization from a UUID-generated string to a static 'TestImport' string.
  • pipeline/util/src/main/java/org/datacommons/ingestion/util/GraphReader.java
    • Removed java.util.Arrays and org.apache.beam.sdk.Pipeline imports.
    • Added a check in graphToEdges to skip the 'dcid' property when iterating through node properties to prevent incorrect edge generation.
    • Removed the deleteExistingDataForImport helper method, as its functionality was moved to GraphIngestionPipeline.java.
  • pipeline/util/src/test/java/org/datacommons/ingestion/util/GraphReaderTest.java
    • Added a 'dcid' property to a test graph node in testGraphToEdges to validate the new dcid skipping logic.
Activity
  • No human activity has been recorded on this pull request yet.
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 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 counter productive. 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.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

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.

Copy link
Contributor

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

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 refactors the ingestion pipeline to process each import individually, which is a good architectural improvement for scalability. However, the current implementation introduces a few issues. I've identified a typo that will cause a compilation failure, a null pointer exception when deletes are skipped due to incorrect initialization of wait signals, and a potential data consistency issue where node writes no longer wait for deletions. My review includes specific code suggestions to address these critical and high-severity problems.


/**
* Helper method to flatten and write mutations to Spanner, optionally waiting on a signal.
* Helper method to flatten and write mutations to Spanner.
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: maybe update since it isn't flattening anymore?

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.

2 participants