title: How to do Cassandra CQL queries with Astyanax?
body: <p>I'm using Astyanax version 1.56.26 with Cassandra version 1.2.2</p>
  
  <p>Ok, a little situational overview:</p>
  
  <ol>
  <li><p>I have created a very simple column family using cqlsh like so:</p>
  
  <p><code>CREATE TABLE users (
    name text PRIMARY KEY,
    age int,
    weight int
  );</code></p></li>
  <li><p>I populated the column family (no empty columns)</p></li>
  <li><p>Querying <code>users</code> via cqlsh yields expected results</p></li>
  <li><p>Now I want to programmatically query <code>users</code>, so I try something like:</p></li>
  </ol>
  
  <pre><code>ColumnFamily&lt;String, String> users =  
    new ColumnFamily&lt;String, String>("users", StringSerializer.get(), StringSerializer.get());
  OperationResult&lt;ColumnList&lt;String>> result = ks.prepareQuery(users)
    .getRow("bobbydigital") // valid rowkey
    .execute();
  ColumnList&lt;String> columns = result.getResult();
  int weight = columns.getColumnByName("weight").getIntegerValue();
  </code></pre>
  
  <ol>
  <li>During the assignment of <code>weight</code> a NPE is thrown! :(</li>
  </ol>
  
  <p>My understanding is that the <code>result</code> should have contained all the columns associated with the row containing <code>"bobbydigital"</code> as its row key. I then tried to assign the value in the column named <code>"weight"</code> to the integer variable <code>weight</code>. I know that the variable <code>columns</code> is getting assigned because when I add some debug code right after the assignment, like so:  </p>
  
  <pre><code>System.out.println("Column names = " + columns.getColumnNames());
  </code></pre>
  
  <p>I get the following output:</p>
  
  <p><code>Column names = [, age, weight]</code></p>
  
  <p>So why the null pointer? Can someone tell me where I went wrong? Also, why is there blank column name?</p>
  
  <p>UPDATE:<br>
  Also if I try querying in a different manner, like so:</p>
  
  <pre><code>Column&lt;String> result = ks.prepareQuery(users)
    .getKey("bobbydigital")
    .getColumn("weight")
    .execute().getResult();
  int x = result.getIntegerValue();
  </code></pre>
  
  <p>I get the following exception:<br>
  <code>InvalidRequestException(why:Not enough bytes to read value of component 0)</code></p>
  
  <p>Thanks in advance for any help you can provide!</p>