|
3 | 3 | import warnings |
4 | 4 | import ipaddress |
5 | 5 | import uuid |
| 6 | +from decimal import Decimal |
6 | 7 | from collections.abc import Callable, Sequence |
7 | 8 | from enum import Enum |
8 | 9 | from itertools import zip_longest |
@@ -609,7 +610,7 @@ def is_not_in_near_future(column: str | Column, offset: int = 0, curr_timestamp: |
609 | 610 | @register_rule("row") |
610 | 611 | def is_equal_to( |
611 | 612 | column: str | Column, |
612 | | - value: int | float | str | datetime.date | datetime.datetime | Column | None = None, |
| 613 | + value: int | float | Decimal | str | datetime.date | datetime.datetime | Column | None = None, |
613 | 614 | abs_tolerance: float | None = None, |
614 | 615 | rel_tolerance: float | None = None, |
615 | 616 | ) -> Column: |
@@ -671,7 +672,7 @@ def is_equal_to( |
671 | 672 | @register_rule("row") |
672 | 673 | def is_not_equal_to( |
673 | 674 | column: str | Column, |
674 | | - value: int | float | str | datetime.date | datetime.datetime | Column | None = None, |
| 675 | + value: int | float | Decimal | str | datetime.date | datetime.datetime | Column | None = None, |
675 | 676 | abs_tolerance: float | None = None, |
676 | 677 | rel_tolerance: float | None = None, |
677 | 678 | ) -> Column: |
@@ -733,7 +734,7 @@ def is_not_equal_to( |
733 | 734 |
|
734 | 735 | @register_rule("row") |
735 | 736 | def is_not_less_than( |
736 | | - column: str | Column, limit: int | float | datetime.date | datetime.datetime | str | Column | None = None |
| 737 | + column: str | Column, limit: int | float | Decimal | datetime.date | datetime.datetime | str | Column | None = None |
737 | 738 | ) -> Column: |
738 | 739 | """Checks whether the values in the input column are not less than the provided limit. |
739 | 740 |
|
@@ -763,7 +764,7 @@ def is_not_less_than( |
763 | 764 |
|
764 | 765 | @register_rule("row") |
765 | 766 | def is_not_greater_than( |
766 | | - column: str | Column, limit: int | float | datetime.date | datetime.datetime | str | Column | None = None |
| 767 | + column: str | Column, limit: int | float | Decimal | datetime.date | datetime.datetime | str | Column | None = None |
767 | 768 | ) -> Column: |
768 | 769 | """Checks whether the values in the input column are not greater than the provided limit. |
769 | 770 |
|
@@ -794,8 +795,8 @@ def is_not_greater_than( |
794 | 795 | @register_rule("row") |
795 | 796 | def is_in_range( |
796 | 797 | column: str | Column, |
797 | | - min_limit: int | float | datetime.date | datetime.datetime | str | Column | None = None, |
798 | | - max_limit: int | float | datetime.date | datetime.datetime | str | Column | None = None, |
| 798 | + min_limit: int | float | Decimal | datetime.date | datetime.datetime | str | Column | None = None, |
| 799 | + max_limit: int | float | Decimal | datetime.date | datetime.datetime | str | Column | None = None, |
799 | 800 | ) -> Column: |
800 | 801 | """Checks whether the values in the input column are in the provided limits (inclusive of both boundaries). |
801 | 802 |
|
@@ -832,8 +833,8 @@ def is_in_range( |
832 | 833 | @register_rule("row") |
833 | 834 | def is_not_in_range( |
834 | 835 | column: str | Column, |
835 | | - min_limit: int | float | datetime.date | datetime.datetime | str | Column | None = None, |
836 | | - max_limit: int | float | datetime.date | datetime.datetime | str | Column | None = None, |
| 836 | + min_limit: int | float | Decimal | datetime.date | datetime.datetime | str | Column | None = None, |
| 837 | + max_limit: int | float | Decimal | datetime.date | datetime.datetime | str | Column | None = None, |
837 | 838 | ) -> Column: |
838 | 839 | """Checks whether the values in the input column are outside the provided limits (inclusive of both boundaries). |
839 | 840 |
|
@@ -1585,7 +1586,7 @@ def apply(df: DataFrame, spark: SparkSession, ref_dfs: dict[str, DataFrame]) -> |
1585 | 1586 | @register_rule("dataset") |
1586 | 1587 | def is_aggr_not_greater_than( |
1587 | 1588 | column: str | Column, |
1588 | | - limit: int | float | str | Column, |
| 1589 | + limit: int | float | Decimal | str | Column, |
1589 | 1590 | aggr_type: str = "count", |
1590 | 1591 | group_by: list[str | Column] | None = None, |
1591 | 1592 | row_filter: str | None = None, |
@@ -1630,7 +1631,7 @@ def is_aggr_not_greater_than( |
1630 | 1631 | @register_rule("dataset") |
1631 | 1632 | def is_aggr_not_less_than( |
1632 | 1633 | column: str | Column, |
1633 | | - limit: int | float | str | Column, |
| 1634 | + limit: int | float | Decimal | str | Column, |
1634 | 1635 | aggr_type: str = "count", |
1635 | 1636 | group_by: list[str | Column] | None = None, |
1636 | 1637 | row_filter: str | None = None, |
@@ -1675,7 +1676,7 @@ def is_aggr_not_less_than( |
1675 | 1676 | @register_rule("dataset") |
1676 | 1677 | def is_aggr_equal( |
1677 | 1678 | column: str | Column, |
1678 | | - limit: int | float | str | Column, |
| 1679 | + limit: int | float | Decimal | str | Column, |
1679 | 1680 | aggr_type: str = "count", |
1680 | 1681 | group_by: list[str | Column] | None = None, |
1681 | 1682 | row_filter: str | None = None, |
@@ -1726,7 +1727,7 @@ def is_aggr_equal( |
1726 | 1727 | @register_rule("dataset") |
1727 | 1728 | def is_aggr_not_equal( |
1728 | 1729 | column: str | Column, |
1729 | | - limit: int | float | str | Column, |
| 1730 | + limit: int | float | Decimal | str | Column, |
1730 | 1731 | aggr_type: str = "count", |
1731 | 1732 | group_by: list[str | Column] | None = None, |
1732 | 1733 | row_filter: str | None = None, |
@@ -2780,7 +2781,6 @@ def _add_column_diffs( |
2780 | 2781 | """ |
2781 | 2782 | columns_changed = [] |
2782 | 2783 | if compare_columns: |
2783 | | - |
2784 | 2784 | for col_name in compare_columns: |
2785 | 2785 | is_numeric = isinstance(df.schema[col_name].dataType, types.NumericType) |
2786 | 2786 |
|
@@ -2991,7 +2991,7 @@ def _build_aggregate_check_metadata( |
2991 | 2991 |
|
2992 | 2992 | def _is_aggr_compare( |
2993 | 2993 | column: str | Column, |
2994 | | - limit: int | float | str | Column, |
| 2994 | + limit: int | float | Decimal | str | Column, |
2995 | 2995 | aggr_type: str, |
2996 | 2996 | aggr_params: dict[str, Any] | None, |
2997 | 2997 | group_by: list[str | Column] | None, |
@@ -3218,7 +3218,7 @@ def _cleanup_alias_name(column: str) -> str: |
3218 | 3218 |
|
3219 | 3219 |
|
3220 | 3220 | def get_limit_expr( |
3221 | | - limit: int | float | datetime.date | datetime.datetime | str | Column | None = None, |
| 3221 | + limit: int | float | Decimal | datetime.date | datetime.datetime | str | Column | None = None, |
3222 | 3222 | ) -> Column: |
3223 | 3223 | """ |
3224 | 3224 | Generate a Spark Column expression for a limit value. |
@@ -3247,7 +3247,7 @@ def get_limit_expr( |
3247 | 3247 | parsed_dt = datetime.datetime.fromisoformat(limit) |
3248 | 3248 |
|
3249 | 3249 | # Check if the string contains time component |
3250 | | - has_time = ':' in limit |
| 3250 | + has_time = ":" in limit |
3251 | 3251 |
|
3252 | 3252 | if has_time: |
3253 | 3253 | return F.to_timestamp(F.lit(parsed_dt)) |
|
0 commit comments