title: Cassandra Trigger
body: <p>I am new to Cassandra and use Cassandra 3.10 and have table like</p>
  
  <pre><code>create table db1.table1 (id text, trip_id text, event_time timestamp, mileage double, primary key(id, event_time));
  create table db1.table2 (id text, trip_id text, start_time timestamp, mileage double, primary key(id, start_time));
  </code></pre>
  
  <p>I need to transfer data from table1 to table2 aggregated by trip_id and sum  on mileage and update data in table2</p>
  
  <p>I have written a trigger function to get column name and value</p>
  
  <pre><code>public Collection&lt;Mutation&gt; augment(Partition partition) {
      HashMap map = new HashMap();
      CFMetaData cfm = partition.metadata();
      String tableName = cfm.cfName;
      try {
          UnfilteredRowIterator it = partition.unfilteredIterator();
          while (it.hasNext()) {
              Unfiltered un = it.next();
              Clustering clt = (Clustering) un.clustering();
              Iterator&lt;Cell&gt; cells = partition.getRow(clt).cells().iterator();              
              while(cells.hasNext()){
                  Cell cell = cells.next();
                  map.put(cell.column().name.toString(), cell.value().array());
                  ...
              }
          }
      } catch (Exception e) {
  
      }
  
  
      ...
  }
  </code></pre>
  
  <p>But how can I get Primary key and the value of Primary key? If those are not gettable, how can I use trigger function to do the job?</p>