Skip to content

Commit 5fce36a

Browse files
committed
fix without cast
1 parent e1a0790 commit 5fce36a

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/snowflake/snowpark/_internal/analyzer/datatype_mapper.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -606,16 +606,9 @@ def numeric_to_sql_without_cast(value: Any, datatype: DataType) -> str:
606606

607607
if not isinstance(datatype, _NumericType):
608608
# if the value is not numeric or the datatype is not numeric, fallback to the
609-
# regular to_sql generation
609+
# regular to_sql generation.
610610
return to_sql(value, datatype)
611611

612-
# DecFloatType must always use DECFLOAT 'value' syntax to preserve precision
613-
if isinstance(datatype, DecFloatType):
614-
if isinstance(value, str):
615-
return f"DECFLOAT {str_to_sql(value)}"
616-
else:
617-
return f"DECFLOAT '{value}'"
618-
619612
if isinstance(value, float) and isinstance(datatype, _FractionalType):
620613
# when the float value is NAN or INF, a cast is still required
621614
if math.isnan(value) or math.isinf(value):

tests/unit/test_datatype_mapper.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -700,6 +700,8 @@ def test_numeric_to_sql_without_cast():
700700
assert numeric_to_sql_without_cast(float("nan"), FloatType()) == "'NAN' :: FLOAT"
701701
assert numeric_to_sql_without_cast(float("inf"), DoubleType()) == "'INF' :: FLOAT"
702702

703+
assert numeric_to_sql_without_cast(Decimal(0.5), DecFloatType()) == "0.5"
704+
703705

704706
@pytest.mark.parametrize(
705707
"value, datatype",

0 commit comments

Comments
 (0)