MAX aggregate Function with Varchar

Hi , In my stream I have date field with VARCHAR type , want maximum value of that field , tried with max aggregate function but its returning “No Max aggregate function with STRING argument type exists” , tried using STRINGTOTIMESTAMP as well CAST function with diffrent data types but all are retruning null,
Please suggest.

Can you share a sample of your messages here, and the output of your attempts with STRINGTOTIMESTAMP?

Hi @tchopra501 . ksqldb processes an infinite stream of data hence you need to define a window to return the max.

  1. covert varchar to timestamp (long): Use a custom timestamp column - ksqlDB Documentation
  2. and max() it with limit 1. ksqlDB Tutorial: How to find the min/max in a stream of events using ksqlDB

HTH.
Thanks,
Rankesh

1 Like