Skip to main content

StandardsRegistry.find_tables()

List the tables of a source that each standard of the registry applies to.

Usage

Source

StandardsRegistry.find_tables(source)

This is Standard.find_tables() for every standard of the registry: it finds the tables of a source and selects those that each standard would validate, without reading or validating any of them.

Parameters

source: Any
The tables: a dictionary of names to tables, an Ibis connection or a connection string, a directory, a glob pattern, or a list of files (see the Sources of Tables section of Standard).

Returns

dict[str, list[str]]
The names of the selected tables, by the name of each standard.

Examples

A registry with a standard for the staging tables and one for every table:

import pointblank as pb
import polars as pl
import tempfile
from pathlib import Path

standards_dir = Path(tempfile.mkdtemp())

pb.Standard(
    name="staging", steps=[pb.Step("rows_distinct")], applies_to=pb.tbl_starts_with("stg_")
).to_yaml(standards_dir / "staging.yaml")
pb.Standard(name="baseline", steps=[pb.Step("rows_complete")]).to_yaml(
    standards_dir / "baseline.yaml"
)

tables = {"stg_orders": pl.DataFrame({"id": [1]}), "orders": pl.DataFrame({"id": [1]})}

pb.StandardsRegistry(standards_dir).find_tables(tables)
{'baseline': ['stg_orders', 'orders'], 'staging': ['stg_orders']}

Both tables get the baseline standard, and only stg_orders gets the staging standard.