Skip to content

feat: Add python client api for JobStatistics.referenced_property_graphs.#16137

Open
ericfe-google wants to merge 3 commits intomainfrom
referenced_property_graphs
Open

feat: Add python client api for JobStatistics.referenced_property_graphs.#16137
ericfe-google wants to merge 3 commits intomainfrom
referenced_property_graphs

Conversation

@ericfe-google
Copy link
Contributor

Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly:

  • Make sure to open an issue as a bug/issue before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea
  • Ensure the tests and linter pass
  • Code coverage does not decrease (if any source code was changed)
  • Appropriate docs were updated (if necessary)

Fixes #<issue_number_goes_here> 🦕

@gemini-code-assist
Copy link
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 BigQuery Python client by adding support for retrieving referenced property graphs from job statistics. It introduces a new PropertyGraphReference class to model these graph references and integrates this functionality into the QueryJob object, providing a programmatic way to access this information.

Highlights

  • New Feature: Property Graph References: Introduced the PropertyGraphReference class to represent BigQuery property graph identifiers, enabling structured access to these references.
  • BigQuery Job Statistics Integration: Added a referenced_property_graphs property to the QueryJob class, allowing users to retrieve a list of PropertyGraphReference objects from job statistics.
  • Unit Tests: Included comprehensive unit tests to ensure the correct functionality and parsing of referenced property graphs within job statistics.
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.

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 adds a new property referenced_property_graphs to QueryJob to expose referenced property graphs from job statistics. A corresponding PropertyGraphReference class is introduced, along with unit tests. The implementation is solid, but I have one suggestion to improve the new PropertyGraphReference class for better consistency and readability within the existing codebase.

Comment on lines +369 to +413
_PROPERTY_TO_API_FIELD = {
"dataset_id": "datasetId",
"project": "projectId",
"property_graph_id": "propertyGraphId",
}

def __init__(self, dataset_ref: "DatasetReference", property_graph_id: str):
self._properties = {}

_helpers._set_sub_prop(
self._properties,
self._PROPERTY_TO_API_FIELD["project"],
dataset_ref.project,
)
_helpers._set_sub_prop(
self._properties,
self._PROPERTY_TO_API_FIELD["dataset_id"],
dataset_ref.dataset_id,
)
_helpers._set_sub_prop(
self._properties,
self._PROPERTY_TO_API_FIELD["property_graph_id"],
property_graph_id,
)

@property
def project(self) -> str:
"""str: Project bound to the property graph."""
return _helpers._get_sub_prop(
self._properties, self._PROPERTY_TO_API_FIELD["project"]
)

@property
def dataset_id(self) -> str:
"""str: ID of dataset containing the property graph."""
return _helpers._get_sub_prop(
self._properties, self._PROPERTY_TO_API_FIELD["dataset_id"]
)

@property
def property_graph_id(self) -> str:
"""str: The property graph ID."""
return _helpers._get_sub_prop(
self._properties, self._PROPERTY_TO_API_FIELD["property_graph_id"]
)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The implementation of __init__ and the property getters can be simplified to improve readability and align with the implementation of the existing TableReference class.

You can directly initialize the _properties dictionary and access its items in the properties. This also makes the _PROPERTY_TO_API_FIELD dictionary redundant.

    def __init__(self, dataset_ref: "DatasetReference", property_graph_id: str):
        self._properties = {
            "projectId": dataset_ref.project,
            "datasetId": dataset_ref.dataset_id,
            "propertyGraphId": property_graph_id,
        }

    @property
    def project(self) -> str:
        """str: Project bound to the property graph."""
        return self._properties["projectId"]

    @property
    def dataset_id(self) -> str:
        """str: ID of dataset containing the property graph."""
        return self._properties["datasetId"]

    @property
    def property_graph_id(self) -> str:
        """str: The property graph ID."""
        return self._properties["propertyGraphId"]

@ericfe-google ericfe-google force-pushed the referenced_property_graphs branch from 1a06742 to f4aecbc Compare March 20, 2026 23:38
@ericfe-google ericfe-google force-pushed the referenced_property_graphs branch from f4aecbc to bd46c45 Compare March 20, 2026 23:44
@ericfe-google ericfe-google marked this pull request as ready for review March 23, 2026 19:37
@ericfe-google ericfe-google requested review from a team as code owners March 23, 2026 19:37
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