Skip to content

feat: add demo.sql golden test file with 5 impactful SQLFluff issues - #3

Open
sauravsrijan wants to merge 1 commit into
masterfrom
feat/demo-golden-test-file
Open

feat: add demo.sql golden test file with 5 impactful SQLFluff issues#3
sauravsrijan wants to merge 1 commit into
masterfrom
feat/demo-golden-test-file

Conversation

@sauravsrijan

Copy link
Copy Markdown
Owner

Summary

This PR adds a new golden test file (demo.sql) that demonstrates 5 of the most impactful SQLFluff issues for SQL code quality analysis. The file is designed as a production-realistic example showing common SQL anti-patterns.

Key Issues Demonstrated

  1. AL03 (aliasing.expression) - Column expressions without explicit aliases
  2. AM06 (ambiguous.column_references) - Inconsistent column references in GROUP BY
  3. AM09 (ambiguous.order_by_limit) - LIMIT without ORDER BY (non-deterministic results)
  4. CV05 (convention.is_null) - NULL comparisons without IS NULL
  5. AL01 (aliasing.table) - Implicit table aliasing in FROM clause

Implementation Details

  • demo.sql: 48-line SQL file demonstrating all 5 issues in realistic e-commerce analytics queries
  • test_demo.py: Comprehensive test suite with 9 tests validating:
    • File existence and size (<100 lines)
    • Detection of each specific issue type
    • Meaningful violation descriptions
    • Multiple issue categories present

Test Results

✅ All 9 tests passing:

  • test_demo_file_exists
  • test_demo_file_size
  • test_al03_aliasing_expression_detected
  • test_am06_ambiguous_column_references_detected
  • test_am09_limit_without_orderby_detected
  • test_cv05_is_null_comparison_detected
  • test_al01_implicit_aliasing_detected
  • test_at_least_five_issue_types
  • test_violations_have_descriptions

Test Plan

  • All new tests pass (9/9)
  • SQLFluff successfully detects all 5 impactful issues
  • File respects 100-line constraint (48 lines)
  • Code follows SQL best practices (except for intentional anti-patterns)

🤖 Generated with Claude Code

This commit adds a new golden test file (demo.sql) that demonstrates 5 of the most impactful SQLFluff issues for SQL code quality analysis:

1. AL03 (aliasing.expression) - Column expression without explicit alias
2. AM06 (ambiguous.column_references) - Inconsistent column references in GROUP BY
3. AM09 (ambiguous.order_by_limit) - Use of LIMIT without ORDER BY
4. CV05 (convention.is_null) - NULL comparison without IS NULL
5. AL01 (aliasing.table) - Implicit table aliasing

Also includes comprehensive test suite (test_demo.py) with 9 tests that validate:
- File structure and size constraints (<100 lines)
- Presence of each impactful issue
- Meaningful violation descriptions
- At least 5 different issue types detected

All tests pass successfully.

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
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