Cross Transform
The cross transform compute the cross-product of a data stream with itself.
Transform Parameters
Property | Type | Description |
---|---|---|
filter | Expr | An optional filter expression for limiting the results of the cross-product. |
as | Array | The output fields for the two data objects being crossed. The default is ["a", "b"] . |
Usage
If the input data is [{v:1}, {v:2}, {v:3}]
, then the transform definition
{"type": "cross"}
produces the output
[
{"a": {"v": 1}, "b": {"v": 1}},
{"a": {"v": 1}, "b": {"v": 2}},
{"a": {"v": 1}, "b": {"v": 3}},
{"a": {"v": 2}, "b": {"v": 1}},
{"a": {"v": 2}, "b": {"v": 2}},
{"a": {"v": 2}, "b": {"v": 3}},
{"a": {"v": 3}, "b": {"v": 1}},
{"a": {"v": 3}, "b": {"v": 2}},
{"a": {"v": 3}, "b": {"v": 3}}
]
Similarly, with the same input data, the following transform
{"type": "cross", "filter": "datum.a !== datum.b"}
produces the output
[
{"a": {"v": 1}, "b": {"v": 2}},
{"a": {"v": 1}, "b": {"v": 3}},
{"a": {"v": 2}, "b": {"v": 1}},
{"a": {"v": 2}, "b": {"v": 3}},
{"a": {"v": 3}, "b": {"v": 1}},
{"a": {"v": 3}, "b": {"v": 2}}
]