title: Cassandra: Searching for NULL values
body: <p>I have a table MACRecord in Cassandra as follows :</p>
  
  <pre><code>CREATE TABLE has.macrecord (
      macadd text PRIMARY KEY,
      position int,
      record int,
      rssi1 float,
      rssi2 float,
      rssi3 float,
      rssi4 float,
      rssi5 float,
      timestamp timestamp
  )
  </code></pre>
  
  <p>I have 5 different nodes each updating a row based on its title i-e node 1 just updates rssi1, node 2 just updates rssi2 etc. This evidently creates null values for other columns.</p>
  
  <p>I cannot seem to be able to a find a query which will give me only those rows which are not null. Specifically i have referred to this <a href="https://stackoverflow.com/questions/24456188/select-in-cassandra-where-id-null">post</a>.</p>
  
  <p>I want to be able to query for example like <code>SELECT *FROM MACRecord where RSSI1 != NULL</code> as in MYSQL. However it seems both null values and comparison operators such as != are not supported in CQL. </p>
  
  <p>Is there an alternative to putting NULL values or a special flag?. I am inserting float so unlike strings i cannot insert something like ''. What is a possible workaround for this problem?</p>
  
  <p>Edit :</p>
  
  <p>My data model in MYSQL was like this :</p>
  
  <pre><code>+-----------+--------------+------+-----+-------------------+-----------------------------+
  | Field     | Type         | Null | Key | Default           | Extra                       |
  +-----------+--------------+------+-----+-------------------+-----------------------------+
  | MACAdd    | varchar(17)  | YES  | UNI | NULL              |                             |
  | Timestamp | timestamp    | NO   |     | CURRENT_TIMESTAMP | on update CURRENT_TIMESTAMP |
  | Record    | smallint(6)  | YES  |     | NULL              |                             |
  | RSSI1     | decimal(5,2) | YES  |     | NULL              |                             |
  | RSSI2     | decimal(5,2) | YES  |     | NULL              |                             |
  | RSSI3     | decimal(5,2) | YES  |     | NULL              |                             |
  | RSSI4     | decimal(5,2) | YES  |     | NULL              |                             |
  | RSSI5     | decimal(5,2) | YES  |     | NULL              |                             |
  | Position  | smallint(6)  | YES  |     | NULL              |                             |
  +-----------+--------------+------+-----+-------------------+-----------------------------+
  </code></pre>
  
  <p>Each node (1-5) was  querying from MYSQL based on its number for example node 1  <code>"SELECT *FROM MACRecord WHERE RSSI1 is not NULL"</code></p>
  
  <p>I updated my data model in cassandra as follows so that rssi1-rssi5 are now VARCHAR types.</p>
  
  <pre><code>CREATE TABLE has.macrecord (
      macadd text PRIMARY KEY,
      position int,
      record int,
      rssi1 text,
      rssi2 text,
      rssi3 text,
      rssi4 text,
      rssi5 text,
      timestamp timestamp
  )
  </code></pre>
  
  <p>I was thinking that each node would initially insert string 'NULL' for a record and when an actual rssi data comes it will just replace the 'NULL' string so it would avoid having tombstones and would more or less appear to the user that the values are actually not valid pieces of data since they are flagged 'NULL'.</p>
  
  <p>However i am still puzzled as to how i will retrieve results like i have done in MYSQL. There is no != operator in cassandra. How can i write a query which will give me a result set for example like "SELECT *FROM HAS.MACRecord where RSSI1 != 'NULL'" . </p>