Skip to main content

Tooling for SQL feature lineage extraction and unified vector SQL generation

Project description

feature-sql-tool

feature-sql-tool is a draft Python package for two related tasks:

  1. analyzing SQL scripts for model features and extracting dependency lineage;
  2. building a unified SQL query for a model input vector from multiple feature SQL files.

The package is designed around sqlglot and uses a src layout with modern pyproject.toml packaging, which is the recommended approach in the Python Packaging User Guide. The packaging guide recommends defining build metadata in pyproject.toml, and the tool recommendations guide recommends building distributions with python -m build rather than calling setup.py directly. citeturn721430search0turn721430search2turn721430search6turn721430search7turn721430search9

Features in this first version

  • FeatureSpec points to a .sql file instead of storing long SQL inline.
  • SQL loading, parsing, scope registration, lineage extraction, graph classification, and unified SQL generation are split into separate modules.
  • A first MVP service API is included.

Install locally

python -m pip install -U pip
pip install -e .

For development extras:

pip install -e .[dev]

Build distributions

python -m pip install -U build
python -m build

This creates:

  • dist/*.tar.gz — source distribution
  • dist/*.whl — wheel

Check distributions

python -m pip install -U twine
twine check dist/*

Upload to PyPI

python -m pip install -U twine
twine upload dist/*

Install from a downloaded archive

After publishing to PyPI:

pip download feature-sql-tool
pip install feature_sql_tool-0.1.0-py3-none-any.whl

Minimal usage example

from pathlib import Path

from feature_sql_tool import FeatureSqlTool, FeatureSpec

features = [
    FeatureSpec(
        feature_name="avg_payment_30d",
        sql_file_path=Path("sql/avg_payment_30d.sql"),
        final_alias="avg_payment_30d",
        entity_key="client_id",
        dialect="spark",
    ),
]

tool = FeatureSqlTool()
results = tool.analyze_features(features)
print(results[0].source_columns)

Notes

This package is still an MVP scaffold. Deep recursive CTE resolution, UNION-aware lineage, and real common-subgraph optimization are not fully implemented yet.

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

feature_sql_tool-0.1.0.tar.gz (13.0 kB view details)

Uploaded Source

Built Distribution

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

feature_sql_tool-0.1.0-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

Details for the file feature_sql_tool-0.1.0.tar.gz.

File metadata

  • Download URL: feature_sql_tool-0.1.0.tar.gz
  • Upload date:
  • Size: 13.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for feature_sql_tool-0.1.0.tar.gz
Algorithm Hash digest
SHA256 75d6300909a720567742adcd586a168d5d6c366c3bc14377ef4625a1fc47f8b0
MD5 288e399640fb7c8c6ef954c7bc83ea47
BLAKE2b-256 88ce7d032bca73180b2e8e80c8c9e72c5020d128f4ac7e7218d0ca38a70890f3

See more details on using hashes here.

File details

Details for the file feature_sql_tool-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for feature_sql_tool-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4b50dcb6f3d779408f35aab590f0665188b0e7cacbb7b8a13685e3666d14abdd
MD5 50ace2217ba2e3cad1dc06f168b8942b
BLAKE2b-256 a4962438915408f24993a49932ed30b7e1bed18d9dfd9ff555b2985db2646355

See more details on using hashes here.

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