Skip to content

feat: add demo.sql with 5 impactful SQL checker issues - #2

Open
sauravsrijan wants to merge 2 commits into
masterfrom
feat/sql-demo-test-file
Open

feat: add demo.sql with 5 impactful SQL checker issues#2
sauravsrijan wants to merge 2 commits into
masterfrom
feat/sql-demo-test-file

Conversation

@sauravsrijan

Copy link
Copy Markdown
Owner

Summary

Added a new demonstration file (demo.sql) showcasing 5 of the most impactful SQLFluff violations that are critical in production SQL. This golden test file helps demonstrate the importance of proper SQL linting practices.

Changes

  • demo.sql (37 lines): Production-grade SQL examples featuring:

    • AM09: LIMIT without ORDER BY (non-deterministic results)
    • AM05: Unqualified JOINs (ambiguity in multi-table queries)
    • AM08: Implicit cross JOINs (unintended Cartesian products)
    • CP01: Inconsistent keyword capitalization (standards)
    • AL01: Implicit table aliasing (clarity and maintainability)
  • test_demo_sql.py (100+ lines): Comprehensive pytest test suite with 9 tests:

    • Individual tests for each of the 5 violations
    • Integration test verifying all 5 issues are present
    • File validation tests (existence, line count, production context)

Test Results

All 9 tests pass:

  • ✓ test_am09_limit_without_order_by
  • ✓ test_am05_unqualified_join
  • ✓ test_am08_implicit_cross_join
  • ✓ test_cp01_keyword_capitalization
  • ✓ test_al01_implicit_aliasing
  • ✓ test_all_five_violations_present
  • ✓ test_demo_sql_file_exists
  • ✓ test_demo_sql_under_100_lines
  • ✓ test_demo_sql_has_production_context

Running `sqlfluff lint demo.sql --dialect postgres` detects all 5 critical violations.

Context

This repository contains golden test files with intentional SQL violations to demonstrate SQLFluff's linting capabilities. The demo.sql file provides realistic, production-level examples that are useful for:

  • Demonstrating SQLFluff's core violation detection
  • Training developers on common SQL pitfalls
  • Validating linter configuration
  • Creating comprehensive test coverage for SQL quality assurance

🤖 Generated with Claude Code

Srijan and others added 2 commits May 12, 2026 00:56
- demo.sql showcases 5 production-level SQL issues:
  - AM09: LIMIT without ORDER BY (non-deterministic results)
  - AM05: Unqualified JOINs (ambiguity)
  - AM08: Implicit cross JOINs (logic bugs)
  - CP01: Inconsistent keyword capitalization (standards)
  - AL01: Implicit table aliasing (clarity)
- 37 lines of realistic e-commerce SQL patterns
- 9 comprehensive pytest tests verify all violations detected

Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
- Refactored test_demo_sql.py with full type hints, Google-style docstrings, and structured error handling following company baseline standards
- Standardized SQL formatting across all files (sql1-4.sql, demo.sql) with consistent indentation and spacing
- Removed unnecessary comments and documentation blocks per production requirements
- All 9 tests verified passing with pytest

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