TYPEOF

Determines the data type of value.

This function corresponds to the typeof(X) function in SQLite. It returns a string that indicates the fundamental data type of the expression result from the column.

The possible return values are:

  • "null"

  • "integer"

  • "real"

  • "text"

  • "blob"

This is useful for inspecting the underlying storage class of a value in a column, especially in weakly-typed columns or when dealing with dynamic data.

Example

// Create a table with a column of a dynamic type (or ANY)
CREATE TABLE Test (value);
INSERT INTO Test VALUES (123); -- typeof(value) -> 'integer'
INSERT INTO Test VALUES (123.45); -- typeof(value) -> 'real'
INSERT INTO Test VALUES ('hello'); -- typeof(value) -> 'text'
INSERT INTO Test VALUES (NULL); -- typeof(value) -> 'null'
INSERT INTO Test VALUES (x'010203'); -- typeof(value) -> 'blob'

// In KQLite, you would query it like this:
val valueType = select(TYPEOF(Test.value)).from(Test).where(Test.id eq 1)

Return

A KQLiteColumn of type String containing the name of the data type (e.g., "integer", "text", "blob", "real", or "null").

Author

MOHAMMAD AZIM ANSARI

Parameters

column

The column or expression whose data type is to be determined.

See also