Ksql: Add support for building array object (result of 1:N join)

Created on 15 Feb 2019  路  3Comments  路  Source: confluentinc/ksql

Would be nice to be able to join two streams (or stream/table) when there is a relation of 1 to N between a property of the stream A with stream B. For example Customer -> Orders (1:M). Considering the following data set:

Customer:

1 {"customer_id": 1, "name": "Bob"}
2 {"customer_id":2, "name": "Alice"}

Orders:

1 {"order_id": 1, "amount": 100, "currency": "eur", "customer_id": 1}
2 {"order_id": 2, "amount": 20, "currency": "eur", "customer_id": 1}
3 {"order_id": 3, "amount": 97, "currency": "eur", "customer_id": 1}
4 {"order_id": 4, "amount": 2, "currency": "eur", "customer_id": 2}

The data in the joined stream would look like:

1 {"customer_id": 1, "name": "Bob", "orders": [
    {"order_id": 1, "amount": 100, "currency": "eur", "customer_id": 1},
    {"order_id": 2, "amount": 20, "currency": "eur", "customer_id": 1},
    {"order_id": 3, "amount": 97, "currency": "eur", "customer_id": 1}
]}

2 {"customer_id":2, "name": "Alice", "orders": [
    {"order_id": 4, "amount": 2, "currency": "eur", "customer_id": 2}
]}
enhancement join-functions

Most helpful comment

Any updates on this feature, it seems to me this would be akin to collect_list supporting Structs?

All 3 comments

NB This differs from #1559 because the desired output is not multiple messages, but one message with an array holding the N matching join rows. In effect, the opposite operation to #527.

Related to #1830

Any updates on this feature, it seems to me this would be akin to collect_list supporting Structs?

Was this page helpful?
0 / 5 - 0 ratings