Skip to content

TupleGet

aggregating category: array no `||` new-mode: required resultSize: 1

Extracts the element at the given 0-based index from a TUPLE-valued field.

TupleGet(:tuple, N) reads a previously-built TUPLE value from the named field and returns its Nth element. It does not consume any pipeline input; the dependency is declared via the field reference, so TupleGet can appear at the start of a sibling chain that needs to unpack values produced earlier by a Tuple rule.

When the source TUPLE was broadcast from an ARRAY (i.e. the field holds an ARRAY<TUPLE>), TupleGet propagates the fan-out: the Nth element is extracted from each TUPLE in the array, with one result per element.

Available in new mode only.

Parameters

1tuple Mandatory — accepts: field

Field reference (:-notation) to a CDM field holding a TUPLE value (or an ARRAY<TUPLE>).

2index Mandatory — accepts: INT

0-based index into the tuple. Must be non-negative.

Input type

Output type

  • UNKNOWN

The element type is inferred from the destination CDM field. Out-of-range indices raise a runtime error.

Requires

  • First parameter must be a field reference in :-notation.
  • Second parameter must be a non-negative integer index.
  • The referenced field must hold a TUPLE (or ARRAY<TUPLE>) at runtime.

Examples

Unpack a tuple stored in a virtual field (test092)

Tuple(:cid, :eth) => :gtuple
TupleGet(:gtuple, 0) => :gender_concept_id
TupleGet(:gtuple, 1) => :ethnicity_concept_id

Errors

  • TupleGet: dependency value is not a TUPLE
    The referenced field does not hold a TUPLE at runtime.
  • TupleGet: index out of range
    The 0-based index is >= the tuple length.
  • TupleGet() index must be non-negative
    A negative index literal was supplied.
  • TupleGet() requires exactly two parameters
    Wrong arity.
  • TupleGet() is only available in new mode
    New mode is not enabled in etl.conf.

See also

Tuple, GetCDMFieldValue