SQL Metadata Lineage
This package helps you to find first level lineage / column level dependency in a given query
Get SQL metadata (first level lineage) for most type of sql queries with inner sub-queries and other complex joins
Get column level base logic after analyzing query
Sample input.sql
SELECT investments.month_nm AS month_nm,
acquisitions.companies_acquired,
investments.companies_rec_investment
FROM (
SELECT acq.acquired_month_nm AS month_nm,
COUNT(DISTINCT acq.company_permalink) AS companies_acquired
FROM tutorial.crunchbase_acquisitions acq
GROUP BY 1
) acquisitions
FULL JOIN (
SELECT invst.funded_month_nm AS month_nm,
COUNT(DISTINCT invst.company_permalink) AS companies_rec_investment
FROM tutorial.crunchbase_investments invst
GROUP BY 1
) investments
ON acquisitions.month_nm = investments.month_nm
table_map, column_map = sql_metadata_lineage.get_metadata("input.sql")
Output text
**** Database.Table alias mapping ****
Subquery mapping alias: acquisitions acq -> tutorial.crunchbase_acquisitions Subquery mapping alias: investments invst -> tutorial.crunchbase_investments
**** Column, Database and Table mapping ****
month_nm -> tutorial.crunchbase_investments.funded_month_nm companies_acquired -> count(DISTINCT tutorial.crunchbase_acquisitions.company_permalink) companies_rec_investment -> count(DISTINCT tutorial.crunchbase_investments.company_permalink)
table_map dictionary output
{'acquisitions': {'acq': 'tutorial.crunchbase_acquisitions'}, 'investments': {'invst': 'tutorial.crunchbase_investments'}}
column_map dictionary output
{'month_nm': 'tutorial.crunchbase_investments.funded_month_nm', 'companies_acquired': 'count(DISTINCT tutorial.crunchbase_acquisitions.company_permalink)', 'companies_rec_investment': 'count(DISTINCT tutorial.crunchbase_investments.company_permalink)'}
Can directly provide sql query as input
table_map, column_map = sql_metadata.get_metadata('''
SELECT investments.month_nm AS month_nm,
acquisitions.companies_acquired,
investments.companies_rec_investment
FROM (
SELECT acq.acquired_month_nm AS month_nm,
COUNT(DISTINCT acq.company_permalink) AS companies_acquired
FROM tutorial.crunchbase_acquisitions acq
GROUP BY 1
) acquisitions
FULL JOIN (
SELECT invst.funded_month_nm AS month_nm,
COUNT(DISTINCT invst.company_permalink) AS companies_rec_investment
FROM tutorial.crunchbase_investments invst
GROUP BY 1
) investments
ON acquisitions.month_nm = investments.month_nm
''')
Metadata
Release files for sql-metadata-lineage 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sql_metadata_lineage-0.0.1.tar.gz | 4.8 kB | Without provenance | Details for sql_metadata_lineage-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sql_metadata_lineage-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for sql_metadata_lineage-0.0.1-py3-none-any.whl |
Total release size: 10.7 kB
Release files / sql_metadata_lineage-0.0.1.tar.gz
| Download URL | sql_metadata_lineage-0.0.1.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d2dd6b39cad716bc74f9266c2c15db5cc3acdee2380c6493a06401c781f6c2f4
|
|
BLAKE2b-256 checksum How to use checksums |
dec422f7972a7439b8955218ad4a076fa95ee0ddda7b3865553078935f08c290
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Release files / sql_metadata_lineage-0.0.1-py3-none-any.whl
| Download URL | sql_metadata_lineage-0.0.1-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1812ae773c0e41f7d14d24fa8ba2f82ff3c9b48ec6693ea51a90fe50b2bf4247
|
|
BLAKE2b-256 checksum How to use checksums |
39d94a1d7067035817309349374976a3d9da5eec72dd1c6944541c6534f4bcb8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.3.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
|
Security for sql-metadata-lineage 0.0.1
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.