Skip to main content
Returns the type name of a VARIANT value as a string. This function inspects a VARIANT value and returns its type as a string. This is useful for understanding the structure of VARIANT data or for conditional processing based on the data type.

Syntax

Parameters

  • variant_expr: the expression that represents the VARIANT object. This is typically a VARIANT column from an Iceberg table or a VARIANT value returned by variant_query.

Return value

Returns a VARCHAR value representing the type name. Possible return values include:
  • "Null" - for a VARIANT null, such as a JSON null. For SQL NULL, including the result of variant_query when the path does not exist, the function returns NULL. To test for a VARIANT null, use is_variant_null.
  • "Boolean(true)" - for boolean true values
  • "Boolean(false)" - for boolean false values
  • "Int8", "Int16", "Int32", "Int64" - for integer values
  • "Float", "Double" - for floating-point values
  • "Decimal4", "Decimal8", "Decimal16" - for decimal values with different precision
  • "String" - for string values
  • "Binary" - for binary data
  • "Date" - for date values
  • "TimestampTz", "TimestampNtz" - for timestamp values with or without timezone
  • "TimestampTzNanos", "TimestampNtzNanos" - for nanosecond-precision timestamp values
  • "TimeNtz" - for time values without timezone
  • "Uuid" - for UUID values
  • "Object" - for struct or map values
  • "Array" - for array values

Examples

Example 1: Get the type of a VARIANT value at the root level.
Example 2: Get the type of nested fields.
Example 3: Check types of multiple fields.
Example 4: Use in conditional logic to handle different types.
Example 5: Filter rows based on type.

keyword

VARIANT_TYPEOF,VARIANT