Search code examples
apache-kafkaksqldb

How to set [ignoreNulls] in KSQLDB aggregate functions to not ignore nulls


I try to get the latest value of a Message via KSQLDB. Therefor I use LATEST_BY_OFFSET.

In the Documentation it is described as follows:

Since: 0.13.0

EARLIEST_BY_OFFSET(col1, earliestN, [ignoreNulls])

Stream Return the earliest N values for the specified column as an ARRAY. The earliest valuesin the partition have the lowest offsets. The optional ignoreNulls parameter controls whether nulls are ignored. The default is to ignore null values.

How do i set it to NOT ignore the Nulls. I tried 0/1, true/false


Solution

  • I was not sure which version of ksqlDB im using. So I found that Confluent Platform uses version 0.10 (https://docs.confluent.io/platform/current/installation/versions-interoperability.html)

    Therefore this command cannot work.

    But i find it quite easy to misread the documentation because of this paragraph:

    Since: 0.10.0
    
    EARLIEST_BY_OFFSET(col1, [ignoreNulls])
    Stream
    
    Return the earliest value for the specified column. The earliest value in the partition
    
    has the lowest offset.
    
    The optional ignoreNulls parameter, available since version 0.13.0, controls whether nulls are ignored. The default
    
    is to ignore null values.
    

    So they write "Since 0.10.0", add the ignoreNulls-parameter and say that ignoreNulls can only be used by version 0.13.