Refactor int_topline__student_metrics to use CTEs#3328
Open
anthonygwalters wants to merge 4 commits intomainfrom
Open
Refactor int_topline__student_metrics to use CTEs#3328anthonygwalters wants to merge 4 commits intomainfrom
anthonygwalters wants to merge 4 commits intomainfrom
Conversation
… avoid repeated scans Five upstream tables were referenced multiple times across separate UNION ALL branches, causing BigQuery to scan each table more than once per model run: - int_topline__iready_diagnostic_weekly (2x) - int_topline__dibels_pm_weekly (2x) - int_topline__college_matriculation_weekly (4x) - int_topline__state_assessments_weekly (3x) - int_extracts__student_enrollments_weeks (3x) Adding named CTEs at the top of the with block for each of these and referencing the CTE alias in the body allows BigQuery to treat each as a single scan. https://claude.ai/code/session_01VwB9BpfUrxTnCVYPa16md9
added 2 commits
February 26, 2026 22:19
…laude/optimize-topline-cascade-m5ra7
c0802a6 to
2209a4d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request
Summary & Motivation
When merged, this pull request will refactor
int_topline__student_metrics.sqlto use Common Table Expressions (CTEs) for all referenced source models. This improves code readability and maintainability by centralizing all source model references at the top of the query, making dependencies explicit and reducing repetition throughout the file.The following models are now referenced via CTEs:
int_topline__iready_diagnostic_weeklyint_topline__dibels_pm_weeklyint_topline__college_matriculation_weeklyint_topline__state_assessments_weeklyint_extracts__student_enrollments_weeksSelf-review
General
dbt
[model name].ymlproperties file for all models.SQL
union_dataset_join_clause()macro for queries that employ models that use regional datasetsgroup bywithout any aggregations when you mean to usedistinctdistinctusage must be accompanied by a comment explaining its necessityorder byforselectstatements. That should be done in the reporting layer.Troubleshooting
https://claude.ai/code/session_01VwB9BpfUrxTnCVYPa16md9