Skip to content
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

Datatype Mismatch. Cannot cast builtin call return type 'bigint' to expected type 'timestamp' #579

Open
kmuthukk opened this issue Nov 12, 2018 · 1 comment
Assignees
Labels
area/ycql Yugabyte CQL (YCQL) kind/bug This issue is a bug priority/medium Medium priority issue
Projects

Comments

@kmuthukk
Copy link
Collaborator

kmuthukk commented Nov 12, 2018

Jira Link: DB-4715
Seeing this error on toUnixTimestamp(now()) -> timestamp conversion.

9:47 $ ~/yugabyte-1.1.0.5/bin/cqlsh
Connected to local cluster at 127.0.0.1:9042.
[cqlsh 5.0.1 | Cassandra 3.9-SNAPSHOT | CQL spec 3.4.2 | Native protocol v4]
Use HELP for help.
cqlsh> create keyspace k;
cqlsh> use k;
cqlsh:k> CREATE TABLE sample_times (a int, b timestamp, c timeuuid, d bigint, PRIMARY KEY (a,b,c,d));
cqlsh:k> INSERT INTO sample_times (a,b,c,d) VALUES (1, toUnixTimestamp(now()), 50554d6e-29bb-11e5-b345-feff819cdc9f, toTimestamp(now()));
InvalidRequest: Error from server: code=2200 [Invalid query] message="SQL error: Datatype Mismatch. Cannot cast builtin call return type 'bigint' to expected type 'timestamp'
INSERT INTO sample_times (a,b,c,d) VALUES (1, toUnixTimestamp(now()), 50554d6e-29bb-11e5-b345-feff819cdc9f, toTimestamp(now()));
                                              ^^^^^^^^^^^^^^^
 (error -201)"
@kmuthukk kmuthukk added the kind/bug This issue is a bug label Nov 12, 2018
@kmuthukk kmuthukk added this to To Do in YCQL via automation Nov 12, 2018
@kmuthukk
Copy link
Collaborator Author

kmuthukk commented Nov 12, 2018

The example above is from:

https://docs.datastax.com/en/cql/3.3/cql/cql_reference/timeuuid_functions_r.html

But it seems like the expressions for "b" & "d" columns in the doc is flipped.

The workaround would be:

cqlsh:k> INSERT INTO sample_times (a,b,c,d) VALUES (1, toTimestamp(now()), 50554d6e-29bb-11e5-b345-feff819cdc9f, toUnixTimestamp(now()));
cqlsh:k> select * from sample_times;

 a | b                               | c                                    | d
---+---------------------------------+--------------------------------------+---------------
 1 | 2018-11-12 20:15:44.504000+0000 | 50554d6e-29bb-11e5-b345-feff819cdc9f | 1542053744505

But looks like Apache Cassandra supports implicit conversions that YCQL isn't.

@rthallamko3 rthallamko3 added the area/ycql Yugabyte CQL (YCQL) label Dec 29, 2022
@yugabyte-ci yugabyte-ci added the priority/medium Medium priority issue label Dec 29, 2022
@yugabyte-ci yugabyte-ci assigned suranjan and unassigned robertpang and nocaway Jan 19, 2023
@yugabyte-ci yugabyte-ci added status/awaiting-triage Issue awaiting triage and removed status/awaiting-triage Issue awaiting triage labels Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ycql Yugabyte CQL (YCQL) kind/bug This issue is a bug priority/medium Medium priority issue
Projects
YCQL
  
To Do
Status: No status
Development

No branches or pull requests

6 participants