Metadata-Version: 2.4
Name: dbt-tester
Version: 0.2.0
Summary: Static analysis and health report generator for dbt projects
Author-email: Vinoth J <career.vinothj@gmail.com>
License: MIT
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: click>=8.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: rich>=13.0
Requires-Dist: jinja2>=3.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0; extra == "dev"
Dynamic: license-file

# dbt-tester

A powerful static analysis tool for dbt projects that scans models, schemas, and sources to find issues like missing tests, undocumented columns, hardcoded references, and more.

## What is dbt-tester?

DBT TESTER helps you:
- Find models without tests
- Identify undocumented columns
- Catch hardcoded table references
- Verify data quality rules
- Generate reports for team review

## Quick Start (5 minutes)

### Step 1: Install

```bash
# Create virtual environment (recommended)
python -m venv .venv

# Activate (Linux/Mac)
source .venv/bin/activate

# Activate (Windows)
.venv\Scripts\activate

# Install
pip install -e .
```

### Step 2: Run Your First Scan

```bash
# Scan a dbt project
dbt-tester run /path/to/your/dbt/project

# Or scan current folder
dbt-tester run .
```

### Step 3: Understand Results

```
DBT TESTER v0.1.0
Version: 0.1.0 | Created by: VINOTH J

SYSTEM STATUS: X CRITICAL
Models: 354 | Sources: 0

ISSUE MATRIX:
  ERROR: 100
  WARN:  50

DASHBOARD:
  Models Scanned: 354
  Total Issues: 150
  Status: CRIT
```

## Command Options

### Basic Options

| Command | What it does |
|---------|--------------|
| `dbt-tester run .` | Scan current directory |
| `dbt-tester run /path/to/project` | Scan specific folder |
| `dbt-tester run . -v` | Show fix instructions |

### Output Formats

| Format | Command | Best for |
|--------|---------|----------|
| Terminal | `--format console` | Quick review |
| HTML | `--format html --output report.html` | Share with team |
| JSON | `--format json --output report.json` | CI/CD automation |

### Exit Control

| Option | When it exits with code 1 |
|--------|---------------------------|
| `--fail-on error` | If any ERROR found |
| `--fail-on warning` | If any WARNING or ERROR found |

Example for CI:
```bash
dbt-tester run . --format html --output report.html --fail-on warning
```

## Understanding Output

### Status Types

- **X CRITICAL** = Must fix (will break builds)
- **! WARNING** = Should fix (data quality risk)
- **OK HEALTHY** = No issues found

### Common Issues

| Issue | Meaning | How to Fix |
|-------|---------|------------|
| ERROR: Model has no tests | Add tests in schema.yml | Add `tests: - not_null` |
| ERROR: Missing description | Add doc in schema.yml | Add `description: "..."` |
| ERROR: Hardcoded table ref | Use ref() instead | Replace `db.table` with `{{ ref('model') }}` |
| WARN: Column missing not_null | Add not_null test | Add test for *_id columns |

## Installation for Distribution

If you want to share the package:

```bash
# Build
python -m build

# Upload to PyPI (need account)
twine upload dist/*
```

Then anyone can install:
```bash
pip install dbt-tester
dbt-tester run .
```

## For Developers

```bash
# Run tests
pytest

# Test with sample project
dbt-tester run tests/fixtures/basic_project --format console
```

## Troubleshooting

### "No matching distribution found"

Your Python is too old. Use Python 3.9+:
```bash
python3 -m venv .venv
source .venv/bin/activate
pip install dbt-tester
```

### "externally-managed-environment"

Use virtual environment:
```bash
python -m venv .venv
source .venv/bin/activate
pip install -e .
```

## Examples

### Basic Scan
```bash
dbt-tester run ./my_dbt_project
```

### With HTML Report
```bash
dbt-tester run ./my_dbt_project --format html --output report.html
```

### CI/CD Integration
```bash
# Exit 1 if any error
dbt-tester run . --fail-on error

# Create report for artifacts
dbt-tester run . --format html --output dbt-report.html --fail-on warning
```

## License

MIT License
