Skip to content

Commit ec91c91

Browse files
authored
chore: update compatibility guide for primitive to string casts (#4012)
1 parent 09d9ace commit ec91c91

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/source/user-guide/latest/compatibility.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,18 @@ suffixes (e.g. `Europe/Moscow`), and the full Spark timestamp year range
160160
(-290308 to 294247). Note that `CAST(string AS DATE)` is only compatible for years between
161161
262143 BC and 262142 AD due to an underlying library limitation.
162162

163+
### Decimal with Negative Scale to String
164+
165+
Casting a `DecimalType` with a negative scale to `StringType` is marked as incompatible when
166+
`spark.sql.legacy.allowNegativeScaleOfDecimal` is `false` (the default). When that config is
167+
disabled, Spark cannot create negative-scale decimals, so Comet falls back to avoid running
168+
native execution on unexpected inputs.
169+
170+
When `spark.sql.legacy.allowNegativeScaleOfDecimal=true`, the cast is compatible. Comet matches
171+
Spark's behavior of using Java `BigDecimal.toString()` semantics, which produces scientific
172+
notation (e.g. a value of 12300 stored as `Decimal(7,-2)` with unscaled value 123 is rendered
173+
as `"1.23E+4"`).
174+
163175
### Legacy Mode
164176

165177
<!--BEGIN:CAST_LEGACY_TABLE-->

0 commit comments

Comments
 (0)