[ https://issues.apache.org/jira/browse/CASSANDRA-20827?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18014055#comment-18014055 ]
Stefan Miklosovic commented on CASSANDRA-20827: ----------------------------------------------- I am not completely sure I understand this. There is already JSON you can use like this: {code} cassandra@cqlsh> CREATE TYPE ks.mytype (id int, val map<int, text>); cassandra@cqlsh> CREATE TABLE ks.tb3 (id int, values frozen<mytype>, primary key (id)); cassandra@cqlsh> INSERT INTO ks.tb3 (id, values ) VALUES ( 1, {id: 5, val: {1: 'hello', 2: 'world'}}); cassandra@cqlsh> select * from ks.tb3; id | values ----+---------------------------------------- 1 | {id: 5, val: {1: 'hello', 2: 'world'}} (1 rows) cassandra@cqlsh> select json * from ks.tb3; [json] --------------------------------------------------------------------- {"id": 1, "values": {"id": 5, "val": {"1": "hello", "2": "world"}}} (1 rows) {code} What we have in system_views.settings is _string representation of the value_. So, I think that what you see is the result of HashMap.toString, basically. Hence, the method you want to introduce, collection2json, is not _converting collections to json_, because it is not _collection_, it is String, it was just produced by HashMap.toString. It would be more suitable if we introduced CQL _type_ which would be JSON. This is not done yet. There was some discussions about that. BTW we do have a constraint called JSON: {code} cassandra@cqlsh> CREATE TABLE ks.tb4 (id int, values text CHECK JSON, primary key (id)); cassandra@cqlsh> INSERT INTO ks.tb4 (id , values ) VALUES ( 1, '{"this": {"is": "a json"}}'); cassandra@cqlsh> INSERT INTO ks.tb4 (id , values ) VALUES ( 1, 'this is not'); InvalidRequest: Error from server: code=2200 [Invalid query] message="Value for column 'values' violated JSON constraint as it is not a valid JSON." cassandra@cqlsh> select * FROM ks.tb4; id | values ----+---------------------------- 1 | {"this": {"is": "a json"}} (1 rows) {code} So I think that while {{value}} column would be still technically _text_, we might in theory put a JSON constraint on it. It means that every value in there would look like JSON and it would be the responsibility of whoever is populating that table that whatever text inserted would be a valid JSON. > Represent complex settings as JSON on system_views.settings table > ----------------------------------------------------------------- > > Key: CASSANDRA-20827 > URL: https://issues.apache.org/jira/browse/CASSANDRA-20827 > Project: Apache Cassandra > Issue Type: Improvement > Components: Local/Config > Reporter: Paulo Motta > Assignee: Marko Tsymbaliuk > Priority: Normal > Time Spent: 40m > Remaining Estimate: 0h > > Complex configuration (maps/sets/lists) are represented as > Collections.toString() on {{system.settings}} virtual table: > {code:java} > cqlsh> select * from system_views.settings where name='seed_provider' ; > name | value > ------+------- > (0 rows) > cqlsh> select * from system_views.settings where > name='seed_provider.parameters' ; > name | value > --------------------------+------------------------ > seed_provider.parameters | {seeds=127.0.0.1:7000} > {code} > While this is fine for human consumption, it's not ideal for programmatic > access, since it requires custom parsing. > This ticket is to add ability of representing complex types as JSON on > {{system.settings}} and potentially making it default in trunk, so the above > would return: > {code:java} > cqlsh> select * from system_views.settings where name='seed_provider' ; > name | value > ------+------- > (0 rows) > cqlsh> select * from system_views.settings where > name='seed_provider.parameters' ; > name | value > --------------------------+------------------------ > seed_provider.parameters | {"seeds": "127.0.0.1:7000"}{code} -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org