Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-11788

hbase is not deleting the cell when a Put with a KeyValue, KeyValue.Type.Delete is submitted

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 0.99.0, 0.96.1.1, 0.98.5, 2.0.0
    • 0.99.0, 0.98.6
    • None
    • None
    • Cloudera CDH 5.1.x

    • Reviewed

    Description

      Code executed:

          @Test
          public void testHbasePutDeleteCell() throws Exception {
              TableName tableName = TableName.valueOf("my_test");
              Configuration configuration = HBaseConfiguration.create();
              HTableInterface table = new HTable(configuration, tableName);
              final String rowKey = "12345";
              final byte[] familly = Bytes.toBytes("default");
              // put one row
              Put put = new Put(Bytes.toBytes(rowKey));
              put.add(familly, Bytes.toBytes("A"), Bytes.toBytes("a"));
              put.add(familly, Bytes.toBytes("B"), Bytes.toBytes("b"));
              put.add(familly, Bytes.toBytes("C"), Bytes.toBytes("c"));
              table.put(put);
              // get row back and assert the values
              Get get = new Get(Bytes.toBytes(rowKey));
              Result result = table.get(get);
              Assert.isTrue(Bytes.toString(result.getValue(familly, Bytes.toBytes("A"))).equals("a"), "Column A value should be a");
              Assert.isTrue(Bytes.toString(result.getValue(familly, Bytes.toBytes("B"))).equals("b"), "Column B value should be b");
              Assert.isTrue(Bytes.toString(result.getValue(familly, Bytes.toBytes("C"))).equals("c"), "Column C value should be c");
              // put the same row again with C column deleted
              put = new Put(Bytes.toBytes(rowKey));
              put.add(familly, Bytes.toBytes("A"), Bytes.toBytes("a"));
              put.add(familly, Bytes.toBytes("B"), Bytes.toBytes("b"));
              put.add(new KeyValue(Bytes.toBytes(rowKey), familly, Bytes.toBytes("C"), HConstants.LATEST_TIMESTAMP, KeyValue.Type.DeleteColumn));
              table.put(put);
              // get row back and assert the values
              get = new Get(Bytes.toBytes(rowKey));
              result = table.get(get);
              Assert.isTrue(Bytes.toString(result.getValue(familly, Bytes.toBytes("A"))).equals("a"), "Column A value should be a");
              Assert.isTrue(Bytes.toString(result.getValue(familly, Bytes.toBytes("B"))).equals("b"), "Column A value should be b");
              Assert.isTrue(result.getValue(familly, Bytes.toBytes("C")) == null, "Column C should not exists");
          }
      

      This assertion fails, the cell is not deleted but rather the value is empty:

      hbase(main):029:0> scan 'my_test'
      ROW                                                   COLUMN+CELL                                                                                                                                                 
       12345                                                column=default:A, timestamp=1408473082290, value=a                                                                                                          
       12345                                                column=default:B, timestamp=1408473082290, value=b                                                                                                          
       12345                                                column=default:C, timestamp=1408473082290, value=      
      

      This behavior is different than previous 4.8.x Cloudera version and is currently corrupting all hive queries involving is null or is not null operators on the columns mapped to hbase

      Attachments

        1. TestPutAfterDeleteColumn.java
          4 kB
          sri venu bora
        2. HBASE-11788-master_v2.patch
          10 kB
          Srikanth Srungarapu
        3. HBASE-11788-master.patch
          10 kB
          Srikanth Srungarapu
        4. TestPutWithDelete.java
          4 kB
          Andrew Kyle Purtell

        Issue Links

          Activity

            People

              srikanth235 Srikanth Srungarapu
              cristian_armaselu Cristian Armaselu
              Votes:
              0 Vote for this issue
              Watchers:
              16 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: