Striim 3.10.1 documentation


SELECT [DISTINCT] { <field name>, ... }
  (<nested collection name>.<member name>[, <type>])
  <iterator name>, 
  <nested collection name>




<var> is of any supported type (see below)


<var> is bound to the specified <type>

The ITERATOR function allows you to access the members of nested collections in a dataset, so long as the collection implements the java.lang.Iterable interface or is a JsonNode.

For example, suppose you have the following statement:

create stream s1 (
    id string, 
    json_array JsonNode,
    list_of_objects java.util.List

The json_array and list_of_objects are both nested data collections.

Since java.util.List implements the java.lang.Iterable interface, you can create an iterator and use it to access the members of list_of_objects :

SELECT lst from s1, ITERATOR(s1.list_of_objects) lst;

Suppose the list_of_objects contains objects of this Java type:

package my.package;
class MyType {
    int attrA;
    int attrB;

You would access its members using this statement:

SELECT attrA, attrB FROM s1, ITERATOR(s1.list_of_objects, my.package.MyType) lst;

The stream also includes a JsonNode member. Suppose the following events are added to the stream:

('a', [1,2,3], null)
('b', [1,3,4], null)

Here is how you can iterate through json_array:

SELECT id, a FROM s1, iterator(s1.json_array) a;
a 1
a 2
a 3
b 1
b 3
b 4

This statement illustrates a cross join between json_array and list_of_objects:

SELECT a, b FROM ITERATOR(s1.json_array) a, ITERATOR(s1.list_of_objects) b, s1;

You can iterate through multiple levels of nesting. For example, this statement iterates through 2 levels, where json_array contains another_nested_collection:

SELECT x FROM s1, ITERATOR(s1.json_array) a, ITERATOR(a.another_nested_collection) x;


Arbitrary data types, such as a Java List, cannot be used with a WActionStore that is persisted to Elasticsearch. Also, it is not possible to convert a JSON List into a Java List.