Skip to content

Commit

Permalink
HBASE-23138 Drop_all table by regex fail (#704)
Browse files Browse the repository at this point in the history
Signed-off-by: Wellington Chevreuil <[email protected]>
(cherry picked from commit d237106)
  • Loading branch information
Karthik Palanisamy authored and wchevreuil committed Oct 9, 2019
1 parent a342590 commit 79c772f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
10 changes: 9 additions & 1 deletion hbase-shell/src/main/ruby/hbase/admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,15 @@ def drop(table_name)
# Drops a table
def drop_all(regex)
pattern = Pattern.compile(regex.to_s)
failed = @admin.deleteTables(pattern).map { |t| t.getTableName.getNameAsString }
failed = java.util.ArrayList.new
@admin.listTableNames(pattern).each do |table_name|
begin
@admin.deleteTable(table_name)
rescue java.io.IOException => e
puts puts "table:#{table_name}, error:#{e.toString}"
failed.add(table_name)
end
end
failed
end

Expand Down
4 changes: 4 additions & 0 deletions hbase-shell/src/test/ruby/hbase/admin_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,10 @@ def teardown
admin.enable_all(@regex)
assert(command(:is_enabled, @t1))
assert(command(:is_enabled, @t2))
admin.disable_all(@regex)
admin.drop_all(@regex)
assert(!command(:exists, @t1))
assert(!command(:exists, @t2))
end

#-------------------------------------------------------------------------------
Expand Down

0 comments on commit 79c772f

Please sign in to comment.