tabulardelta.comparators.tabulardelta_dataclasses module
- class tabulardelta.comparators.tabulardelta_dataclasses.ChangedValue(example_join_columns: dict[str, Any], old: Any, new: Any, count: int)[source]
Bases:
object
Implements the
ChangedValue
protocol for TabularDelta.- count: int
(Positive) number of rows containing this change.
- example_join_columns: dict[str, Any]
Mapping from column names to values represents an example row where this change occurred.
- new: Any
New value after the change.
- old: Any
Previous value before the change.
- class tabulardelta.comparators.tabulardelta_dataclasses.Column(name: str, type: str)[source]
Bases:
object
Implements the
Column
protocol for TabularDelta.Methods
from_sqlalchemy(column: sa.sql.ColumnElement[Any]) -> Column:
Turns SQLAlchemy.Column into TabularDelta.Column
- static from_sqlalchemy(column: ColumnElement[Any]) Column [source]
Turns SQLAlchemy.Column into TabularDelta.Column.
- Arguments:
- column
sa.sql.ColumnElement[Any]
: SQLAlchemy column to be converted.
- column
- Results
Column
: TabularDelta column with according name and type.
- name: str
Name of the column.
- type: str
Data type of the column.
- class tabulardelta.comparators.tabulardelta_dataclasses.ColumnDelta(cols: list[ColumnPair])[source]
Bases:
object
Implements the
ColumnDelta
protocol.- Attributes:
- added
Metadata of added columns (only in new table).
- comparable_type_changed
Columns with changed but comparable data types.
- differences
Comparable column with changed values.
- incomparable_type_changed
Columns with changed and incomparable data types.
- joined
Columns used to join the old and new table.
- matched
Matched columns (exist in both tables).
- new
Metadata of columns in the new table.
- old
Metadata of columns in the old table.
- removed
Metadata of removed columns (only in old table).
- renamed
Renamed columns (matched using values and types).
- cols: list[ColumnPair]
All (potentially matched) columns of both tables.
Unmatched columns have None on other side.
- property comparable_type_changed: list[ColumnPair]
Columns with changed but comparable data types.
- property differences: list[ColumnPair]
Comparable column with changed values.
- property incomparable_type_changed: list[ColumnPair]
Columns with changed and incomparable data types.
- property joined: list[ColumnPair]
Columns used to join the old and new table.
- property matched: list[ColumnPair]
Matched columns (exist in both tables).
- property renamed: list[ColumnPair]
Renamed columns (matched using values and types).
- class tabulardelta.comparators.tabulardelta_dataclasses.ColumnPair(_old: Column | None = None, _new: Column | None = None, join: bool = False, incomparable: bool = False, _values: DataFrame | None = None)[source]
Bases:
object
Implements the
MatchedColumn
andChangedColumn
protocol for TabularDelta.Methods
from_sqlalchemy(…) -> ColumnPair:
Creates TabularDelta.ColumnPair using SQLAlchemy columns
from_str(…) -> ColumnPair:
Creates TabularDelta.ColumnPair using column names and types
__len__() -> int
Total number of changes
__iter__() -> Iterator[ChangedValue]
Examples of value changes
- static from_sqlalchemy(old: ColumnElement[Any] | None = None, new: ColumnElement[Any] | None = None, join: bool = False, incomparable: bool = False, _values: DataFrame | None = None) ColumnPair [source]
Creates TabularDelta.ColumnPair using SQLAlchemy columns.
- Arguments:
- old
sa.sql.ColumnElement[Any]
|None
: Column in the old table or None if column was added.
- new
sa.sql.ColumnElement[Any]
|None
: Column in the new table or None if column was removed.
- join
bool
: Whether column was used as join column for comparison.
- incomparable
bool
: Whether data types of column in old and new table are incomparable.
- _values
pd.DataFrame
: DataFrame with examples of value changes. Contains old column, new column,
_count
column, and optionally other columns for identifying example rows.
- old
- Returns
ColumnPair
: TabularDelta.ColumnPair with according metadata and values.
- static from_str(old: str | None = None, old_type: str | None = None, new: str | None = None, new_type: str | None = None, join: bool = False, incomparable: bool = False, _values: DataFrame | None = None) ColumnPair [source]
Creates TabularDelta.ColumnPair using column names and types.
- Arguments:
- old
str
|None
: Column name in the old table or None if column was added.
- old_type
str
|None
: Column type in the old table or None if column was added.
- new
str
|None
: Column name in the new table or None if column was removed.
- new_type
str
|None
: Column type in the new table or None if column was removed.
- join
bool
: Whether column was used as join column for comparison.
- incomparable
bool
: Whether data types of column in old and new table are incomparable.
- _values
pd.DataFrame
: DataFrame with examples of value changes. Contains old column, new column,
_count
column, and optionally other columns for identifying example rows. If the column wasn’t renamed, the name of the old column in the DataFrame should be suffixed by_old
.
- old
- Returns
ColumnPair
: TabularDelta.ColumnPair with according metadata and values.
- incomparable: bool = False
Whether data types of column in old and new table are incomparable.
- join: bool = False
Whether column was used as join column for comparison.
- class tabulardelta.comparators.tabulardelta_dataclasses.RowDelta(old: Rows, new: Rows, added: Rows, removed: Rows, equal: Rows, unequal: Rows)[source]
Bases:
object
Implements the
RowDelta
protocol.
- class tabulardelta.comparators.tabulardelta_dataclasses.Rows(count: int, examples: list[dict[str, Any]] | None)[source]
Bases:
object
Implements the
Rows
protocol.- count: int
Number of represented rows.
- examples: list[dict[str, Any]] | None
Optional examples of represented rows.
- class tabulardelta.comparators.tabulardelta_dataclasses.TabularDelta(name: str = '', old_name: str | None = None, info: list[str] = <factory>, warnings: list[str] = <factory>, errors: list[str] = <factory>, _columns: list[~tabulardelta.comparators.tabulardelta_dataclasses.ColumnPair] = <factory>, _old_rows: int = 0, _new_rows: int = 0, _added_rows: int = 0, _removed_rows: int = 0, _equal_rows: int = 0, _unequal_rows: int = 0, _example_added_rows: list[dict[str, ~typing.Any]] = <factory>, _example_removed_rows: list[dict[str, ~typing.Any]] = <factory>, _example_equal_rows: list[dict[str, ~typing.Any]] = <factory>, _example_unequal_rows: list[dict[str, ~typing.Any]] = <factory>)[source]
Bases:
object
Implements the
TabularDelta
protocol.- Attributes:
- cols
Returns
ColumnDelta
implementation.- old_name
- rows
Returns
RowDelta
implementation.
Methods
from_errors(errors: list[str], name: str = “”) -> TabularDelta:
Default TabularDelta containing errors
- property cols: ColumnDelta
Returns
ColumnDelta
implementation.
- errors: list[str]
Errors collected during the comparison.
- static from_errors(errors: list[str], name: str = '') TabularDelta [source]
Creates default TabularDelta object with errors.
- Arguments:
- errors
list[str]
: List of error messages.
- name
str
: Name of the table.
- errors
- Returns
TabularDelta
: TabularDelta object containing errors.
- info: list[str]
Additional information collected during the comparison.
- name: str = ''
Name of the new table and therefore the comparison.
- old_name: str | None = None
Optional name of the old table.
- warnings: list[str]
Warnings collected during the comparison.