[
https://issues.apache.org/jira/browse/KAFKA-3705?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16584254#comment-16584254
]
ASF GitHub Bot commented on KAFKA-3705:
---------------------------------------
bellemare opened a new pull request #5527: [DO NOT MERGE] - KAFKA-3705 Added a
foreignKeyJoin implementation for KTable.
URL: https://github.com/apache/kafka/pull/5527
https://issues.apache.org/jira/browse/KAFKA-3705
Foreign Key Join:
================================
Allows for a KTable to map its value to a given foreign key and join on
another KTable keyed on that foreign key. Applies the joiner, then returns the
tuples keyed on the original key. This supports updates from both sides of the
join.
Design Philosophy:
================================
The intent of this design was to build a totally encapsulated function that
operates very similarly to the regular join function. No further work is
required by the user to obtain their foreignKeyJoin results after calling the
function. That being said, there is increased cost in some of the topology
components, especially due to resolving out-of-order arrival due to foreign key
changes. I would appreciate any and all feedback on this approach, as my
understanding of the Kafka Streams DSL is to provide higher level functionality
without requiring the users to know exactly what's going on under the hood.
Some points of note:
1) Requires three full materialized State Stores
One for the prefixScanning of the repartitioned CombinedKey events.
One for the highwater mark for resolving out-of-order processing of
events.
One for the final materialized sink. This is required because I am
sourcing the events back from a repartitioning topic, and so a state store is
required to construct a proper Topic Source (see KTableSource).
2) Merging the highwater and final materialized may be possible, but it is
unlikely to be useful if we wish for users of this API to be able to specify
their own Materialized state store.
3) Caching is disabled on the prefixScan store, same reasons as Jan gave
above.
4) ReadOnlyKeyValueStore interface was modified to contain prefixScan. This
requires that all implementations support this, but follows an existing
precedent where some store functions are already stubbed out with exceptions.
5) Currently limited to Inner Join (can do more join logic in future - just
limiting the focus of this KIP).
6) Uses RecordHeaders to address out-of-order processing. The added offset
and propagate headers used by the foreignKeyJoin do not persist outside of the
function, but they may collide with user-specified header keys.
7) CombinedKeyByForeignKeyPartitioner -> uses a copied + pasted
implementation of the DefaultPartitioner. Evaluate breaking this out of the
DefaultPartitioner Producer into an accessible function.
8) The large number of variables passed to the
KTableKTableForeignKeyJoinNode. Current decision is to leave it as its own node
because it doesn't quite fit the patterns of existing nodes. In addition, I am
not sure if it each DSL operation should have its own Node type or not.
9) The KTableKTableForeignKeyJoinNode signature (25 parameters! too many,
should be < 13)
10) Application Reset does not seem to delete the new internal topics that I
have added. (only tested with Kafka 1.0).
Testing:
================================
Testing is covered by a single integration test that exercises the foreign
key join. In addition, it exercises the out-of-order resolution and
partitioning strategies by running three streams instances on three partitions.
This demonstrates the scalability of the proposed solution.
Note: Because this solution uses the actual offsets of messages to handle
out of order resolution, the unit testing framework is not suitable (as far as
I can tell) since the offset is not actually provided by the context() access.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Support non-key joining in KTable
> ---------------------------------
>
> Key: KAFKA-3705
> URL: https://issues.apache.org/jira/browse/KAFKA-3705
> Project: Kafka
> Issue Type: Bug
> Components: streams
> Reporter: Guozhang Wang
> Priority: Major
> Labels: api
>
> Today in Kafka Streams DSL, KTable joins are only based on keys. If users
> want to join a KTable A by key {{a}} with another KTable B by key {{b}} but
> with a "foreign key" {{a}}, and assuming they are read from two topics which
> are partitioned on {{a}} and {{b}} respectively, they need to do the
> following pattern:
> {code}
> tableB' = tableB.groupBy(/* select on field "a" */).agg(...); // now tableB'
> is partitioned on "a"
> tableA.join(tableB', joiner);
> {code}
> Even if these two tables are read from two topics which are already
> partitioned on {{a}}, users still need to do the pre-aggregation in order to
> make the two joining streams to be on the same key. This is a draw-back from
> programability and we should fix it.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)