Skip to main content

typeof function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Return a DDL-formatted type string for the data type of the input.

Syntax

typeof(expr)

Arguments

  • expr: Any expression.

Returns

A STRING.

To derive the type of a VARIANT value, use the schema_of_variant function function.

To derive the combined schema of a group of VARIANT values, use the schema_of_variant_agg aggregate function aggregate function.

Examples

SQL
> SELECT typeof(1);
int

> SELECT typeof(array(1));
array<int>

> SELECT typeof(123.4::VARIANT);
variant

> SELECT schema_of_variant(123.4::VARIANT);
DECIMAL(4,1)

> SELECT typeof('hello' COLLATE UTF8_LCASE);
string collate UTF8_LCASE