Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support timestamp and time functions on SQL fliters #844

Open
evankanderson opened this issue Jul 12, 2021 · 9 comments
Open

Support timestamp and time functions on SQL fliters #844

evankanderson opened this issue Jul 12, 2021 · 9 comments
Assignees

Comments

@evankanderson
Copy link
Contributor

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:

  • NOW()
  • ADD / SUBTRACT
  • MINUTE / HOUR / DAY / DAY_OF_WEEK / MONTH / YEAR
  • LESS-THAN / GREATER-THAN
@erikerikson
Copy link
Member

Perhaps abbreviations to SI standards will reduce i18n?

@evankanderson
Copy link
Contributor Author

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
Copy link
Contributor Author

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

SELECT * WHERE time < CURRENT_TIMESTAMP() - INTERVAL '5' MINUTE

@erikerikson
Copy link
Member

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

@duglin
Copy link
Collaborator

duglin commented Jul 21, 2021

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

@github-actions
Copy link

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
Copy link
Collaborator

duglin commented Mar 20, 2024

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

@Cali0707
Copy link
Contributor

@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
Copy link
Collaborator

duglin commented Mar 21, 2024

done and thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants