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

2016-07-07 Thread Tyler Hobbs (JIRA)

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

Tyler Hobbs commented on CASSANDRA-12051:
-

Ah, good point.  I forgot that we accepted the string literal {{now}} for 
timestamp values.  This isn't technically a function call (in CQL terms), so 
other function names will not work.

> 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+
> (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)


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

2016-07-06 Thread Tianshi Wang (JIRA)

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

Tianshi Wang commented on CASSANDRA-12051:
--

It actually supports function now in JSON format.
For anyone who want to insert a current timestamp by JSON format, here is the 
query:

{code}
The ts column should be timestamp.
insert into test JSON '{"id":2,"ts":"now"}';
{code} 



> 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+
> (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)


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

2016-07-06 Thread Tyler Hobbs (JIRA)

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

Tyler Hobbs commented on CASSANDRA-12051:
-

I'll also note that you can use a normal insert with the {{fromJson()}} 
function on JSON fields and use functions for other columns.  For example:

{noformat}
INSERT INTO mytable (id, ts) VALUES (fromJson(?), toTimestamp(now()));
{noformat} 

> 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+
> (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)