Skip to content

Commit 606f3aa

Browse files
committed
Verify SQL Decimal normalization preserves nonfinite rejection
1 parent 40595da commit 606f3aa

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎tests/test_catalog_lifecycle.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import openstatspec
88
import openstatspec.sql.wide as wide
99
from openstatspec.core import UnsupportedOperationError
10+
from openstatspec.sql.profiles import MYSQL, TargetCapabilityExceededError, preflight
1011
from openstatspec.sql.wide import (
1112
ImportRecoveryError,
1213
_bounded_batches,
@@ -237,6 +238,24 @@ def test_database_decimal_numeric_wrappers_are_restored_to_binary64():
237238
assert isinstance(rows[0]["score"], float)
238239

239240

241+
@pytest.mark.parametrize(
242+
"value", [Decimal("NaN"), Decimal("Infinity"), Decimal("-Infinity")],
243+
)
244+
def test_database_decimal_nonfinite_wrappers_remain_rejected(value):
245+
variables = [{
246+
"ordinal": 1,
247+
"source_name": "score",
248+
"physical_name": "score",
249+
"storage_kind": "numeric",
250+
}]
251+
rows = wide._canonicalize_database_numeric_rows([{"score": value}], variables)
252+
253+
with pytest.raises(TargetCapabilityExceededError) as error:
254+
preflight(MYSQL, variables, rows=rows)
255+
256+
assert error.value.details["reason"] == "nonfinite_numeric_value"
257+
258+
240259
def test_bounded_batches_never_exceed_statement_payload_limit():
241260
variables = _variables()
242261
rows = [

0 commit comments

Comments
 (0)