I recently faced this issue you can solve this by using spark.sql.decimalOperations.allowPrecisionLoss
to true
or false
Or using Pandas dataframe in pyspark. You can refer below site
https://datawithazure.blogspot.com/2025/04/when-spark-gets-math-wrong.html