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

KTable to KTable join invocation does not resolve in Scala DSL



    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.0
    • Fix Version/s: 2.0.1, 2.1.0
    • Component/s: streams
    • Labels:


      I found a peculiar problem while doing KTable to KTable join using Scala DSL. The following code:


      val t1: KTable[String, Int] = ...
      val t2: KTable[String, Int] = ...
      val result = t1.join(t2)((x: Int, y: Int) => x + y) 


      does not compile with "ambiguous reference to overloaded function". 

      A quick look at the code shows the join functions are defined as follows:


      def join[VO, VR](other: KTable[K, VO])(
       joiner: (V, VO) => VR,
       materialized: Materialized[K, VR, ByteArrayKeyValueStore]
      def join[VO, VR](other: KTable[K, VO])(joiner: (V, VO) => VR)


      the reason it does not compile is the fact that the first parameter list is identical. For some peculiar reason the KTable class actually compiles...

      The same problem exists for KTable to KTable leftJoin. Other joins (stream-stream, stream-table) do not seem to be affected as there are no overloaded versions of the functions.

      This can be reproduced in smaller scale by some simple scala code:


      object F {
       //def x(a: Int): Int = 5
       //def x(a: Int): Int = 6 //obviously does not compile
       def f(x: Int)(y: Int): Int = x
       def f(x: Int)(y: Int, z: Int): Int = x
      val r = F.f(5)(4) //Cannot resolve
      val r2 = F.f(5)(4, 6) //cannot resolve
      val partial = F.f(5) _ //cannot resolve
      /* you get following error:
      Error: ambiguous reference to overloaded definition,
      both method f in object F of type (x: Int)(y: Int, z: Int)Int
      and method f in object F of type (x: Int)(y: Int)Int
      match argument types (Int)


      The solution: get rid of the multiple parameter lists. I fail to see what practical purpose they serve anyways. I am happy to supply appropriate PR if there is agreement.



          Issue Links



              • Assignee:
                joan@goyeau.com Joan Goyeau
                michald Michal
              • Votes:
                0 Vote for this issue
                4 Start watching this issue


                • Created: