Not sure if this is entirely kosher, but it works and the repartition topic is created automatically and with the right number of partitions wrt the stream
.
KTable emptyTable = someTable.filter((k, v) -> false);
KStream stream = ...
KStream repartionedStream = stream.selectKey(...)
.leftJoin(emptyTable, (v, Null) -> v, ...);
Edit
Please use with caution! This approach apparently became a complicated abomination deserving of an avalanche of downvotes and a flogging in Aug 2020 when Kafka Streams 2.6.0 was introduced and KStream.repartition() came into existence.
So for streams version 2.6+ you must use
KStream stream = ...
KStream repartionedStream = stream.selectKey(...)
.repartition();