Jump to content
  • How to filter out tuple sub-field elements by predicate


    Issue

    I have a list of tuples, where the schema for the tuple element has a field named 'status'. I would like to filter out any elements where status is 'inactive'. How can I accomplish this in Event Flow?

    Solution

    In StreamBase 7.4 or later, use the filterlist() function, as defined in the Help under

    • StreamBase Home > StreamBase References > StreamBase Expression Language Functions > (sub-heading) Simple Functions: Lists

    For example, if the tuple list element has a Named Schema 'Customer' with sub-fields 'name' and 'status', you can filter out inactive entries in a Map operator using the following expression:

     filterlist(input1.Customer, function notInactive(cust Customer) {cust.status != 'inactive'})

    This expression creates a user-defined function, 'notInactive', which applies the predicate cust.status != 'inactive'.


    User Feedback

    Recommended Comments

    There are no comments to display.


×
×
  • Create New...