[ https://issues.apache.org/jira/browse/KAFKA-7653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16693645#comment-16693645 ]
Michael Noll commented on KAFKA-7653: ------------------------------------- Ack, [~mark.tranter]! {quote}Something Like KeySerde[T] and ValueSerde[T] and updating the Kafka Scala Streams code to accept these as implicit dependencies in place of Serde[T].{quote} Yeah, this seems certainly like a possible option -- it was also the first one that came to my mind, for what it's worth. The Scala type system has probably a few more options we could evaluate here. Perhaps there is a way we could introduce types for this in a way that (1) is easier in terms of backwards compatibility and, orthogonal, (2) also convenient to use as well as easy to understand for Scala users that are not experts of Scala's type system, e.g. when writing your own custom serde with the Scala API. {quote}I'm more than happy to help out with a fix for this if we can decide on an appropriate abstraction to use.{quote} That would be great, Mark. Let's continue the conversation here, cc [~guozhang]. > 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 > Priority: Minor > > 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)