Skip to main content

TYPEOF

Returns the storage type of a value: null, integer, real, text or blob. Object and array fields from provider responses are stored as JSON text, so they report text.

See also:
[SELECT] [ Data Types ] [JSON_TYPE]


Syntax​

SELECT TYPEOF(expression) FROM <multipartIdentifier>;

Arguments​

expression
Any expression.

Return Value(s)​

Returns a string.


Examples​

Types of literal values​

Each literal reports its own type:

SELECT TYPEOF(42) AS i, TYPEOF(4.2) AS r, TYPEOF('42') AS t, TYPEOF(NULL) AS n, TYPEOF(x'00') AS b;
|------|---------|------|------|------|
| b | i | n | r | t |
|------|---------|------|------|------|
| blob | integer | null | real | text |
|------|---------|------|------|------|

Types of provider fields​

The following query shows the types of an integer field, an array field and an object field that is sometimes missing in GitHub repository rows:

SELECT name,
TYPEOF(stargazers_count) AS stars_type,
TYPEOF(topics) AS topics_type,
TYPEOF(license) AS license_type
FROM github.repos.repos
WHERE org = 'stackql-labs';

For more information, see https://www.sqlite.org/lang_corefunc.html#typeof