Casting
Casting converts a value from one data type to another. It ensures type correctness and enables operations between otherwise incompatible values.
When expressions contain mixed types, DQL automatically promotes values to the most general compatible type according to this order:
BOOLEAN → INTEGER → BIGINT → FLOAT → DOUBLE → STRING
For example:
42 + "7"→"42" + "7"→"427"
Use $cast or $shortCast to override implicit coercion.
$shortCast
Added in: indicate.dsl.dql@1.0.0
Shorthand form for applying a type annotation to an expression. The type is specified inline as an array, and the expression is interpreted accordingly.
{
"$shortCast": Array ( <string> )
}
- JSON
- SQL
{
"$identifier": "user_count",
"$shortCast": [ "DOUBLE" ]
}
user_count::DOUBLE
$cast
Added in: indicate.dsl.dql@1.0.0
Explicitly converts the result of an expression into a target type. This form is used when precise type enforcement is needed for evaluation or compatibility.
{
"$cast": <string>
}
This maps directly to CAST(expression AS TYPE) in SQL.
Example:- JSON
- SQL
{
"$identifier": "user_count",
"$cast": "DOUBLE"
}
CAST(user_count AS DOUBLE)