ENTITY()
All functions > CORE > ENTITY()
Returns a reference to an entity.
Signatures
Returns: An ENTITY type marker
ENTITY() → ENTITY sql
| Parameter | Type | Required | Description |
|---|
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 BIGINT | PLAIN_ID BIGINT | KEY_FOR_ENTITY2 BIGINT | T_ANNOTATED VARCHAR | T_PLAIN VARCHAR | T_REMAPPED VARCHAR | NEXT_ANNOTATED_ID BIGINT | T_NEXT VARCHAR |
|---|---|---|---|---|---|---|---|
| 1 | 1 | 1 | BIGINT#ENTITY1 | BIGINT | BIGINT#ENTITY2 | 2 | BIGINT#ENTITY1 |
| 2 | 2 | 2 | BIGINT#ENTITY1 | BIGINT | BIGINT#ENTITY2 | 3 | BIGINT#ENTITY1 |
| 3 | 3 | 3 | BIGINT#ENTITY1 | BIGINT | BIGINT#ENTITY2 | 4 | BIGINT#ENTITY1 |