From 8816fa05c2fc5e73cdb3f8b3fa0e24d21907aa47 Mon Sep 17 00:00:00 2001 From: Enis Soztutar Date: Mon, 12 Jan 2015 13:59:44 -0800 Subject: [PATCH] HBASE-12832 Describe table from shell no longer shows Table's attributes, only CF attributes (Srikanth Srungarapu) --- .../java/org/apache/hadoop/hbase/HTableDescriptor.java | 7 +++++++ hbase-shell/src/main/ruby/hbase/admin.rb | 4 ++++ hbase-shell/src/main/ruby/shell/commands/describe.rb | 3 ++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java index 74783581991..cc91aedbbbc 100644 --- a/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java +++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/HTableDescriptor.java @@ -860,6 +860,13 @@ public class HTableDescriptor implements Comparable { return s.toString(); } + /** + * @return map of all table attributes formatted into string. + */ + public String toStringTableAttributes() { + return getValues(true).toString(); + } + private StringBuilder getValues(boolean printDefaults) { StringBuilder s = new StringBuilder(); diff --git a/hbase-shell/src/main/ruby/hbase/admin.rb b/hbase-shell/src/main/ruby/hbase/admin.rb index 09b4181dbd5..f7bcd83ba5e 100644 --- a/hbase-shell/src/main/ruby/hbase/admin.rb +++ b/hbase-shell/src/main/ruby/hbase/admin.rb @@ -362,6 +362,10 @@ module Hbase @admin.getTableDescriptor(TableName.valueOf(table_name)).getColumnFamilies() end + def get_table_attributes(table_name) + @admin.getTableDescriptor(TableName.valueOf(table_name)).toStringTableAttributes + end + #---------------------------------------------------------------------------------------------- # Truncates table (deletes all records by recreating the table) def truncate(table_name, conf = @conf) diff --git a/hbase-shell/src/main/ruby/shell/commands/describe.rb b/hbase-shell/src/main/ruby/shell/commands/describe.rb index 39a30c1da0e..bfa16cdc2da 100644 --- a/hbase-shell/src/main/ruby/shell/commands/describe.rb +++ b/hbase-shell/src/main/ruby/shell/commands/describe.rb @@ -38,7 +38,8 @@ EOF column_families = admin.get_column_families(table) formatter.header(["Table " + table.to_s + " is " + if admin.enabled?(table) then "ENABLED" else "DISABLED" end]) - formatter.header([ "COLUMN FAMILIES DESCRIPTION" ]) + formatter.row([table.to_s + admin.get_table_attributes(table)], true) + formatter.header(["COLUMN FAMILIES DESCRIPTION"]) column_families.each do |column_family| formatter.row([ column_family.to_s ], true) end