feat: Add python client api for JobStatistics.referenced_property_graphs.#16137
feat: Add python client api for JobStatistics.referenced_property_graphs.#16137ericfe-google wants to merge 3 commits intomainfrom
Conversation
Summary of ChangesHello, 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 Highlights
Using Gemini Code AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| _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"] | ||
| ) |
There was a problem hiding this comment.
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"]1a06742 to
f4aecbc
Compare
f4aecbc to
bd46c45
Compare
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:
Fixes #<issue_number_goes_here> 🦕