cassandracql

CQL- Combining two fields in SELECT statement


In my cassandra (columnfamily)table I have a field "message1" and a field "message2". I would like to select all records where message1 + space + message2 is a certain value.

How can I concat or merge two fields(message1+message) into one in select statement as in mysql

  select message1 + ' ' + message2 as WholeMessage 
  from MessageTable  
  where message1 + ' ' + message2 like '%MyWholeMessageString%'

Solution

  • To answer your question: this is not possible in Cassandra at the moment.

    To elaborate, CQL has very limited support for any kind of functions. In fact, the current specification defines only three of them: http://cassandra.apache.org/doc/cql3/CQL.html#functions

    Also, don't expect to do any complex processing and filtering in CQL- referring to your query, there is no operation such as 'like' in CQL.

    I would suggest you retrieve the data in a batch and perform all your processing client-side, or conversely process your data as you need it before inserting into Cassandra. Trying to translate a SQL like logic to CQL will only get you to dead ends.

    Hope this helps.