# Type Casts | Expression | Example | Description | | ------------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------- | | `CAST(expr AS type`) | `CAST(1.25 AS FLOAT)` | Converts an expression to another data type. For conversions to a TEXT type, use TRY\_CAST. | | `TRY_CAST(text_expr AS type`) | `CAST('1.25' AS FLOAT)` | Converts a text to a non-text type, returning null if the conversion could not be successfully performed. | | `ENCODE_TEXT(none_encoded_str`) | `ENCODE_TEXT(long_str)` | Converts a none-encoded text type to a dictionary-encoded text type. | The following table shows cast type conversion support.
FROM/TO:TINYINTSMALLINTINTEGERBIGINTFLOATDOUBLEDECIMALTEXTBOOLEANDATETIMETIMESTAMP
FROM/TO:TINYINTSMALLINTINTEGERBIGINTFLOATDOUBLEDECIMALTEXTBOOLEANDATETIMETIMESTAMP
TINYINT-YesYesYesYesYesYesYesNoNoNon/a
SMALLINTYes-YesYesYesYesYesYesNoNoNon/a
INTEGERYesYes-YesYesYesYesYesYesNoNoNo
BIGINTYesYesYes-YesYesYesYesNoNoNoNo
FLOATYesYesYesYes-YesNoYesNoNoNoNo
DOUBLEYesYesYesYesYes-NoYesNoNoNon/a
DECIMALYesYesYesYesYesYes-YesNoNoNon/a
TEXTYes (Use TRY_CAST)Yes (Use TRY_CAST)Yes (Use TRY_CAST)Yes (Use TRY_CAST)Yes (Use TRY_CAST)Yes (Use TRY_CAST)Yes (Use TRY_CAST)-Yes (Use TRY_CAST)Yes (Use TRY_CAST)Yes (Use TRY_CAST)Yes (Use TRY_CAST)
BOOLEANNoNoYesNoNoNoNoYes-n/an/an/a
DATENoNoNoNoNoNoNoYesn/a-NoYes
TIMENoNoNoNoNoNoNoYesn/aNo-n/a
TIMESTAMPNoNoNoNoNoNoNoYesn/aYesNo-
##