Skip to content

Commit

Permalink
postgres consistency: update ignore filter (#22406)
Browse files Browse the repository at this point in the history
  • Loading branch information
nrainer-materialize authored Oct 16, 2023
1 parent 464738a commit b6ae970
Showing 1 changed file with 17 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@
TIME_TYPE_IDENTIFIER,
TIMESTAMPTZ_TYPE_IDENTIFIER,
)
from materialize.output_consistency.input_data.types.number_types_provider import (
REAL_TYPE_IDENTIFIER,
)
from materialize.output_consistency.operation.operation import (
DbFunction,
DbOperation,
Expand Down Expand Up @@ -82,7 +79,7 @@ def _matches_problematic_operation_or_function_invocation(
):
return YesIgnore("#22016: age, to_char, and others ignore timezone")

if _matches_eq_with_real(expression):
if matches_float_comparison(expression):
return YesIgnore("#22022: real with decimal comparison")

return super()._matches_problematic_operation_or_function_invocation(
Expand Down Expand Up @@ -293,12 +290,6 @@ def matches_round_function(expression: Expression) -> bool:
):
return YesIgnore("#21995: underflow in mz")

if (
'inf" real out of range' in mz_error_msg
and query_template.matches_any_expression(_matches_eq_with_real, True)
):
return YesIgnore("#20022: real resulting in out of range")

if (
"precision for type timestamp or timestamptz must be between 0 and 6"
in mz_error_msg
Expand Down Expand Up @@ -409,6 +400,9 @@ def matches_nullif(expression: Expression) -> bool:
):
return YesIgnore("Different precision causes issues")

if query_template.matches_any_expression(matches_float_comparison, True):
return YesIgnore("Caused by a different precision")

if query_template.matches_any_expression(matches_mod_with_decimal, True):
return YesIgnore("Caused by a different precision")

Expand Down Expand Up @@ -443,24 +437,6 @@ def _shall_ignore_row_count_mismatch(
query_template: QueryTemplate,
contains_aggregation: bool,
) -> IgnoreVerdict:
def matches_float_comparison(expression: Expression) -> bool:
if isinstance(expression, ExpressionWithArgs) and isinstance(
expression.operation, DbOperation
):
if expression.operation.pattern == "$ = $":
type_spec_arg0 = expression.args[0].resolve_return_type_spec()
type_spec_arg1 = expression.args[1].resolve_return_type_spec()

return (
isinstance(type_spec_arg0, NumericReturnTypeSpec)
and type_spec_arg0.always_floating_type
) or (
isinstance(type_spec_arg1, NumericReturnTypeSpec)
and type_spec_arg1.always_floating_type
)

return False

if query_template.matches_any_expression(matches_float_comparison, True):
return YesIgnore("Caused by a different precision")

Expand All @@ -469,18 +445,21 @@ def matches_float_comparison(expression: Expression) -> bool:
)


def _matches_eq_with_real(expression: Expression) -> bool:
if (
isinstance(expression, ExpressionWithArgs)
and isinstance(expression.operation, DbOperation)
and expression.operation.pattern == "$ = $"
def matches_float_comparison(expression: Expression) -> bool:
if isinstance(expression, ExpressionWithArgs) and isinstance(
expression.operation, DbOperation
):
type_arg0 = expression.args[0].try_resolve_exact_data_type()
type_arg1 = expression.args[1].try_resolve_exact_data_type()
if expression.operation.pattern == "$ = $":
type_spec_arg0 = expression.args[0].resolve_return_type_spec()
type_spec_arg1 = expression.args[1].resolve_return_type_spec()

return (
type_arg0 is not None and type_arg0.type_name == REAL_TYPE_IDENTIFIER
) or (type_arg1 is not None and type_arg1.type_name == REAL_TYPE_IDENTIFIER)
return (
isinstance(type_spec_arg0, NumericReturnTypeSpec)
and type_spec_arg0.always_floating_type
) or (
isinstance(type_spec_arg1, NumericReturnTypeSpec)
and type_spec_arg1.always_floating_type
)

return False

Expand Down

0 comments on commit b6ae970

Please sign in to comment.