cloudevents / spec

CloudEvents Specification
https://cloudevents.io
Apache License 2.0
5.01k stars 580 forks source link

Support timestamp and time functions on SQL fliters #844

Open evankanderson opened 3 years ago

evankanderson commented 3 years ago

Had a conversation today with a user who wanted to be able to apply a filter like the following:

SELECT * WHERE time < NOW() - "5 minutes"

It would be handy to have a timestamp type and a handful of time-related functions. Off the top of my head:

erikerikson commented 3 years ago

Perhaps abbreviations to SI standards will reduce i18n?

evankanderson commented 3 years ago

I'd probably lean towards whatever is in the SQL-99 standard (or later equivalent); I picked those out of a SQL manpage, but this book seems to be freely available and cover the standard itself.

evankanderson commented 3 years ago

It looks like the proper SQL way to write the first clause would be:

SELECT * WHERE time < CURRENT_TIMESTAMP() - INTERVAL '5' MINUTE
erikerikson commented 3 years ago

That makes complete sense and I feel a little foolish in hindsight. Thank you for helping remind me of context! 😄

duglin commented 3 years ago

INTERVAL '5' MINUTE is an interesting syntax. Seems like a reasonable thing to do. Someone want to submit a PR?

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 30 days with no activity. Mark as fresh by updating e.g., adding the comment /remove-lifecycle stale.

duglin commented 5 months ago

@evankanderson or perhaps @Cali0707 - does Knative need/want this? Perhaps a PR??

Cali0707 commented 5 months ago

@duglin I can definitely see where this would be useful for Knative, I can work on thinking this through more and opening a PR but I won't get it done in time for the call this week - hopefully next week! Would you be able to assign this to me?

duglin commented 5 months ago

done and thanks