feat: Bring API parity to v3/observation for existence checks in Spanner#1823
feat: Bring API parity to v3/observation for existence checks in Spanner#1823SandeepTuniki merged 6 commits intomasterfrom
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 Spanner backend's observation API by introducing an optimized mechanism for checking the existence of observations for given variables and entities. Instead of creating a new endpoint, this change integrates the existence check functionality directly into the existing /v3/observation and /v2/observation APIs, improving efficiency and maintaining API consistency. This allows clients to quickly determine if specific data points exist without retrieving full observation details, addressing a previous feedback item. 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 introduces an optimization for observation existence checks in the Spanner backend by enhancing the existing /v3/observation API instead of adding a new endpoint. The changes are well-structured and include new queries, interface methods, and tests. My review includes a couple of suggestions: one to improve the robustness and performance of observation processing in datasource.go, and another to enhance the accuracy of the mock client in datasource_test.go to better reflect real-world filtering behavior, which will improve test quality.
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces a new feature to efficiently check for the existence of observations for specified statistical variables and entities within the Spanner data source. This includes adding a CheckVariableExistence method to the SpannerClient interface and its implementation, integrating this check into the Observation function under specific conditions (when only variable and entity existence is requested), and adding new validation to ensure entities are specified. Corresponding SQL query builders, Spanner statements, and comprehensive golden tests have been added to support this functionality. A review comment suggests improving error handling in internal/server/spanner/datasource.go by using %w for error wrapping to allow for better error inspection up the call stack.
n-h-diaz
left a comment
There was a problem hiding this comment.
Thanks for the quick update!
Generally looks good, just had a small comment on supporting stat vars per place
…servation # Conflicts: # internal/server/spanner/query.go
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces an optimized mechanism to check for the existence of observations based on variables and entities. It adds a new CheckVariableExistence method to the Spanner client interface and its implementation, which is utilized in the Observation handler for specific existence-only requests. A new FilterStatVarsByEntityQuery function was added to construct the necessary SQL queries, accompanied by new golden files and comprehensive tests. The review suggests adding a defensive error check to FilterStatVarsByEntityQuery to prevent potential full table scans if called with empty variable and entity lists.
|
Hi @n-h-diaz, I addressed your feedback. Could you take a look at this PR again? Also, the CI is failing on Codacy checks, related to SQL queries. I wasn't sure if I should apply the suggested changes. We're not really following the suggested patterns in the rest of the codebase. What do you suggest regarding this? |
n-h-diaz
left a comment
There was a problem hiding this comment.
Thank you!
(Codacy often complains about sql/gql - I think safe to ignore)
Let's see if this is efficient enough for existence requests (both v3 observation and variable filter) and can discuss alternatives if latency is too high
This PR implements API parity for existence checks within the Spanner backend (b/49252083). This effectively helps us to remove the
/v2/variable/filter, used to filter down the variables that are associated with specific entities.Following feedback on the initial approach in #1819, this implementation optimizes the existing
/v3/observation(and/v2/observation) api rather than introducing a newv3/variable/filterendpoint.