in cassandra-cli how to get all column names in a table and how to get it
using hector in java?
I'm trying to get column names but could not get way to get only column
names.
In cli I executed command describe table nodes, it returned the result:
CREATE TABLE nodes (
key text PRIMARY KEY,
id text,
scores text,
topic1 text,
topic2 text,
topic3 text,
topic4 text,
topics text
) 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
populate_io_cache_on_flush='false' AND
compaction={'class': 'SizeTieredCompactionStrategy'} AND
compression={'sstable_compression': 'SnappyCompressor'};
CREATE INDEX idx_nodes_id ON nodes (id);
As given in this question, I tries using following command in cli:
SELECT column_name FROM system.schema_columnfamilies WHERE keyspace_name =
'ianew' AND columnfamily_name = 'nodes';
but it gave the error:
Bad Request: Undefined name column_name in selection clause
Perhaps you meant to use CQL 2? Try using the -2 option when starting cqlsh.
As given in this post, I tried using hector in java:
SliceQuery<String, String, String> query =
HFactory.createSliceQuery(keyspace, StringSerializer.get(),
StringSerializer.get(), StringSerializer.get());
query.setColumnFamily(columnFamilyName);
query.setKey("key");
query.setRange(null, null, false, Integer.MAX_VALUE);
ColumnSliceIterator<String, String, String> iterator = new
ColumnSliceIterator<String, String, String>(query, null, "\uFFFF", false);
while (iterator.hasNext()) {
HColumnImpl<String, String> column = (HColumnImpl<String, String>)
iterator.next();
System.out.println("Column name = " + column.getName() + "; Column
value = " + column.getValue());
colNames.add(column.getName());
}
but it returned with no results.
I want output to be something like:
TABLE nodes:
Columns: key text PRIMARY KEY, id text, scores text, topic1 text, topic2
text, topic3 text, topic4 text, topics text
and similar result through Hector.
Versions I'm using:
[cqlsh 2.3.0 | Cassandra 1.2.4 | CQL spec 3.0.0 | Thrift protocol 19.35.0]
No comments:
Post a Comment