[ https://issues.apache.org/jira/browse/KAFKA-7653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16701345#comment-16701345 ]
Guozhang Wang commented on KAFKA-7653: -------------------------------------- I think [~mark.tranter] is trying to provide a work-around if we cannot auto configure the same serde class' instance with key turned on / off. If that is possible, then I feel providing two instances of a single class of serde whose which will be configured differently for key and value would be ideal; if this cannot be achieved, then we need to consider using two classes, and passing in the instance of each class respectively for key and value. Note that https://issues.apache.org/jira/browse/KAFKA-3729 was filed before we have KIP-182; now with key / value serdes wrapped in Produced / Consumed / Grouped etc, we know exactly which serde is used for key / value, and hence should be able to auto-configure them accordingly inside the constructor of those control objects. Then with that this ticket should be easy to resolve, does that make sense? > Streams-Scala: Add type level differentiation for Key and Value serdes. > ----------------------------------------------------------------------- > > Key: KAFKA-7653 > URL: https://issues.apache.org/jira/browse/KAFKA-7653 > Project: Kafka > Issue Type: Improvement > Components: streams > Reporter: Mark Tranter > Assignee: Mark Tranter > Priority: Minor > Labels: scala > > Implicit resolution/conversion of Serdes/Consumed etc is a big improvement > for the Scala Streams API. However in cases where a user needs to > differentiate between Key and Value serializer functionality (i.e. using the > Schema Registry), implicit resolution doesn't help and could cause issues. > e.g. > {code:java} > case class MouseClickEvent(pageId: Long, userId: String) > builder > // Long serde taken from implicit scope configured with > // `isKey` = true > .stream[Long, MouseClickEvent]("mouse-clicks") > .selectKey((_,v) => v.userId) > .groupByKey > .aggregate(() => 0L, (_: String, mce: MouseClickEvent, count: Long) => > count + 1) > .toStream > // Same Long serde taken from implicit scope configured with > // `isKey` = true, even thought the `Long` value in this case > // will be the Value > .to("mouse-clicks-by-user") > {code} > It would be ideal if Key and Value Serde/SerdeWrapper types/type classes > could be introduced to overcome this limitation. -- This message was sent by Atlassian JIRA (v7.6.3#76005)