INPUT()
All functions > CORE > INPUT()
Declares an input: a typed value that the query binds, such as an entity key.
Signatures
Returns: An input of the given type
INPUT(type) → INPUT sql
| Parameter | Type | Required | Description |
|---|---|---|---|
type | TYPE | Yes | Type of the value, such as BIGINT or BIGINT#CUSTOMERS for an entity key compile-time |
Notes
- Features that depend on an input are evaluated once per bound value
- Bind values in the query with
FOR INPUT_NAME := BIND_VALUES(...)(orBIND_COLUMNS,@BIND_KEYSET) - Annotate the type with an entity (
BIGINT#CUSTOMERS) to make the input a key thatRELATED()andEXTERNAL_COLUMNS()can follow - Inside
MACRO()andVARIANT(), inputs are the parameters that get replaced
See also
Examples
Declare an input and bind values to it
FeatureQL
DEFINE
input1 := INPUT(BIGINT),
calculated := input1 + 1
RETURN
input1,
calculated
FOR
input1 := BIND_VALUES(ARRAY(1, 3, 5))
;Result
| INPUT1 BIGINT | CALCULATED BIGINT |
|---|---|
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |
Entity-annotated input
FeatureQL
DEFINE
entity1 := ENTITY(),
entity2 := ENTITY(),
entity1_id := INPUT(BIGINT#entity1)
RETURN
entity1_id,
plain_id := KEY_TO_SCALAR(entity1_id),
key_for_entity2 := UNSAFE_CAST(entity1_id AS _#entity2),
t_annotated := TYPEOF(entity1_id),
t_plain := TYPEOF(plain_id),
t_remapped := TYPEOF(key_for_entity2),
next_annotated_id := UNSAFE_CAST(KEY_TO_SCALAR(entity1_id) + 1 AS _#entity1),
t_next := TYPEOF(next_annotated_id)
FOR
entity1_id := BIND_VALUES(SEQUENCE(1, 3))
;Result
| ENTITY1_ID BIGINT#ENTITY1 | PLAIN_ID BIGINT | KEY_FOR_ENTITY2 BIGINT#ENTITY2 | T_ANNOTATED VARCHAR | T_PLAIN VARCHAR | T_REMAPPED VARCHAR | NEXT_ANNOTATED_ID BIGINT#ENTITY1 | 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 |