Skip to main content

helix-ir

PyPI version License Python versions Tests

helix-ir is a comprehensive open-source Python library for schema inference, normalization, transformation, and DDL generation. It takes raw, messy document streams (JSON, Parquet, MongoDB, REST APIs, Kafka) and produces clean, typed, normalized schemas ready for any data warehouse — Postgres, Redshift, BigQuery, Snowflake, Databricks, or DuckDB.

Installation

pip install helix-ir
# With optional extras:
pip install 'helix-ir[mongo]'       # MongoDB source
pip install 'helix-ir[postgres]'    # PostgreSQL source
pip install 'helix-ir[kafka]'       # Kafka source
pip install 'helix-ir[dev]'         # Development tools

Hello World

from helix_ir import infer, normalize, compile_ddl

# 1. Infer schema from documents
documents = [
    {"order_id": "ORD-001", "customer_email": "alice@example.com",
     "amount": 99.99, "items": [{"sku": "A1", "qty": 2}]},
    {"order_id": "ORD-002", "customer_email": "bob@example.com",
     "amount": 149.50, "items": [{"sku": "B3", "qty": 1}]},
]

schema = infer(documents, name="orders")
print(schema)
# Schema('orders', [order_id: string, customer_email: string, amount: double, items: list<...>])

# 2. Normalize to 1NF (flatten nested arrays)
plan = normalize(schema)
print(plan.table_names())
# ['orders', 'orders__items']

# 3. Compile DDL for your target warehouse
ddl = compile_ddl(plan, dialect="duckdb")
print(ddl)
# CREATE TABLE IF NOT EXISTS "orders" (
#   "__id" VARCHAR NOT NULL,
#   "order_id" VARCHAR NOT NULL,
#   ...
# );
# CREATE TABLE IF NOT EXISTS "orders__items" (
#   "__id" VARCHAR NOT NULL,
#   "__parent_id" VARCHAR NOT NULL,
#   ...
# );

Quick Start: Infer + Normalize + DDL

from helix_ir import infer, normalize, compile_ddl
from helix_ir.ddl import DDLOptions

# Infer with PII detection
schema = infer(
    documents,
    name="customers",
    sample_size=5000,
    seed=42,
    detect_pii=True,
    pii_locale="in",   # India locale: detects PAN, Aadhaar, GSTIN
)

# Check PII annotations
for name, ht in schema.fields:
    if ht.pii_class:
        print(f"  {name}: {ht.pii_class}")

# Normalize
plan = normalize(schema, strategy="1nf")

# Generate DDL with options
opts = DDLOptions(if_not_exists=True, schema_prefix="raw")
ddl_pg = compile_ddl(plan, dialect="postgres", options=opts)
ddl_bq = compile_ddl(plan, dialect="bigquery", options=opts)

print(ddl_pg.to_sql())
print(ddl_bq.to_sql())

Quick Start: Transformation Pipeline

from helix_ir.transform import Table
from helix_ir.transform.expression import col, lit

# Build a lazy query plan
table = Table("orders")
result = (
    table
    .filter(col("status") == lit("shipped"))
    .select(col("order_id"), col("amount"), col("customer_email"))
    .sort(col("amount").desc())
    .limit(100)
)

# Compile to SQL for any dialect
print(result.to_sql("duckdb"))
print(result.to_sql("bigquery"))
print(result.to_sql("snowflake"))

Quick Start: Schema Diff

from helix_ir.diff import diff

# Compare two schema versions
schema_v1 = infer(old_documents, name="orders")
schema_v2 = infer(new_documents, name="orders")

schema_diff = diff(schema_v1, schema_v2)

print(f"Breaking changes: {schema_diff.has_breaking_changes}")
for change in schema_diff.changes:
    print(f"  [{change.severity.upper()}] {change.description}")

# Filter by severity
breaking = schema_diff.filter("breaking")

CLI

# Infer schema from a file
helix-ir infer data.ndjson --name orders --locale in

# Generate DDL
helix-ir ddl schema.json --dialect snowflake

# Normalize + DDL
helix-ir normalize schema.json --strategy 1nf --dialect bigquery

# Diff two schemas
helix-ir diff schema_v1.json schema_v2.json

# Generate data quality tests
helix-ir test schema.json --sensitivity 1.5

# Generate lineage graph
helix-ir lineage schema.json --format dot

Module Overview

Module Description
helix_ir.infer Schema inference from document streams using Algorithm R reservoir sampling
helix_ir.types HelixType dataclass + type lattice (join, meet, subsumes)
helix_ir.schema Schema class + Path addressing
helix_ir.normalize 1NF / MongoDB / inline_small normalization strategies
helix_ir.transform Lazy SQL transformation DSL with multi-dialect compilation
helix_ir.ddl DDL generation for DuckDB, Postgres, Redshift, BigQuery, Snowflake, Databricks
helix_ir.diff Schema diff with safe/risky/breaking change classification
helix_ir.pii PII detection via field name heuristics + regex patterns (IN/US/EU)
helix_ir.lineage Field-level lineage tracking with OpenLineage export
helix_ir.sources Connectors: JSON, Parquet, MongoDB, PostgreSQL, REST, Kafka
helix_ir.test Automatic data quality test generation from schema metadata
helix_ir.cli Typer-based CLI with rich output

Documentation

Full documentation: https://helix-ir.readthedocs.io/

License

Apache 2.0 — Copyright 2024 Sparsh Prakash

Metadata

Release files for helix-ir 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for helix-ir 0.1.0
File Size Uploaded Provenance
helix_ir-0.1.0.tar.gz 60.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for helix-ir 0.1.0
File Interpreter ABI Platform
helix_ir-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 138.8 kB

Release files / helix_ir-0.1.0.tar.gz

Download URL helix_ir-0.1.0.tar.gz
Size 60.8 kB
Tags Source
SHA-256 checksum
How to use checksums
2afa6ca9801a7f3a68cfa54b5f0a8d50c943951a5ba65c7dbc4616f58e4c2648
BLAKE2b-256 checksum
How to use checksums
c173f46c892b4b48224ecab13f14bf7993963a862d4164b539098fc814a473ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Release files / helix_ir-0.1.0-py3-none-any.whl

Download URL helix_ir-0.1.0-py3-none-any.whl
Size 78.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
dc6fe4d2312991e14744407cda3da4a329dea9c428f7cfbc6b72ede305cbf70e
BLAKE2b-256 checksum
How to use checksums
243db29fcd48f79eff31bff9af14e55d2d9342b93587efada7705a7630b2adb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.9.13

Security for helix-ir 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page