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
ParameterTypeRequiredDescription
typeTYPEYesType 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(...) (or BIND_COLUMNS, @BIND_KEYSET)
  • Annotate the type with an entity (BIGINT#CUSTOMERS) to make the input a key that RELATED() and EXTERNAL_COLUMNS() can follow
  • Inside MACRO() and VARIANT(), 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 BIGINTCALCULATED BIGINT
12
34
56

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#ENTITY1PLAIN_ID BIGINTKEY_FOR_ENTITY2 BIGINT#ENTITY2T_ANNOTATED VARCHART_PLAIN VARCHART_REMAPPED VARCHARNEXT_ANNOTATED_ID BIGINT#ENTITY1T_NEXT VARCHAR
111BIGINT#ENTITY1BIGINTBIGINT#ENTITY22BIGINT#ENTITY1
222BIGINT#ENTITY1BIGINTBIGINT#ENTITY23BIGINT#ENTITY1
333BIGINT#ENTITY1BIGINTBIGINT#ENTITY24BIGINT#ENTITY1