refactor: Update StatVarAggregator to use procedural BigQuery SQL features - #702
refactor: Update StatVarAggregator to use procedural BigQuery SQL features#702SandeepTuniki wants to merge 2 commits into
Conversation
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Security | 1 medium |
🟢 Metrics -8 complexity
Metric Results Complexity -8
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Code Review
This pull request refactors the StatVarAggregator to consolidate the TimeSeries and Observation queries into a single multi-statement SQL script using temporary tables and BigQuery query parameters, alongside adding corresponding unit tests. The feedback suggests keeping the entities and facet columns as JSON type throughout the temporary tables to avoid expensive serialization/deserialization overhead, and simplifying the UpdateFacet temporary function by using a single JSON_SET call with multiple path-value pairs.
…ative via GROUP BY
This is a purely refactoring PR. No functionality changes, or bug fixes.
This PR refactors the statvar aggregation SQL query. Presently the query is constructed through several python helpers as small snippets, and then combined together. But it's hard to logically follow the query's order and flow due to python's loops and conditions. So I refactored it to take advantage of BQ's native procedural features (i.e; variables, conditions, loops, and temp functions). Now the query is linear and easy to follow.