- Categories:
Semi-structured and structured data functions (Type Predicates)
TYPEOF¶
Returns the type of a value stored in a VARIANT column.
- See also:
Syntax¶
Arguments¶
exprThe argument can be a column name or a general expression of type VARIANT. If necessary, you can cast the
exprto a VARIANT.
Returns¶
Returns a VARCHAR value that contains the data type of the input expression, such as BOOLEAN, DECIMAL, ARRAY, OBJECT, and so on.
Usage notes¶
The returned string might be DECIMAL even if the input is an exact integer, due to optimizations that change the physical storage type of the input.
This function doesn’t support a structured type as an input argument.
Examples¶
Create and fill the vartab table. The INSERT statement uses the PARSE_JSON function to insert
VARIANT values in the v column of the table.
Query the data. The query uses the TYPEOF function to show the data types of the values stored in the VARIANT column.
The following example uses the TYPEOF function to determine the data type of a value by casting the value to a VARIANT.
Create and populate a table:
Query the table using the TYPEOF function by casting each value to a VARIANT: