title: NullPointerException exception when using Flink's leftOuterJoinLateral in Scala
body: <p>I am trying to follow <a href="https://ci.apache.org/projects/flink/flink-docs-release-1.9/dev/table/udfs.html#table-functions" rel="nofollow noreferrer">the documentation</a> and create a Table Function to &quot;flatten&quot; some data. The Table Function seems to work fine when using the <code>joinLateral</code> to do the flattening. When using <code>leftOuterJoinLateral</code> though, I get the following error. I'm using Scala and have tried both Table API and SQL with the same result:</p>
  <blockquote>
  <p>Caused by: java.lang.NullPointerException: Null result cannot be stored in a Case Class.</p>
  </blockquote>
  <p>Here is my job:</p>
  <pre class="lang-scala prettyprint-override"><code>import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
  import org.apache.flink.table.api.scala.StreamTableEnvironment
  import org.apache.flink.table.api.scala._
  import org.apache.flink.streaming.api.scala._
  import org.apache.flink.table.functions.TableFunction
  
  object example_job{
    // Split the List[Int] into multiple rows
    class Split() extends TableFunction[Int] {
      def eval(nums: List[Int]): Unit = {
        nums.foreach(x =&gt;
          if(x != 3) {
            collect(x)
        })
      }
    }
  
    def main(args: Array[String]): Unit = {
      val env = StreamExecutionEnvironment.createLocalEnvironment()
      val tableEnv = StreamTableEnvironment.create(env)
      val splitMe = new Split()
  
      // Create some dummy data
      val events: DataStream[(String, List[Int])] = env.fromElements((&quot;simon&quot;, List(1,2,3)), (&quot;jessica&quot;, List(3)))
      
      val table = tableEnv.fromDataStream(events, 'name, 'numbers)
        .leftOuterJoinLateral(splitMe('numbers) as 'number)
        .select('name, 'number)
      table.toAppendStream[(String, Int)].print()
      env.execute(&quot;Flink jira ticket example&quot;)
    }
  }
  </code></pre>
  <p>When I change <code>.leftOuterJoinLateral</code> to <code>.joinLateral</code> I get the expected result:</p>
  <pre class="lang-scala prettyprint-override"><code>(simon,1)
  (simon,2)
  </code></pre>
  <p>When using the <code>.leftOuterJoinLateral</code> I would expect something like:</p>
  <pre class="lang-scala prettyprint-override"><code>(simon,1)
  (simon,2)
  (simon,null) // or (simon, None)
  (jessica,null) // or (jessica, None)
  </code></pre>
  <p>Seems like this might be a bug with the Scala API? I wanted to check here first before raising a ticket just in case I'm doing something stupid!</p>