# Stream composite keys

**URL:** <https://forum.confluent.io/t/stream-composite-keys/5430>\
**Category:** ksqlDB\
**Created:** [30 June 2022 21:27 UTC](https://forum.confluent.io/t/stream-composite-keys/5430 "2022-06-30T21:27:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacob-braze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/jacob-braze/32/2018_2.png) [@jacob-braze](https://forum.confluent.io/u/jacob-braze)\
**Post date:** [30 June 2022 21:27 UTC](https://forum.confluent.io/t/stream-composite-keys/5430/1 "2022-06-30T21:27:34Z")

</div>

I’m trying to create a stream with a composite key following the answer from @rmoff in [apache kafka connect - How to create KSQL table from a topic with composite key? - Stack Overflow](https://stackoverflow.com/a/59663082), however, like another recent commenter, I’m running into “`MY_COMPOSITE_KEY must be a column in the source schema since PARTITION BY is applied on the input.`”

Any suggestions? I can duplicate all the details here if it will help.

As further background, the whole reason I’m trying to do this to deal with the issue that we can’t join on more than one column, as described here by @vxia : [KSQLDB: JOINs on multiple conditions are not yet supported · Issue #8574 · confluentinc/ksql · GitHub](https://github.com/confluentinc/ksql/issues/8574#issuecomment-1027272025)

Any help is much appreciated?

---

<div class="post-metadata">

**Author:** ![jacob-braze](https://sea1.discourse-cdn.com/flex019/user_avatar/forum.confluent.io/jacob-braze/32/2018_2.png) [@jacob-braze](https://forum.confluent.io/u/jacob-braze)\
**Post date:** [1 July 2022 09:55 UTC](https://forum.confluent.io/t/stream-composite-keys/5430/2 "2022-07-01T09:55:36Z")

</div>

Found a solution:

```auto
CREATE STREAM repartitioned_stream AS
   SELECT * FROM my_stream
   PARTITION BY STRUCT(K1 := <expression 1>, K2 := <expression 2>)
   EMIT CHANGES;

```

See: [Keys Unlocked - ksqlDB 0.15 Supports Even More Data Types](https://www.confluent.io/blog/ksqldb-0-15-reads-more-message-keys-supports-more-data-types/#join-on-sources)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex019/uploads/confluentcommunity/original/1X/c49438c90c9df282e9996fdf6971be890c71b65a.svg) [@system](https://forum.confluent.io/u/system)\
**Post date:** [12 July 2022 15:38 UTC](https://forum.confluent.io/t/stream-composite-keys/5430/3 "2022-07-12T15:38:19Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
