Type Conversions
Applies to: ✅ Data 360 SQL ✅ Tableau Hyper API
You can convert from one data type to another using CAST or TRY_CAST.
The SQL CAST function converts a value from one type to another. If the type conversion fails, Data 360 SQL throws an error. In contrast, the TRY_CAST function returns NULL if the conversion fails.
The syntax :: is equivalent to CAST.
You can create arrays by casting string literals or by using the Array Constructor syntax. To cast a string literal to an array, use the ::array(<type>) syntax:
An array string literal consists of a comma-separated list of element literals surrounded by square brackets [...]. The element literal syntax is identical to that of the respective atomic type.
For string array types, any upper or lower case variant of the element literal null is parsed as a null value. To specify the string "null", escape the element literal by using double quotes. For example:
Returns: [NULL,"null"] — a null element, followed by the string 'null'.
When returning an array of text types, every non-null element is quoted.