UNSAFE_CAST()

All functions > CORE > UNSAFE_CAST()

Returns the given expression casted to the given type, allowing to change or remove entity type

Signatures

Returns: The expression converted to the specified type, or NULL if conversion fails

UNSAFE_CAST(expr: T, as_type: DataTypeEnum.TYPE) → U
sql
ParameterTypeRequiredDescription
exprTYesThe expression to convert
as_typeDataTypeEnum.TYPEYesThe target data type

Notes

  • Same as CAST but allowing to change or remove entity type

See also

Examples

Typical casts

FeatureQL
SELECT
    f1 := UNSAFE_CAST('123' AS BIGINT), -- Valid string to integer
    f2 := UNSAFE_CAST(3.14E0 AS BIGINT), -- Double truncates toward zero
    f3 := UNSAFE_CAST('2024-06-01' AS DATE) -- String to DATE
;
Result
f1 BIGINTf2 BIGINTf3 TIMESTAMP
12332024-06-01

Last update at: 2026/05/26 17:22:09