You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@cassandra.apache.org by java8964 <ja...@hotmail.com> on 2015/02/26 01:24:55 UTC

Why and How I didn't get the result back in cqlsh

Here is the version of the cqlsh and Cassandra I am using:
yzhang@yzhangmac1:~/dse/bin$ ./cqlsh hostname 9160 -u username -p passwordConnected to P2 QA Cluster at c1-cass01.roving.com:9160.[cqlsh 3.1.2 | Cassandra 1.2.18.1 | CQL spec 3.0.0 | Thrift protocol 19.36.2]Use HELP for help.cqlsh> use mykeyspace;cqlsh: mykeyspace >
cqlsh:automation_d1> describe table "myTable";
CREATE TABLE "myTable" (  key varint,  key2 varint,  column1 bigint,  column2 ascii,  value text,  PRIMARY KEY ((key, key2), column1, column2)) WITH COMPACT STORAGE AND  bloom_filter_fp_chance=0.010000 AND  caching='KEYS_ONLY' AND  comment='' AND  dclocal_read_repair_chance=0.000000 AND  gc_grace_seconds=864000 AND  read_repair_chance=0.100000 AND  replicate_on_write='true' AND  compaction={'class': 'SizeTieredCompactionStrategy'} AND  compression={'sstable_compression': 'SnappyCompressor'};
select * from "myTable";   59 |  336 | 1100390163336 | A |   [{"updated_at":1424844362530,"ids":"668e5520-bb71-11e4-aecd-00163e56be7c"}]  59 |  336 | 1100390163336 | D |   [{"updated_at":1424844365062,"ids":"668e5520-bb71-11e4-aecd-00163e56be7c"}]
Obviously, the table has lots of data. Now the problem is I cannot get any data back in my query using key of existing data. Why?
cqlsh:mykeyspace> select * from "myTable" where key=59 and key2=336;cqlsh:mykeyspace> select * from "myTable" where "key"=59 and "key2"=336;
As you can see, I know key=59 and key2=336 existed, but no matter what I try, I cannot query them out. The last 2 query didn't return the any result to me.
Now I tried the cassandra-cli:
./cassandra-cli -h hostname -u username -pw password[user1@unknown] use mykeyspace;Authenticated to keyspace: mykeyspace[user1@unknown] list myTable......................... lots of data............-------------------RowKey: 51:855=> (name=1100393052855:D, value=[{"updated_at":1424269592866,"id":"fc31b6d0-5479-11e4-8a79-00163e56be7c"}], timestamp=1424269592866000, ttl=2764800)-------------------RowKey: 59:336=> (name=1100390163336:A, value=[{"updated_at":1424844362530,"id":"668e5520-bb71-11e4-aecd-00163e56be7c"}], timestamp=1424844362533000, ttl=2764800)=> (name=1100390163336:D, value=[{"updated_at":1424844365062,"id":"668e5520-bb71-11e4-aecd-00163e56be7c"}], timestamp=1424844365063000, ttl=2764800)
[default@mykeyspace] get myTable['59:336'];Returned 0 results.Elapsed time: 62 msec(s).
Why I cannot get the data by key, in neither cqlsh nor cassandra-cli?
Thanks
Yong
 		 	   		  

RE: Why and How I didn't get the result back in cqlsh

Posted by java8964 <ja...@hotmail.com>.
Hi, Duncan:
Thanks for your reply, but it didn't help.
yzhang@yzhangmac1:~/dse/bin$ ./cqlsh hostname 9160 -u user -p passwordConnected to P2 QA Cluster at xxx:9160.[cqlsh 3.1.2 | Cassandra 1.2.18.1 | CQL spec 3.0.0 | Thrift protocol 19.36.2]Use HELP for help.cqlsh> use myKeyspace;cqlsh:myKeyspace > consistency all;Consistency level set to ALL.cqlsh: myKeyspace> select * from "myTable" where "key"=59 and "key2"=336;cqlsh: myKeyspace > select * from "myTable" where key=59 and key2=336;cqlsh: myKeyspace >
This table in fact was created by old column family way in Cassandra 1.1, using composite key and composite column names.After we upgrade to Cassandra 1.2, you can see the column name in CQL comes from the Cassandra. So this table is NOT created in CQL.
I think it maybe due to the column name "key" is a reserved word. But even I quote it like "key" in the CQL query, it still didn't help.
> Date: Thu, 26 Feb 2015 03:55:04 +0100
> From: duncan.sands@gmail.com
> To: user@cassandra.apache.org
> Subject: Re: Why and How I didn't get the result back in cqlsh
> 
> Hi,
> 
> On 26/02/15 01:24, java8964 wrote:
> ...
> > select * from "myTable";
> >    59 |  336 | 1100390163336 | A |
> > [{"updated_at":1424844362530,"ids":"668e5520-bb71-11e4-aecd-00163e56be7c"}]
> >    59 |  336 | 1100390163336 | D |
> > [{"updated_at":1424844365062,"ids":"668e5520-bb71-11e4-aecd-00163e56be7c"}]
> >
> > Obviously, the table has lots of data. Now the problem is I cannot get any data
> > back in my query using key of existing data. Why?
> >
> > cqlsh:mykeyspace> select * from "myTable" where key=59 and key2=336;
> > cqlsh:mykeyspace> select * from "myTable" where "key"=59 and "key2"=336;
> 
> try at a higher consistency level, eg first do this in cqlsh:
>    CONSISTENCY ALL;
> then try your queries.  If that works then the issue is that some replicas are 
> missing data.  The default cqlsh consistency level is ONE.
> 
> Best wishes, Duncan.
 		 	   		  

Re: Why and How I didn't get the result back in cqlsh

Posted by Duncan Sands <du...@gmail.com>.
Hi,

On 26/02/15 01:24, java8964 wrote:
...
> select * from "myTable";
>    59 |  336 | 1100390163336 | A |
> [{"updated_at":1424844362530,"ids":"668e5520-bb71-11e4-aecd-00163e56be7c"}]
>    59 |  336 | 1100390163336 | D |
> [{"updated_at":1424844365062,"ids":"668e5520-bb71-11e4-aecd-00163e56be7c"}]
>
> Obviously, the table has lots of data. Now the problem is I cannot get any data
> back in my query using key of existing data. Why?
>
> cqlsh:mykeyspace> select * from "myTable" where key=59 and key2=336;
> cqlsh:mykeyspace> select * from "myTable" where "key"=59 and "key2"=336;

try at a higher consistency level, eg first do this in cqlsh:
   CONSISTENCY ALL;
then try your queries.  If that works then the issue is that some replicas are 
missing data.  The default cqlsh consistency level is ONE.

Best wishes, Duncan.