Skip to content

Implement Postgres compatible now() function #251

@alamb

Description

@alamb

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
I want to write queries that have predicates on relative timeranges like "the last 1 hour" or "the last 2 days"

Describe the solution you'd like
I would like a new function now() that takes no arguments and returns a DataType::Timestamp(TimeUnit::Nanoseconds, NULL) of the current timestamp

It should follow the postgres semantics described in https://www.postgresql.org/docs/current/functions-datetime.html

now ( ) → timestamp with time zone
Current date and time (start of current transaction); see Section 9.9.4

Bonus points for adding SQL standard functions https://www.postgresql.org/docs/current/functions-datetime.html#FUNCTIONS-DATETIME-CURRENT such as CURRENT_TIME and CURRENT_TIMESTAMP.

Describe alternatives you've considered
N/A

Additional context
I imagine this is largely an exercise in creating a new built in function now() and calling chrono::Utc::now() to get the current time:

https://docs.rs/chrono/0.4.19/chrono/offset/struct.Utc.html#method.now

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions