typeof()

Returns the name of the data type of the result of the expression

Arguments & returns

typeof(expression)

Scalar
Overload link expression Returns
#01 ANY VARCHAR

Example

typeof example
SQL
Haybarn WASM 1.5.5-rc3 · In your browser

Engine example · Run to view results.

In other engines

Used in larger rewrites 1

These examples use typeof as one part of a larger SQL translation.

BigQuerylength()

SELECT LENGTH(foo)
In Haybarn
SELECT CASE TYPEOF(foo) WHEN 'BLOB' THEN OCTET_LENGTH(CAST(foo AS BLOB)) ELSE LENGTH(CAST(foo AS TEXT)) END

SQLGlot example ↗