4

I'm using the HBase API to access Google Cloud Bigtable, but whenever I try to delete a column:

Delete delete = new Delete(r.getRow());
delete.addColumn(CF, Bytes.toBytes(d.seqid()));
delete.addColumn(CF, COL_LEASE);
tasksTable.delete(delete);

I'm getting an UnsupportedOperationException:

java.lang.UnsupportedOperationException: Cannot delete single latest cell.
at com.google.cloud.bigtable.hbase.adapters.DeleteAdapter.throwIfUnsupportedPointDelete(DeleteAdapter.java:85)
at com.google.cloud.bigtable.hbase.adapters.DeleteAdapter.adapt(DeleteAdapter.java:141)
at com.google.cloud.bigtable.hbase.adapters.HBaseRequestAdapter.adapt(HBaseRequestAdapter.java:71)
at com.google.cloud.bigtable.hbase.BigtableTable.delete(BigtableTable.java:307)
at queue.BigTableRowBackedQueue.poll(BigTableRowBackedQueue.java:54)

I saw in the code it occurs here.

I can delete the entire row fine from the HBase Java client, and I can delete individual columns fine by using the HBase shell.

How can I delete columns without removing the row in the Java client?

Misha Brukman
  • 12,938
  • 4
  • 61
  • 78
Chris
  • 470
  • 4
  • 11

1 Answers1

10

Sorry for your troubles. Bigtable and HBase differ in a couple of ways, and this is one of them.

Delete delete = new Delete(rowKey);
delete.addColumns(COLUMN_FAMILY, qual); // the 's' matters
table.delete(delete);

HBase's Delete.addColumn deletes only the latest cell from the column. The Delete.addColumn_s_ means delete all cells (i.e. all the various timestamps). Alternatively, you can delete a specific cell via Delete.addColumn(byte[], byte[], long) where the long is a timestamp.

The hbase shell delete uses deleteColumns which maps to addColumns under the cover. It also uses the s variation, which is why it works.

For reference here is our complete TestDelete suite which identify the use case you present as @Category(KnownGap.class) which we use to identify differences missing HBase features in the Bigtable client.

Solomon Duskis
  • 2,691
  • 16
  • 12