Skip to content

Add parse_ulid_timestamp() function#1

Open
rcoup wants to merge 2 commits intogeckoboard:masterfrom
rcoup:parse
Open

Add parse_ulid_timestamp() function#1
rcoup wants to merge 2 commits intogeckoboard:masterfrom
rcoup:parse

Conversation

@rcoup
Copy link
Copy Markdown

@rcoup rcoup commented Jan 8, 2020

Extracts the timestamp from a generated ULID

eg:

postgres=# select now(), parse_ulid_timestamp(generate_ulid());
              now              |     parse_ulid_timestamp
-------------------------------+----------------------------
 2020-01-08 14:04:43.441019+00 | 2020-01-08 14:04:43.441+00
(1 row)

@leocassarani
Copy link
Copy Markdown
Member

Hi @rcoup, thanks for your contribution.

This is not a use case that we've ever come across and we were curious to hear what you were hoping to achieve with this function. The way we use ULIDs is as opaque identifiers and we've never expected to be able to retrieve the timestamp portion from an existing ULID.

Look forward to hearing from you.

@rcoup
Copy link
Copy Markdown
Author

rcoup commented Feb 3, 2020

Used it for tracing & debugging: grabbing chunks of records associated with a time range or figuring out when a record appeared, in situations where for whatever reason there aren't associated timestamp fields.

Most of the language ULID implementations (Python, Go, etc) seem to have parse methods.

@pksunkara
Copy link
Copy Markdown

@rcoup FWIW, pgx_ulid supports casting to timestamp. I needed this feature for generating creation timestamps from id.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants