[jira] [Commented] (CASSANDRA-12051) JSON does not take functions
[ 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] [Comment Edited] (CASSANDRA-12051) JSON does not take functions
[ https://issues.apache.org/jira/browse/CASSANDRA-12051?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15365564#comment-15365564 ] Tianshi Wang edited comment on CASSANDRA-12051 at 7/7/16 3:54 AM: -- It actually supports function "now" in JSON format. Just remove the parenthesis. 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} was (Author: postgres): 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] [Created] (CASSANDRA-12051) JSON does not take functions
Tianshi Wang created CASSANDRA-12051: Summary: 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-11513) Result set is not unique on primary key (cql)
[ https://issues.apache.org/jira/browse/CASSANDRA-11513?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15230417#comment-15230417 ] Tianshi Wang commented on CASSANDRA-11513: -- Cassandra community is awesome! Should buy you a beer, Joel. > Result set is not unique on primary key (cql) > -- > > Key: CASSANDRA-11513 > URL: https://issues.apache.org/jira/browse/CASSANDRA-11513 > Project: Cassandra > Issue Type: Bug >Reporter: Tianshi Wang >Assignee: Joel Knighton > > [cqlsh 5.0.1 | Cassandra 3.4 | CQL spec 3.4.0 | Native protocol v4] > Run followings, > {code} > drop table if exists test0; > CREATE TABLE test0 ( > pk int, > a int, > b text, > s text static, > PRIMARY KEY (pk, a) > ); > insert into test0 (pk,a,b,s) values (0,1,'b1','hello b1'); > insert into test0 (pk,a,b,s) values (0,2,'b2','hello b2'); > insert into test0 (pk,a,b,s) values (0,3,'b3','hello b3'); > create index on test0 (b); > insert into test0 (pk,a,b,s) values (0,2,'b2 again','b2 again'); > {code} > Now select one record based on primary key, we got all three records. > {code} > cqlsh:ops> select * from test0 where pk=0 and a=2; > pk | a | s| b > +---+--+-- > 0 | 1 | b2 again | b1 > 0 | 2 | b2 again | b2 again > 0 | 3 | b2 again | b3 > {code} > {code} > cqlsh:ops> desc test0; > CREATE TABLE ops.test0 ( > pk int, > a int, > b text, > s text static, > PRIMARY KEY (pk, a) > ) WITH CLUSTERING ORDER BY (a ASC) > AND bloom_filter_fp_chance = 0.01 > AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} > AND comment = '' > AND compaction = {'class': > 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', > 'max_threshold': '32', 'min_threshold': '4'} > AND compression = {'chunk_length_in_kb': '64', 'class': > 'org.apache.cassandra.io.compress.LZ4Compressor'} > AND crc_check_chance = 1.0 > AND dclocal_read_repair_chance = 0.1 > AND default_time_to_live = 0 > AND gc_grace_seconds = 864000 > AND max_index_interval = 2048 > AND memtable_flush_period_in_ms = 0 > AND min_index_interval = 128 > AND read_repair_chance = 0.0 > AND speculative_retry = '99PERCENTILE'; > CREATE INDEX test0_b_idx ON ops.test0 (b); > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Updated] (CASSANDRA-11513) Result set is not unique on primary key (cql)
[ https://issues.apache.org/jira/browse/CASSANDRA-11513?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Tianshi Wang updated CASSANDRA-11513: - Description: [cqlsh 5.0.1 | Cassandra 3.4 | CQL spec 3.4.0 | Native protocol v4] Run followings, {code} drop table if exists test0; CREATE TABLE test0 ( pk int, a int, b text, s text static, PRIMARY KEY (pk, a) ); insert into test0 (pk,a,b,s) values (0,1,'b1','hello b1'); insert into test0 (pk,a,b,s) values (0,2,'b2','hello b2'); insert into test0 (pk,a,b,s) values (0,3,'b3','hello b3'); create index on test0 (b); insert into test0 (pk,a,b,s) values (0,2,'b2 again','b2 again'); {code} Now select one record based on primary key, we got all three records. {code} cqlsh:ops> select * from test0 where pk=0 and a=2; pk | a | s| b +---+--+-- 0 | 1 | b2 again | b1 0 | 2 | b2 again | b2 again 0 | 3 | b2 again | b3 {code} {code} cqlsh:ops> desc test0; CREATE TABLE ops.test0 ( pk int, a int, b text, s text static, PRIMARY KEY (pk, a) ) WITH CLUSTERING ORDER BY (a ASC) AND bloom_filter_fp_chance = 0.01 AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} AND comment = '' AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} AND crc_check_chance = 1.0 AND dclocal_read_repair_chance = 0.1 AND default_time_to_live = 0 AND gc_grace_seconds = 864000 AND max_index_interval = 2048 AND memtable_flush_period_in_ms = 0 AND min_index_interval = 128 AND read_repair_chance = 0.0 AND speculative_retry = '99PERCENTILE'; CREATE INDEX test0_b_idx ON ops.test0 (b); {code} was: [cqlsh 5.0.1 | Cassandra 3.4 | CQL spec 3.4.0 | Native protocol v4] Run followings, {code} drop table if exists test0; CREATE TABLE test0 ( pk int, a int, b text, s text static, PRIMARY KEY (pk, a) ); insert into test0 (pk,a,b,s) values (0,1,'b1','hello b1'); insert into test0 (pk,a,b,s) values (0,2,'b2','hello b2'); insert into test0 (pk,a,b,s) values (0,3,'b3','hello b3'); create index on test0 (b); insert into test0 (pk,a,b,s) values (0,2,'b2 again','b2 again'); {code} Now select one record based on primary key, we got all three records. {code} cqlsh:ops> select * from test0 where pk=0 and a=2; pk | a | s| b +---+--+-- 0 | 1 | b2 again | b1 0 | 2 | b2 again | b2 again 0 | 3 | b2 again | b3 {code} > Result set is not unique on primary key (cql) > -- > > Key: CASSANDRA-11513 > URL: https://issues.apache.org/jira/browse/CASSANDRA-11513 > Project: Cassandra > Issue Type: Bug >Reporter: Tianshi Wang > > [cqlsh 5.0.1 | Cassandra 3.4 | CQL spec 3.4.0 | Native protocol v4] > Run followings, > {code} > drop table if exists test0; > CREATE TABLE test0 ( > pk int, > a int, > b text, > s text static, > PRIMARY KEY (pk, a) > ); > insert into test0 (pk,a,b,s) values (0,1,'b1','hello b1'); > insert into test0 (pk,a,b,s) values (0,2,'b2','hello b2'); > insert into test0 (pk,a,b,s) values (0,3,'b3','hello b3'); > create index on test0 (b); > insert into test0 (pk,a,b,s) values (0,2,'b2 again','b2 again'); > {code} > Now select one record based on primary key, we got all three records. > {code} > cqlsh:ops> select * from test0 where pk=0 and a=2; > pk | a | s| b > +---+--+-- > 0 | 1 | b2 again | b1 > 0 | 2 | b2 again | b2 again > 0 | 3 | b2 again | b3 > {code} > {code} > cqlsh:ops> desc test0; > CREATE TABLE ops.test0 ( > pk int, > a int, > b text, > s text static, > PRIMARY KEY (pk, a) > ) WITH CLUSTERING ORDER BY (a ASC) > AND bloom_filter_fp_chance = 0.01 > AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} > AND comment = '' > AND compaction = {'class': > 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', > 'max_threshold': '32', 'min_threshold': '4'} > AND compression = {'chunk_length_in_kb': '64', 'class': > 'org.apache.cassandra.io.compress.LZ4Compressor'} > AND crc_check_chance = 1.0 > AND dclocal_read_repair_chance = 0.1 > AND default_time_to_live = 0 > AND gc_grace_seconds = 864000 > AND max_index_interval = 2048 > AND memtable_flush_period_in_ms = 0 > AND min_index_interval = 128 > AND read_repair_chance = 0.0 > AND speculative_retry = '99PERCENTILE'; > CREATE INDEX test0_b_idx ON ops.test0 (b); > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Created] (CASSANDRA-11513) Result set is not unique on primary key (cql)
Tianshi Wang created CASSANDRA-11513: Summary: Result set is not unique on primary key (cql) Key: CASSANDRA-11513 URL: https://issues.apache.org/jira/browse/CASSANDRA-11513 Project: Cassandra Issue Type: Bug Reporter: Tianshi Wang [cqlsh 5.0.1 | Cassandra 3.4 | CQL spec 3.4.0 | Native protocol v4] Run followings, {code} drop table if exists test0; CREATE TABLE test0 ( pk int, a int, b text, s text static, PRIMARY KEY (pk, a) ); insert into test0 (pk,a,b,s) values (0,1,'b1','hello b1'); insert into test0 (pk,a,b,s) values (0,2,'b2','hello b2'); insert into test0 (pk,a,b,s) values (0,3,'b3','hello b3'); create index on test0 (b); insert into test0 (pk,a,b,s) values (0,2,'b2 again','b2 again'); {code} Now select one record based on primary key, we got all three records. {code} cqlsh:ops> select * from test0 where pk=0 and a=2; pk | a | s| b +---+--+-- 0 | 1 | b2 again | b1 0 | 2 | b2 again | b2 again 0 | 3 | b2 again | b3 {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)