-
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
sql: Add Data Type Formatting Functions #3781
Comments
PG also has the concept of a pair of I/O Functions for each datatype, one function to parse and one to format. The pg_type table names that pair of I/O functions, as well as a pair of binary send/receive functions. Ultimately, there are any number of format/parse or serialize/deserialize function pairs. For example, encoding of datum values for storage in the KV store (like the decimal type.) |
|
I think I'll give it a try |
@mjibson could you prioritize this issue? |
I came across the unavailability of postgres' Is there a statement which replaces select to_timestamp(1586233649);
select to_timestamp('1586233649'); |
Just ran into this as well. Shame that #7976 and #9018 were abandoned (4 years ago?). The needed function in my case was I worked around it by using As well, neither of |
CockroachDB does support int->timestamp cast, though it is an experimental feature. See https://www.cockroachlabs.com/docs/stable/int.html#supported-casting-and-conversion (Postgres does not support this, so it doesn't address the question of finding something that works for both DBs.) |
I was trying to get a cockroach based backend working with Apache Superset (a very popular visualization framework). But it fails to work on CockroachDB because to_timestamp() has not yet been implemented. It would be nice if this issue is addressed. |
Add |
The select to_char("users"."created_at" - interval '4 HOUR', 'YYYY-MM-DD') as date_result, count("users"."id") as aggregate from "users" where "users"."created_at" between 2021-06-22 00:00:00 and 2021-06-28 19:56:46 group by to_char("users"."created_at" - interval '4 HOUR', 'YYYY-MM-DD') order by "date_result" asc) Implementing the time functions will definitely improve the compatibility with PostgreSQL, and make adoption easier |
@bangeneticalgorithms Superset 1.0 works fine with CockroachDB. After Upgrading to v1.2 following issue appears: apache/superset#15825 |
any news ? |
to_timestamp was developed: #82523 |
I think https://www.cockroachlabs.com/docs/stable/functions-and-operators.html#date-and-time-functions |
the one org version works, yes.
|
Update: |
102787: builtins: implement to_char(date, string) r=rafiss a=otan Release note (sql change): Introduce the `to_char(date, format)` builtin variant, which converts a given date to a string using the given format string. Informs #3781 (if we had implicit casts this wouldnt be an issue!) Co-authored-by: Oliver Tan <otan@cockroachlabs.com>
Eventually we are going to want to add support for converting various data types to formatted strings, and from formatted strings back again. Postgres handles this well and provides a lot of detail on the specifics of its implementation here.
gz#10829
Jira issue: CRDB-6199
The text was updated successfully, but these errors were encountered: