Skip to content

feat: Support conversion of Unix timestamps in timestamptz#570

Merged
kodiakhq[bot] merged 3 commits intomainfrom
unix-timestamps
Jan 4, 2023
Merged

feat: Support conversion of Unix timestamps in timestamptz#570
kodiakhq[bot] merged 3 commits intomainfrom
unix-timestamps

Conversation

@hermanschaaf
Copy link
Copy Markdown
Contributor

This adds support for Unix timestamps to the Timestamptz type. I think it's reasonable to expect that an integer type is to be interpreted as unix time, and a custom resolver should be used if this is not the case.

@disq
Copy link
Copy Markdown
Member

disq commented Jan 4, 2023

What about UnixMillis? How can you be sure the given timestamp is unix (ie. seconds)? (Auto-detection might work)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Jan 4, 2023

⏱️ Benchmark results

  • DefaultConcurrency-2 resources/s: 11,768
  • Glob-2 ns/op: 199.9
  • TablesWithChildrenDefaultConcurrency-2 resources/s: 26,350
  • BufferedScanner-2 ns/op: 12.7
  • LogReader-2 ns/op: 37.06

@hermanschaaf
Copy link
Copy Markdown
Contributor Author

What about UnixMillis? How can you be sure the given timestamp is unix (ie. seconds)? (Auto-detection might work)

@disq Yeah, there are many variations (also unix time + milliseconds as float), but I think it's about providing a reasonable default in the SDK (which we can document). If an int field contains something other than Unix seconds, it will need to be converted first, but this should cover most cases without the need for additional code.

As for unix millis specifically, I don't think we can reliably tell which one is which (imagine the time is supposed to represent 1 second after 1 January 1970, for example).

@kodiakhq kodiakhq bot merged commit 6b948ab into main Jan 4, 2023
@kodiakhq kodiakhq bot deleted the unix-timestamps branch January 4, 2023 12:54
kodiakhq bot pushed a commit that referenced this pull request Jan 4, 2023
🤖 I have created a release *beep* *boop*
---


## [1.18.0](v1.17.2...v1.18.0) (2023-01-04)


### Features

* Add Transformer for tables (codegen replacement) ([#564](#564)) ([a643ddf](a643ddf))
* Support conversion of Unix timestamps in timestamptz ([#570](#570)) ([6b948ab](6b948ab))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants