ENTITY()

All functions > CORE > ENTITY()

Returns a reference to an entity.

Signatures

Returns: An ENTITY type marker

ENTITY() → ENTITY
sql
ParameterTypeRequiredDescription

Notes

  • Defines an entity in the FeatureMesh system
  • Entities represent the primary keys around which features are organized
  • Used in feature definitions to specify entity relationships
  • Part of the FeatureMesh core type system
  • Essential for feature materialization and keyset operations

Examples

ENTITY() with INPUT and bindings (2-types.slt)

FeatureQL
WITH
    entity1 := ENTITY(),
    entity2 := ENTITY(),
    entity1_id := INPUT(BIGINT#ENTITY1)
SELECT
    entity1_id,
    plain_id := UNSAFE_CAST(entity1_id AS BIGINT),
    key_for_entity2 := UNSAFE_CAST(entity1_id AS BIGINT#ENTITY2),
    t_annotated := TYPEOF(entity1_id),
    t_plain := TYPEOF(plain_id),
    t_remapped := TYPEOF(key_for_entity2),
    next_annotated_id := UNSAFE_CAST(
        UNSAFE_CAST(entity1_id AS BIGINT) + 1 AS BIGINT#ENTITY1
    ),
    t_next := TYPEOF(next_annotated_id)
FOR
    entity1_id := BIND_VALUES(SEQUENCE(1, 3))
;
Result
ENTITY1_ID BIGINTPLAIN_ID BIGINTKEY_FOR_ENTITY2 BIGINTT_ANNOTATED VARCHART_PLAIN VARCHART_REMAPPED VARCHARNEXT_ANNOTATED_ID BIGINTT_NEXT VARCHAR
111BIGINT#ENTITY1BIGINTBIGINT#ENTITY22BIGINT#ENTITY1
222BIGINT#ENTITY1BIGINTBIGINT#ENTITY23BIGINT#ENTITY1
333BIGINT#ENTITY1BIGINTBIGINT#ENTITY24BIGINT#ENTITY1

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