ksql icon indicating copy to clipboard operation
ksql copied to clipboard

Have GETDATE function instead of UNIX_TIMESTAMP to filter or call today's date

Open Scharlotten opened this issue 2 years ago • 2 comments

Most SQL database use the GETDATE function to use for filtering and other purposes to display "today's timestamp". Although ksqldb does offer UNIX_TIMESTAMP as an epoch time for the current date, it is a bit strange to name the function like this also to only be available for epoch time, especially if the user wants to add or subtract dates from it.

Scharlotten avatar Jul 13 '22 16:07 Scharlotten

@colinhicks thoughts on the function name here?

jnh5y avatar Jul 13 '22 16:07 jnh5y

Yeah, I understand the potential confusion with UNIX_TIMESTAMP. This function was introduced before KSQL had a timestamp type. When timestamp and date types were introduced, we also introduced utility functions to convert between them, such that you can do this today:

FROM_UNIXTIME(UNIX_TIMESTAMP())  -- returns TIMESTAMP representing the current timestamp
FROM_DAYS(UNIX_DATE()) -- returns DATE representing the current date

We can consider additional functions to make the above examples a single function call instead of two, but we'd want to think through whether the addition of more date/time-related functions could add to confusion, since there are already quite a few in this vein.

colinhicks avatar Jul 15 '22 15:07 colinhicks