We use Cassandra as a database with most of the tables having schema (and created via CQL), but also some old tables defined via Thrift API, i.e. using COMPACT STORAGE and having quite a number of dynamic columns.
A typical example would be an Accounts
table with a number of tags, flags, etc inserted into a user data.
Code can fetch, decode and manipulate Blob of these dynamic columns easily. E.g. via cassandra-cli you could list some accounts as:
RowKey: bfc4c12b-abcd-defg-90ca-0a56870596e1
=> (name=country, value=US, timestamp=1384489319659000)
=> (name=email, value=someperson@goodserver.org, timestamp=1384489425826000)
=> (name=ourCode, value=12345, timestamp=1384489319550005)
=> (name=flag_ab_notice_twoweeks, value=text, timestamp=1385943698049000)
=> (name=flag_client, value=4d6f7a696c6c612f352e3020286950686f6e653b20435055206950686f6e65204f5320375f305f33206c696b65204d6163204f53205829204170706c655765624b69742f3533372e35312e3120284b48544d4c2c206c696b65204765636b6f29204d6f62696c652f313142353131205468696e674c696e6b2f312e372e312e313233, timestamp=1384489319637000)
=> (name=flag_orgindustry, value=, timestamp=1435153936346000)
=> (name=flag_orgsize, value=736d616c6c, timestamp=1435153936458000)
=> (name=flag_orgtype, value=5363686f6f6c, timestamp=1435153936450000)
=> (name=flag_registeredWith, value=email, timestamp=1384489319617000)
=> (name=flag_registrationFunnel, value=api, timestamp=1384489319601000)
=> (name=flag_statsEmails, value=true, timestamp=1384489322779000)
=> (name=lastTOSApproved, value=0000014259fe7ced, timestamp=1384489319661000)
=> (name=name, value=John, timestamp=1384489425826001)
=> (name=password, value=12345678, timestamp=1384489425826002)
=> (name=primaryId, value=bfc4c12b-abcd-defg-90ca-0a56870596e1, timestamp=1384489319550001)
=> (name=roles, value=user, timestamp=1384489319550002)
=> (name=salt, value=123456789, timestamp=1384489425826003)
When I am looking at the same data via CQL I can see some columns (ones defined with the schema) and cannot see another ones (e.g. column "salt" in my case that was originally created by a Java client using Hector driver and HFactory.createColumn("salt", byteArrayOfAUtf8StringValue)
. Well, cqlsh cannot show dynamic thrift-created column names as told e.g. at https://www.pythian.com/blog/effective-approach-migrate-dynamic-thrift-data-cql-part-2/ , yet a I still can't understand something.
Questions
- How come casandra-cli can show the names of such dynamic sells? Where is the name "salt" stored?
- Why cqlsh cannot use the same source of data to show the cell titles/values (at least in a non-decoded way)?
- Or can I somehow instruct cqlsh to show me a value of a given dynamic cell? Maybe something like `SELECT DECODE_DYNAMIC_COLUMN("salt", "String") FROM "Accoutns" WHERE..."? That would simplify maintenance quite a lot as I wouldn't have to write a Java wrapper every time I need to examine something.
Best regards, Artem.