# 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.

<table data-header-hidden><thead><tr><th width="161">FROM/TO:</th><th width="150">TINYINT</th><th width="150">SMALLINT</th><th width="150">INTEGER</th><th width="150">BIGINT</th><th width="150">FLOAT</th><th width="150">DOUBLE</th><th width="150">DECIMAL</th><th width="150">TEXT</th><th width="150">BOOLEAN</th><th width="150">DATE</th><th width="150">TIME</th><th>TIMESTAMP</th></tr></thead><tbody><tr><td>FROM/TO:</td><td><code>TINYINT</code></td><td><code>SMALLINT</code></td><td><code>INTEGER</code></td><td><code>BIGINT</code></td><td><code>FLOAT</code></td><td><code>DOUBLE</code></td><td><code>DECIMAL</code></td><td><code>TEXT</code></td><td><code>BOOLEAN</code></td><td><code>DATE</code></td><td><code>TIME</code></td><td><code>TIMESTAMP</code></td></tr><tr><td><code>TINYINT</code></td><td>-</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>No</td><td>No</td><td>No</td><td>n/a</td></tr><tr><td><code>SMALLINT</code></td><td>Yes</td><td>-</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>No</td><td>No</td><td>No</td><td>n/a</td></tr><tr><td><code>INTEGER</code></td><td>Yes</td><td>Yes</td><td>-</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>No</td><td>No</td><td>No</td></tr><tr><td><code>BIGINT</code></td><td>Yes</td><td>Yes</td><td>Yes</td><td>-</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>No</td><td>No</td><td>No</td><td>No</td></tr><tr><td><code>FLOAT</code></td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>-</td><td>Yes</td><td>No</td><td>Yes</td><td>No</td><td>No</td><td>No</td><td>No</td></tr><tr><td><code>DOUBLE</code></td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>-</td><td>No</td><td>Yes</td><td>No</td><td>No</td><td>No</td><td>n/a</td></tr><tr><td><code>DECIMAL</code></td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>Yes</td><td>-</td><td>Yes</td><td>No</td><td>No</td><td>No</td><td>n/a</td></tr><tr><td><code>TEXT</code></td><td>Yes (Use TRY_CAST)</td><td>Yes (Use TRY_CAST)</td><td>Yes (Use TRY_CAST)</td><td>Yes (Use TRY_CAST)</td><td>Yes (Use TRY_CAST)</td><td>Yes (Use TRY_CAST)</td><td>Yes (Use TRY_CAST)</td><td>-</td><td>Yes (Use TRY_CAST)</td><td>Yes (Use TRY_CAST)</td><td>Yes (Use TRY_CAST)</td><td>Yes (Use TRY_CAST)</td></tr><tr><td><code>BOOLEAN</code></td><td>No</td><td>No</td><td>Yes</td><td>No</td><td>No</td><td>No</td><td>No</td><td>Yes</td><td>-</td><td>n/a</td><td>n/a</td><td>n/a</td></tr><tr><td><code>DATE</code></td><td>No</td><td>No</td><td>No</td><td>No</td><td>No</td><td>No</td><td>No</td><td>Yes</td><td>n/a</td><td>-</td><td>No</td><td>Yes</td></tr><tr><td><code>TIME</code></td><td>No</td><td>No</td><td>No</td><td>No</td><td>No</td><td>No</td><td>No</td><td>Yes</td><td>n/a</td><td>No</td><td>-</td><td>n/a</td></tr><tr><td><code>TIMESTAMP</code></td><td>No</td><td>No</td><td>No</td><td>No</td><td>No</td><td>No</td><td>No</td><td>Yes</td><td>n/a</td><td>Yes</td><td>No</td><td>-</td></tr></tbody></table>

##
