Skip to content

Commit

Permalink
HBASE-26895 on hbase shell, 'delete/deleteall' for a columnfamily is …
Browse files Browse the repository at this point in the history
…not working (apache#4283)

Signed-off-by: Duo Zhang <zhangduo@apache.org>
(cherry picked from commit ea9bc92)
(cherry picked from commit 02d51b0)
Change-Id: I185acca0416be2da9d73553ad44215a270bd6a1d
  • Loading branch information
eomiks authored and Apache9 committed Apr 14, 2022
1 parent 2b8a1a5 commit cddd9f5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hbase-shell/src/main/ruby/hbase/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,18 @@ def _createdelete_internal(row, column = nil,
if column != ""
if column && all_version
family, qualifier = parse_column_name(column)
d.addColumns(family, qualifier, timestamp)
if qualifier
d.addColumns(family, qualifier, timestamp)
else
d.addFamily(family, timestamp)
end
elsif column && !all_version
family, qualifier = parse_column_name(column)
d.addColumn(family, qualifier, timestamp)
if qualifier
d.addColumn(family, qualifier, timestamp)
else
d.addFamilyVersion(family, timestamp)
end
end
end
d
Expand Down
15 changes: 15 additions & 0 deletions hbase-shell/src/test/ruby/hbase/table_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,21 @@ def teardown
assert_nil(res)
end

define_test "delete should set proper cell type" do
del = @test_table._createdelete_internal('104', 'x:a', 1212)
assert_equal(del.get('x'.to_java_bytes, 'a'.to_java_bytes).get(0).getType.getCode,
org.apache.hadoop.hbase::KeyValue::Type::DeleteColumn.getCode)
del = @test_table._createdelete_internal('104', 'x:a', 1212, [], false)
assert_equal(del.get('x'.to_java_bytes, 'a'.to_java_bytes).get(0).getType.getCode,
org.apache.hadoop.hbase::KeyValue::Type::Delete.getCode)
del = @test_table._createdelete_internal('104', 'x', 1212)
assert_equal(del.get('x'.to_java_bytes, nil).get(0).getType.getCode,
org.apache.hadoop.hbase::KeyValue::Type::DeleteFamily.getCode)
del = @test_table._createdelete_internal('104', 'x', 1212, [], false)
assert_equal(del.get('x'.to_java_bytes, nil).get(0).getType.getCode,
org.apache.hadoop.hbase::KeyValue::Type::DeleteFamilyVersion.getCode)
end

#-------------------------------------------------------------------------------

define_test "deleteall should work w/o columns and timestamps" do
Expand Down

0 comments on commit cddd9f5

Please sign in to comment.