NestDream commented on code in PR #58797:
URL: https://github.com/apache/spark/pull/58797#discussion_r4012122134


##########
python/pyspark/sql/conversion.py:
##########
@@ -763,7 +821,11 @@ def convert_timestamp_ntz(value: Any) -> Any:
 
         elif isinstance(dataType, DecimalType):
             exp = decimal.Decimal(f"1E-{dataType.scale}")
-            ctx = decimal.Context(prec=dataType.precision, 
rounding=decimal.ROUND_HALF_EVEN)
+            # The JVM rounds HALF_UP whenever it rescales a decimal 
(Decimal.set,
+            # Decimal.changePrecision, CAST), so the pickled Python paths, 
which let the JVM
+            # rescale, do too. Python's decimal module defaults to HALF_EVEN, 
which turns
+            # 1.005 into 1.00.
+            ctx = decimal.Context(prec=dataType.precision, 
rounding=decimal.ROUND_HALF_UP)

Review Comment:
   yw!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to