title: KSQLDB coalesce always returns null despite parameters
body: <p>I have the following ksql query:</p>
  <pre><code>SELECT 
    event-&gt;acceptedevent-&gt;id as id1, 
    event-&gt;refundedevent-&gt;id as id2, 
    coalesce(event-&gt;acceptedevent-&gt;id, event-&gt;refundedevent-&gt;id) as coalesce_col 
  FROM events 
  EMIT CHANGES;
  </code></pre>
  <p>Based on the documentation, (<a href="https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/scalar-functions/#coalesce" rel="nofollow noreferrer">https://docs.ksqldb.io/en/latest/developer-guide/ksqldb-reference/scalar-functions/#coalesce</a>) <code>COALESCE</code> returns the first non-null parameter.</p>
  <p>Query returns the following:</p>
  <pre><code>+-----------------------------------------------+-----------------------------------------------+-----------------------------------------------+
  |ID1                                            |ID2                                            |COALESCE_COL                                   |
  +-----------------------------------------------+-----------------------------------------------+-----------------------------------------------+
  |1                                              |null                                           |null                                           |
  |2                                              |null                                           |null                                           |
  |3                                              |null                                           |null                                           |
  </code></pre>
  <p>I was expecting since ID1 is clearly not null, being the first parameter to the call, COALESCE will return same value as ID1 but it returns null. What am I missing?</p>
  <p>I am using <strong>confluentinc/cp-ksqldb-server:6.1.1</strong> and use <strong>avro</strong> for the value serde.</p>
  <p>EventMessage.avsc:</p>
  <pre><code>{
    &quot;type&quot;: &quot;record&quot;,
    &quot;name&quot;: &quot;EventMessage&quot;,
    &quot;namespace&quot;: &quot;com.example.poc.processor2.avro&quot;,
    &quot;fields&quot;: [
      {
        &quot;name&quot;: &quot;event&quot;,
        &quot;type&quot;: [
          &quot;com.example.poc.processor2.avro.AcceptedEvent&quot;,
          &quot;com.example.poc.processor2.avro.RefundedEvent&quot;
        ]
      }
    ]
  }
  </code></pre>