You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by "Sylvain Lebresne (JIRA)" <ji...@apache.org> on 2016/07/06 08:14:11 UTC

[jira] [Resolved] (CASSANDRA-12051) JSON does not take functions

     [ https://issues.apache.org/jira/browse/CASSANDRA-12051?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Sylvain Lebresne resolved CASSANDRA-12051.
------------------------------------------
    Resolution: Won't Fix

I'm afraid we have no plan on supporting this. JSON support is meant as a convenience but we do not want to do anything too complex/esoteric with it. In particular, some things are not and will not be possible with JSON, like function calls, and you should either stick to normal CQL or transform your JSON client side if needed.

More particularly, supporting functions-in-JSON-strings would be pretty messy: we'd have to try to parse every JSON string to see if it looks like function calls, and what if you genuinenly wanted to add a string that happens to look like a function call? This would get messy pretty quickly.

So sorry, but we won't support that.


> JSON does not take functions
> ----------------------------
>
>                 Key: CASSANDRA-12051
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-12051
>             Project: Cassandra
>          Issue Type: Improvement
>            Reporter: Tianshi Wang
>
> toTimestamp(now()) does not work in JSON format.
> {code}
> cqlsh:ops> create table test (
>        ... id int,
>        ... ts timestamp,
>        ... primary key(id)
>        ... );
> cqlsh:ops> insert into test (id, ts) values (1, toTimestamp(now()));
> cqlsh:ops> select * from test;
>  id | ts
> ----+---------------------------------
>   1 | 2016-06-21 18:46:28.753000+0000
> (1 rows)
> cqlsh:ops> insert into test JSON '{"id":2,"ts":toTimestamp(now())}';
> InvalidRequest: code=2200 [Invalid query] message="Could not decode JSON string as a map: org.codehaus.jackson.JsonParseException: Unrecognized token 'toTimestamp': was expecting
>  at [Source: java.io.StringReader@2da0329d; line: 1, column: 25]. (String was: {"id":2,"ts":toTimestamp(now())})"
> cqlsh:ops> insert into test JSON '{"id":2,"ts":"toTimestamp(now())"}';
> InvalidRequest: code=2200 [Invalid query] message="Error decoding JSON value for ts: Unable to coerce 'toTimestamp(now())' to a formatted date (long)"
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)