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

[YCQL] add support for toJSON(), fromJSON() built-ins #992

Closed
kmuthukk opened this issue Mar 14, 2019 · 3 comments
Closed

[YCQL] add support for toJSON(), fromJSON() built-ins #992

kmuthukk opened this issue Mar 14, 2019 · 3 comments
Assignees
Labels
kind/enhancement This is an enhancement of an existing feature

Comments

@kmuthukk
Copy link
Collaborator

Hi, I'm getting the following error when I try to access ybdb cassandra API with Jetbrains DataGrip tool. It is able to connect but not get any data.

SQL error: Invalid Function Call. Failed calling 'tojson(map<text, text>)'. Not found: Function 'tojson' does not exist
SELECT keyspace_name, durable_writes, toJson(replication) as replication
                                      ^^^^^^
FROM system_schema.keyspaces
 (error -214).

Could this be related ?

Originally posted by @hreidar in #778 (comment)

@kmuthukk
Copy link
Collaborator Author

For examples:

See http://cassandra.apache.org/doc/4.0/cql/json.html#the-tojson-function
See https://docs.datastax.com/en/dse/5.1/cql/cql/cql_using/useQueryJSON.html

As reported by @hreidar - the DataGrip tool seems to rely on the toJSON() in the SELECT clause. It would be nice for us to add this support and allow folks to access YCQL via DataGrip.

@kmuthukk kmuthukk changed the title getting the following error when I try to access ybdb cassandra API with Jetbrains DataGrip tool. It is able to connect but not get any data. [YCQL] add support for toJSON(), fromJSON() built-ins Mar 14, 2019
@rkarthik007 rkarthik007 added the kind/enhancement This is an enhancement of an existing feature label Mar 15, 2019
@ndeodhar ndeodhar assigned OlegLoginov and unassigned frozenspider May 30, 2019
@kmuthukk
Copy link
Collaborator Author

kmuthukk commented Jun 13, 2019

Another user reported:

I’ve been trying to use the IntelliJ Cassandra DB Explorer against YB but I’m getting the following error when it tries to read the schema.

SELECT keyspace_name, durable_writes, toJson(replication) as replication
                                      ^^^^^^
FROM system_schema.keyspaces
 (error -214).```
Is this a known issue?

yugabyte-ci pushed a commit that referenced this issue Jul 3, 2019
Summary:
Fix for #992: [YCQL] add support for toJSON(), fromJSON() built-ins
- added function toJson() only (in the current implementation) for all types with exception of UDT & FROZEN.

Test Plan:
ybd  --java-test org.yb.cql.TestSelect#testToJson
ybd  --cxx-test ql-select-expr-test --gtest_filter QLTestSelectedExpr.TestQLSelectToJson
ybd  --cxx-test  bfql-test --gtest_filter BfqlTest.TestBuiltinToJson

Selecting values from the system tables:
CASSANDRA:
```
cqlsh:a> select tojson(replication) from system_schema.keyspaces where keyspace_name='system_auth';
 system.tojson(replication)
-------------------------------------------------------------------------------------
 {"class": "org.apache.cassandra.locator.SimpleStrategy", "replication_factor": "1"}
(1 rows)
```
YUGABYTE:
```
cqlsh:a> select tojson(replication) from system_schema.keyspaces where keyspace_name='system_auth';
 tojson(replication)
----------------------------------------------------------------------------------
 {"class":"org.apache.cassandra.locator.SimpleStrategy","replication_factor":"1"}
(1 rows)
```

EQUAL FORMAT:
```
Types/Values           |           Yugabyte |          Cassandra |
------------------------------------------------------------------
TEXT                   |            "string"|            "string"|
Integer types: TINYINT,|                    |                    |
SMALLINT,INT, BIGINT   |                -123|                -123|
DOUBLE, FLOAT          |              -1.125|              -1.125|
DOUBLE, FLOAT -        |                    |                    |
NaN, Infinity          |                null|                null|
DATE                   |          2018-02-14|          2018-02-14|
TIME                   |  01:02:03.123456789|  01:02:03.123456789|
BLOB                   |          0xdeadbeaf|          0xdeadbeaf|
INET                   |           "1.2.3.4"|           "1.2.3.4"|
VARINT                 |             -123456|             -123456|
DECIMAL                |            -1024.25|            -1024.25|
BOOLEAN                |                true|                true|
UUID                   |"87654321-dead-beaf-|"87654321-dead-beaf-|
                       |  0000-deadbeaf0000"|  0000-deadbeaf0000"|
```
NOT EQUAL FORMAT:
```
Types/Values           |           Yugabyte |          Cassandra |
------------------------------------------------------------------
TIMESTAMP              |2018-02-14T12:24:56.|2018-02-14 12:24:56.|
                       |         987000+0000|                987Z|
MAP                    |       {"1":2,"2":3}|    {"1": 2, "2": 3}|
SET, LIST              |             [4,5,6]|           [4, 5, 6]|
UDT                    |       NOT SUPPORTED|  {"v1": 1, "v2": 2}|
FROZEN<type>           |       NOT SUPPORTED|      same as <type>|
```

Reviewers: neil, alex

Reviewed By: alex

Subscribers: kannan, eng

Differential Revision: https://phabricator.dev.yugabyte.com/D6751
@m-iancu m-iancu added this to YQL-beta Dec 7, 2021
@m-iancu
Copy link
Contributor

m-iancu commented Mar 7, 2022

toJson is done in 541055c. Closing as fromJson is not the roadmap and if added later will be tracked separately.

@m-iancu m-iancu closed this as completed Mar 7, 2022
@m-iancu m-iancu moved this to Done in YQL-beta Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement This is an enhancement of an existing feature
Projects
Status: Done
Development

No branches or pull requests

6 participants