Skip to main content

A data testing framework that executes queries on configurable data providers and validates the results with customizable YAML-defined assertions.

Project description

Aqueductus

A powerful Python framework for validating data quality across different data sources through SQL queries and customizable assertions. Perfect for data engineers and analysts who need to ensure data consistency and quality.

✨ Key Features

  • 🔌 Multiple Data Sources

    • Amazon Athena
    • MySQL
    • Extensible architecture for adding more providers
  • 🔍 Rich Test Types

    • Row presence validation
    • Negative testing (absence of rows)
    • Column completeness checks
    • Value distribution analysis
    • Row count validation
    • Column existence verification
    • Pattern matching with regex support
    • Comparative operators (>, <, =)
  • 🛠️ Advanced Configuration

    • Environment variable support
    • Date placeholders
    • Multiple data source configurations
    • CSV file integration
    • Cross-provider testing
  • 📊 Flexible Reporting

    • Console output
    • JSON export
    • JUnit XML (CI/CD friendly)
    • Markdown reports

🚀 Quick Start

Installation

# Clone the repository
git clone <repository-url>
cd aqueductus

# Install dependencies using Poetry
poetry install

# Activate virtual environment
poetry shell

Quick Start

  1. Create a configuration file (e.g., config.yaml):
providers:
  - name: my_athena
    type: athena
    config:
      region: ${AWS_REGION}
      work_group: ${AWS_WORKGROUP}
      aws_access_key_id: ${AWS_ACCESS_KEY_ID}
      aws_secret_access_key: ${AWS_SECRET_ACCESS_KEY}

tests:
  - name: user_data_validation
    provider: my_athena
    query: >
      SELECT user_id, status
      FROM users
      WHERE created_date = CURRENT_DATE
    
    # Verify specific rows exist
    contains_rows:
      source: inline
      rows:
        - column1: "value1"
          column2: "value2"
      ignore_columns:
        - timestamp
    
    # Verify column completeness
    column_ratio:
      - column: status
        value: "active"
        min_ratio: 0.95
  1. Run the tests:
aqueductus config.yaml

📚 Test Types

1. Contains Rows

Verifies that specific rows exist in the query results:

contains_rows:
  source: inline
  rows:
    - column1: "value1"
      column2: "value2"
  ignore_columns:
    - timestamp

2. Not Contains Rows

Ensures specific rows do not exist:

not_contains_rows:
  rows:
    - column1: "invalid"
      column2: "invalid"

3. Column Ratio

Validates the ratio of values in a column:

column_ratio:
  - column: status
    value: "active"
    min_ratio: 0.95
    max_ratio: 1.0

4. Row Count

Verifies the exact number of rows:

row_count: 100

5. Columns Exist

Ensures required columns are present:

columns_exists:
  - column1
  - column2

🔄 Data Sources

CSV Integration

Load test data from CSV files:

contains_rows:
  source: csv
  path: tests/expected_data.csv

Cross-Provider Testing

Compare data across different providers:

contains_rows:
  source: provider
  provider: other_athena
  query: SELECT * FROM reference_table
  map:  # Optional column mapping
    source_col: target_col

📝 Output Formats

The framework supports multiple output formats:

# Single format
aqueductus config.yaml --format json

# Multiple formats
aqueductus config.yaml --format console,json,junit

Available formats:

  • console: Human-readable console output
  • json: JSON file output
  • junit: JUnit XML for CI/CD integration
  • markdown: Markdown report

🛠️ Development

Adding a New Provider

Reference to provider implementation:

class DataProvider(ABC):
    @abstractmethod
    def __init__(self, config: dict[str, Any]) -> None:
        pass

    @abstractmethod
    def execute_query(self, query: str) -> list[dict[str, Any]]:
        pass

Adding a New Test Type

Reference to test type implementation:

class DataTest(ABC):
    def __init__(
        self,
        query_results: list[dict[str, Any]],
        config: Any,
        providers: dict[str, DataProvider],
    ):
        self.query_results = query_results
        self.config = config
        self.providers = providers

    @abstractmethod
    def run(self) -> dict[str, Any]:
        pass

Adding a New Reporter

Reference to reporter implementation:

class Reporter(ABC):

    @abstractmethod
    def generate_report(self, test_results: list[dict[str, Any]]) -> None:
        pass

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aqueductus-1.0.0.tar.gz (12.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aqueductus-1.0.0-py3-none-any.whl (13.8 kB view details)

Uploaded Python 3

File details

Details for the file aqueductus-1.0.0.tar.gz.

File metadata

  • Download URL: aqueductus-1.0.0.tar.gz
  • Upload date:
  • Size: 12.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for aqueductus-1.0.0.tar.gz
Algorithm Hash digest
SHA256 ce5562469c593b22cc2490e9e4fdffb1e28091aea0abd1feb7683def2bbc5f8a
MD5 2fc5246066c7e1c4a2c21551c4f22fa3
BLAKE2b-256 94c61640a7011372cce44e00ae44103836f0b09433ac47dcd444afdf260cf46d

See more details on using hashes here.

Provenance

The following attestation bundles were made for aqueductus-1.0.0.tar.gz:

Publisher: python-publish.yml on RemoYukoff/aqueductus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file aqueductus-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: aqueductus-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for aqueductus-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f52f217b10fd2235f0f41c57a905514cac1cb31e926b80f5ac73cf0911ae6156
MD5 c8d899b9c7001218fd74ec458d40c988
BLAKE2b-256 2834f872f83ba6acad0f5fd6f0d36bb3ccd3e036339b0ba43c89a1b62e2f065c

See more details on using hashes here.

Provenance

The following attestation bundles were made for aqueductus-1.0.0-py3-none-any.whl:

Publisher: python-publish.yml on RemoYukoff/aqueductus

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page