Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2022 11:44 PM
There is a reason indeed.
And the reason is type coercion:
In your coalesce, you enter 0 as a second value. 0 is an integer.
So Spark will coerce this to a decimal type. For not losing any information, it needs 10 digits in front of the comma (max value of a signed integer is 2147483647 -> 10 digits).
So when you put (15,6) you only have 9 digits => spark coerces this to 16,6.
The same for (8,0) => 10,0
And (12,0) remains 12,0.
If you want to avoid this coercion, you can pass 0.00 (decimal) instead of 0 (int).
I totally agree that the type coercion can be confusing btw.