Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-7653

Streams-Scala: Add type level differentiation for Key and Value serdes.

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • streams

    Description

      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.

      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")
      

      It would be ideal if Key and Value Serde/SerdeWrapper types/type classes could be introduced to overcome this limitation.

      KIP-513: https://cwiki.apache.org/confluence/display/KAFKA/KIP-513%3A+Distinguish+between+Key+and+Value+serdes+in+scala+wrapper+library+for+kafka+streams

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mark.tranter Mark Tranter
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated: