-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
builtins: implement to_timestamp #77591
Comments
Hello, I am Blathers. I am here to help you get the issue triaged. Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here. I was unable to automatically find someone to ping. If we have not gotten back to your issue within a few business days, you can try the following:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan. |
thanks! i think our preference here is to implement |
Hi, can I pick this up? |
@deepto98 sure, it's best if you go ahead and submit a PR as per the instructions in the issue, and following our contribution guidelines |
82523: builtins: implement to_timestamp for Unix epoch r=otan a=nnaka2992 fixes #77591 Previously, CockroachDB did not support to_timestamp(double precision) In PostgreSQL, the function also handles INT, DECIMAL and text by casting, so the commit also implements those for compatibility. Release note (sql change): Add new function to_timestamp which converts Unix epoch of FLOAT, INT, DECIMAL and text to Timestamp with time zone. Co-authored-by: nnaka2992 <nnaka2992@gmail.com>
Just curious, when will this be released? |
@simplenotezy This will be a part of the v22.2 release. There are beta versions available for you to test with: https://www.cockroachlabs.com/docs/releases/v22.2.html |
Describe the problem
To use a timestamp value in decimal, in Postgres, I use the
to_timestamp()
function as followsSince cockroach doesn't have
to_timestamp()
, I use a cast instead:But it results in
SQL Error [42846]: ERROR: invalid cast: decimal -> timestamptz
Casting an integer to timestamptz works, thought it loses precision:
Environment:
Instructions for contributors:
Add a built-in in https://github.com/cockroachdb/cockroach/blob/master/pkg/sql/sem/builtins/builtins.go
Add a test in https://github.com/cockroachdb/cockroach/blob/master/pkg/sql/logictest/testdata/logic_test/timestamp, and run make testbaselogic FILES='timestamp' TESTFLAGS='-rewrite' to test it.
Run make buildshort to regenerate automatically generated files.
Submit a PR.
Jira issue: CRDB-13671
Epic CRDB-14049
The text was updated successfully, but these errors were encountered: