diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb index 5eee26cd04d..460ede3b517 100644 --- a/hbase-shell/src/main/ruby/hbase/admin.rb +++ b/hbase-shell/src/main/ruby/hbase/admin.rb @@ -657,6 +657,23 @@ module Hbase htd.remove(name) end hasTableUpdate = true + # Unset table configuration + elsif method == 'table_conf_unset' + raise(ArgumentError, 'NAME parameter missing for table_conf_unset method') unless name + if name.is_a?(Array) + name.each do |key| + if htd.getConfigurationValue(key).nil? + raise ArgumentError, "Could not find configuration: #{key}" + end + htd.removeConfiguration(key) + end + else + if htd.getConfigurationValue(name).nil? + raise ArgumentError, "Could not find configuration: #{name}" + end + htd.removeConfiguration(name) + end + hasTableUpdate = true # Unknown method else raise ArgumentError, "Unknown method: #{method}" diff --git a/hbase-shell/src/main/ruby/shell/commands/alter.rb b/hbase-shell/src/main/ruby/shell/commands/alter.rb index 2207111d8d7..4aef28c1fc6 100644 --- a/hbase-shell/src/main/ruby/shell/commands/alter.rb +++ b/hbase-shell/src/main/ruby/shell/commands/alter.rb @@ -71,6 +71,10 @@ You can also set configuration settings specific to this table or column family: hbase> alter 't1', CONFIGURATION => {'hbase.hregion.scan.loadColumnFamiliesOnDemand' => 'true'} hbase> alter 't1', {NAME => 'f2', CONFIGURATION => {'hbase.hstore.blockingStoreFiles' => '10'}} +You can also unset configuration settings specific to this table: + + hbase> alter 't1', METHOD => 'table_conf_unset', NAME => 'hbase.hregion.majorcompaction' + You can also remove a table-scope attribute: hbase> alter 't1', METHOD => 'table_att_unset', NAME => 'MAX_FILESIZE' diff --git a/hbase-shell/src/test/ruby/hbase/admin_test.rb b/hbase-shell/src/test/ruby/hbase/admin_test.rb index 2a20d34e53e..025b737d0a1 100644 --- a/hbase-shell/src/test/ruby/hbase/admin_test.rb +++ b/hbase-shell/src/test/ruby/hbase/admin_test.rb @@ -480,6 +480,36 @@ module Hbase assert_no_match(eval("/" + key_2 + "/"), admin.describe(@test_name)) end + define_test "alter should be able to remove a table configuration" do + drop_test_table(@test_name) + create_test_table(@test_name) + + key = "TestConf" + command(:alter, @test_name, CONFIGURATION => {key => 1}) + + # eval() is used to convert a string to regex + assert_match(eval("/" + key + "/"), admin.describe(@test_name)) + + command(:alter, @test_name, 'METHOD' => 'table_conf_unset', 'NAME' => key) + assert_no_match(eval("/" + key + "/"), admin.describe(@test_name)) + end + + define_test "alter should be able to remove a list of table configuration" do + drop_test_table(@test_name) + + key_1 = "TestConf1" + key_2 = "TestConf2" + command(:create, @test_name, { NAME => 'i'}, CONFIGURATION => { key_1 => 1, key_2 => 2 }) + + # eval() is used to convert a string to regex + assert_match(eval("/" + key_1 + "/"), admin.describe(@test_name)) + assert_match(eval("/" + key_2 + "/"), admin.describe(@test_name)) + + command(:alter, @test_name, 'METHOD' => 'table_conf_unset', 'NAME' => [ key_1, key_2 ]) + assert_no_match(eval("/" + key_1 + "/"), admin.describe(@test_name)) + assert_no_match(eval("/" + key_2 + "/"), admin.describe(@test_name)) + end + define_test "get_table should get a real table" do drop_test_table(@test_name) create_test_table(@test_name)