Mastering Code Reviews: A Guide to Better PRs and Clean SQL
Learn best practices for data engineering PRs, including naming conventions, dbt documentation, local testing, and etiquette for faster code approvals.
How to Make Reviewers Approve Your PR
A Guide to Clean SQL, Happy AEs, and Fewer Headaches By Miriam Revilla Alvarez
The Game Plan
1. The Reviewer's Perspective (Why we are like this) <br> 2. Follow Best Practices (Naming & Folders) <br> 3. Documentation (No creative writing) <br> 4. Testing & The 'To Test' Section <br> 5. Etiquette 101 <br> 6. Kahoot! Deathmatch
The Reviewer's Perspective 🧐
Why are we strict?
We feel responsible for Production. Broken logic = 3AM wake-up calls. <br><br> Ambiguous names (e.g., 'id') cause cognitive load and bugs 6 months later. <br><br> We want you to succeed, but we need to protect the data reliability.
Naming Conventions & Folders
<strong>Model Prefixes (Non-negotiable):</strong><br>• <code>stg_</code> : Staging models<br>• <code>prep_</code> : Prep models<br>• <code>event_</code> : Curated event data<br><br><strong>Why?</strong><br>Instantly tells the user the granularity and type of data.
Example: hub_shifts.sql lives under central_ops_team / staffing / shifts / curated. <br>Start clean, stay clean.
Documentation: Not a Creative Writing Class
❌ <strong>Bad:</strong><br>{% docs is_active %}<br>It is active.<br>{% enddocs %}<br><br><em>Reviewer Reaction: Thanks, I can read.</em>
✅ <strong>Good:</strong><br>{% docs is_external_last_mile_rider_profile %}<br>TRUE if external_agency_name is not empty. Used to identify contracted riders.<br>{% enddocs %}<br><br><em>Reviewer Reaction: 🤩 Clarity!</em>
🧪 Testing: The Bare Minimum
<strong>1. Run Tests Locally (Always)</strong><br>.yml tests are your first defense. <br>unique, not_null, relationships.<br><br><strong>2. Why?</strong><br>If these fail, we waste time iterating on typos. Don't be that person.
The 'To Test' Section is Mandatory
Passing .yml tests matches syntax. <br><strong>'To Test' matches REALITY.</strong><br><br>Include:<br>✅ Confirmation .yml tests passed<br>🧠 Validation queries (Show intent!)<br>📊 Row count comparisons<br>⚠️ Explicit callouts for weird data
Validate Business Logic (Show us the Data!)
Don't just run the code. Prove the result makes sense. <br>Ex: A process change should reduce tickets. Show the drop!
🤩 How to Keep Your Reviewer Happy
bullet_1: <strong>Reply to comments</strong><br>Don't ghost us. Explain your fix or argue your case (politely).<br><br>bullet_2: <strong>Don't resolve your own threads</strong><br>That's the reviewer's job. It helps us track what is still pending.<br><br>bullet_3: <strong>Fix it everywhere</strong><br>If we comment on line 10, check if line 50 has the same issue.
🎓 Be a Great PR Citizen
1. Post in <strong>#data-analytics-community</strong> when ready.<br>2. Fill in <em>'What's the problem'</em> and <em>'dbt statements'</em>.<br>3. No 'Draft' PRs for review (Wait until you are done!).<br>4. Re-request review ONLY when you are actually done fixing things.
IT'S KAHOOT TIME! 📱
<strong>Q1:</strong> Which folder implies ownership? <br><em>(A: The closest one to dependencies)</em><br><br><strong>Q2:</strong> Who resolves PR comments? <br><em>(A: The Reviewer only)</em><br><br><strong>Q3:</strong> What prefix is used for curated Event data? <br><em>(A: event_)</em><br><br><strong>Q4:</strong> Is the 'To Test' section optional? <br><em>(A: No, never.)</em><br><br><strong>Q5:</strong> Where do you post your PR link? <br><em>(A: #data-analytics-community)</em>
- pull-request
- data-engineering
- sql-best-practices
- dbt
- code-review
- data-analytics
- git-etiquette









