Skip to content

cast

relationalai.semantics.std.common
cast(target_type: Concept, value: Value) -> Expression

Cast a value to the given target type.

The target type is passed to the core cast relation as a meta-reference so the frontcompiler lowers it as a type node rather than as a normal value.

  • target_type

    (Concept) - The target type to cast to, such as Integer, String, or Number.size(10, 2).
  • value

    (Value) - The value to cast.
  • Expression - An Expression representing the cast value.

Cast a value to an integer:

common.cast(Integer, Employee.age_text)

Cast to a sized number type:

common.cast(Number.size(10, 2), Invoice.amount_text)