Skip to content

refactor: Use BQ procedular query for EntityAggregationGenerator - #699

Open
SandeepTuniki wants to merge 4 commits into
masterfrom
refactor-entity-aggregation-generator
Open

refactor: Use BQ procedular query for EntityAggregationGenerator#699
SandeepTuniki wants to merge 4 commits into
masterfrom
refactor-entity-aggregation-generator

Conversation

@SandeepTuniki

@SandeepTuniki SandeepTuniki commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

This is a purely refactoring PR. No functionality changes, or bug fixes.

This PR refactors the entity 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.

@codacy-production

codacy-production Bot commented Jul 31, 2026

Copy link
Copy Markdown

Not up to standards ⛔

🔴 Issues 1 medium · 2 minor

Alerts:
⚠ 3 issues (≤ 0 issues of at least minor severity)

Results:
3 new issues

Category Results
Security 1 medium
CodeStyle 2 minor

View in Codacy

🟢 Metrics -54 complexity

Metric Results
Complexity -54

View in Codacy

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.

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

Copy link
Copy Markdown
Contributor

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 entity aggregation generation process by migrating dynamic SQL building logic from Python into a cohesive BigQuery procedural SQL script. It also introduces query parameterization via QueryJobConfig to securely inject variables and adds corresponding unit tests. The feedback highlights that the _parse_constraints method is no longer used and should be removed as dead code.

Comment thread pipeline/workflow/aggregation-helper/aggregation/entity_aggregation_generator.py Outdated
@SandeepTuniki
SandeepTuniki marked this pull request as ready for review July 31, 2026 07:24
@SandeepTuniki SandeepTuniki changed the title Refactor EntityAggregationGenerator SQL generation to a single BigQuery procedural script refactor: Use BQ procedular query for EntityAggregationGenerator Jul 31, 2026
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.

1 participant