Skip to main content

tbl_ends_with()

Select tables whose names end with some text.

Usage

Source

tbl_ends_with(
    text,
    case_sensitive=False,
)

tbl_ends_with() selects the tables whose names end with text=, such as the tables named with a suffix for their kind (e.g., orders_fact and sales_fact, or customers_dim and products_dim). Like the other table selectors, it’s used in the applies_to= argument of a Standard or of Standard.apply(). The name tested is the table’s own name, without a schema or a file extension.

Parameters

text: str

The text that a table’s name must end with.

case_sensitive: bool = False
Whether the comparison is case-sensitive. The default is False.

Returns

TableSelector
A table selector, which can be combined with other table selectors with & (and), | (or), - (difference), and ~ (not).

Examples

Here, a standard for the dimension tables of a warehouse applies to the tables whose names end with "_dim":

import pointblank as pb
import polars as pl

tables = {
    "customers_dim": pl.DataFrame({"id": [1, 2]}),
    "products_dim": pl.DataFrame({"id": [1, 2]}),
    "orders_fact": pl.DataFrame({"id": [1, 2]}),
}

dim_standard = pb.Standard(
    name="dimension-keys",
    steps=[pb.Step("rows_distinct", columns_subset="id")],
    applies_to=pb.tbl_ends_with("_dim"),
)

dim_standard.find_tables(tables)
['customers_dim', 'products_dim']

The fact table is left out, so only the two dimension tables would be validated.