Case-change string functions: Correctly set byteLength of the result (Pending)¶
Attention
This behavior change is in the 2026_04 bundle.
For the current status of the bundle, refer to Bundle history.
This behavior change fixes the byte length of the result type for the UPPER
and INITCAP functions. These functions can produce a result whose character
length is up to 3 times the input’s character length, because certain characters can expand into multiple
characters when their case changes (for example, the German sharp s ß becomes SS). Before this fix, the
result type’s character length was correctly tripled but the byte length was left at the input’s byte
length, which could be too small to hold the actual output when non-ASCII characters were involved.
- Before the change:
When
UPPERorINITCAPappeared in a select list, the result type’slengthwas tripled but itsbyteLengthwas copied from the input. For example,UPPER(col)wherecolisVARCHAR(10)withbyteLength = 40producedVARCHAR(30)withbyteLength = 40. In the common ASCII case this didn’t cause visible issues, but with non-ASCII data the stalebyteLengthwas too small for the actual output and could lead to query failures downstream.- After the change:
The
byteLengthof the result type is recomputed from the new character length, so the function always has enough room to hold the actual output. ForUPPER(col)wherecolisVARCHAR(10)withbyteLength = 40, the result is now typedVARCHAR(30)withbyteLength = 120.
This change applies to new query compilations only. Tables and views that were created before the change keep the byte length they were materialized with. If you encounter byte-length-related downstream failures on a pre-existing table, contact Snowflake Support for assistance.
Ref: 2317