# Why foreignKeyExtractor does not accept key?

**URL:** <https://forum.confluent.io/t/why-foreignkeyextractor-does-not-accept-key/12427>\
**Category:** Kafka Streams\
**Created:** [25 October 2024 16:04 UTC](https://forum.confluent.io/t/why-foreignkeyextractor-does-not-accept-key/12427 "2024-10-25T16:04:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jasaczek](https://avatars.discourse-cdn.com/v4/letter/j/d6d6ee/32.png) [@jasaczek](https://forum.confluent.io/u/jasaczek)\
**Post date:** [25 October 2024 16:04 UTC](https://forum.confluent.io/t/why-foreignkeyextractor-does-not-accept-key/12427/1 "2024-10-25T16:04:00Z")

</div>

Hi,

We are quite often using a foreign key join to join data where left side is keyed by `<producer_id, product_id>` and right side is `<producer_id>`. (let’s assume that `product_id` can be repeated between `producer_ids`).  
However, `foreignKeyExtractor` is only accepting value of the left side which forces us to copy `producer_id` in the value of the left side. Is there a reason for this design choice?

Ideally, we would be able to custom partition the left side using the `producer_id` to ensure that both sides are co-partitioned and do a foreign key join without the intermediate topics. I saw [KIP-759: Unneeded repartition canceling - Apache Kafka - Apache Software Foundation](https://cwiki.apache.org/confluence/display/KAFKA/KIP-759%3A+Unneeded+repartition+canceling) and the hack in [Kafka Streams: a map not repartitioning co-partitioned data - Stack Overflow](https://stackoverflow.com/questions/51421693/kafka-streams-a-map-not-repartitioning-co-partitioned-data)  
but I don’t think either would allow me to do that.

Is there a better way of solving this?

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [25 October 2024 17:24 UTC](https://forum.confluent.io/t/why-foreignkeyextractor-does-not-accept-key/12427/2 "2024-10-25T17:24:39Z")

</div>

Good point. I think it’s just a oversight in the design of FK join. I don’t see any reason why we would need to limit the FK-extractor to only user the value as input.

Can you file a Jira ticket for this?

I cannot think of any other workaround right now, but believe what you do (duplicate the FK key column into the value) is the only way to make it work right now.

---

<div class="post-metadata">

**Author:** ![mjsax](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/mjsax/32/3113_2.png) [@mjsax](https://forum.confluent.io/u/mjsax)\
**Post date:** [7 November 2024 19:49 UTC](https://forum.confluent.io/t/why-foreignkeyextractor-does-not-accept-key/12427/3 "2024-11-07T19:49:05Z")

</div>

[https://issues.apache.org/jira/browse/KAFKA-17893](https://issues.apache.org/jira/browse/KAFKA-17893)
