diff --git a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java index 5a2698b..49532ae 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java @@ -1918,6 +1918,8 @@ private int showCreateTable(Hive db, ShowCreateTableDesc showCreateTbl) throws H final String ROW_FORMAT = "row_format"; final String TBL_LOCATION = "tbl_location"; final String TBL_PROPERTIES = "tbl_properties"; + boolean isHbaseTable = false; + StringBuilder createTab_str = new StringBuilder(); String tableName = showCreateTbl.getTableName(); Table tbl = db.getTable(tableName, false); @@ -1928,6 +1930,10 @@ private int showCreateTable(Hive db, ShowCreateTableDesc showCreateTbl) throws H FileSystem fs = resFile.getFileSystem(conf); outStream = fs.create(resFile); + if (tbl.getStorageHandler() != null) { + isHbaseTable = tbl.getStorageHandler().toString().equals("org.apache.hadoop.hive.hbase.HBaseStorageHandler"); + } + if (tbl.isView()) { String createTab_stmt = "CREATE VIEW `" + tableName + "` AS " + tbl.getViewExpandedText(); outStream.writeBytes(createTab_stmt.toString()); @@ -1936,17 +1942,20 @@ private int showCreateTable(Hive db, ShowCreateTableDesc showCreateTbl) throws H return 0; } - ST createTab_stmt = new ST("CREATE <" + EXTERNAL + "> TABLE `" + - tableName + "`(\n" + - "<" + LIST_COLUMNS + ">)\n" + - "<" + TBL_COMMENT + ">\n" + - "<" + LIST_PARTITIONS + ">\n" + - "<" + SORT_BUCKET + ">\n" + - "<" + ROW_FORMAT + ">\n" + - "LOCATION\n" + - "<" + TBL_LOCATION + ">\n" + - "TBLPROPERTIES (\n" + - "<" + TBL_PROPERTIES + ">)\n"); + createTab_str.append("CREATE <" + EXTERNAL + "> TABLE `"); + createTab_str.append(tableName + "`(\n"); + createTab_str.append("<" + LIST_COLUMNS + ">)\n"); + createTab_str.append("<" + TBL_COMMENT + ">\n"); + createTab_str.append("<" + LIST_PARTITIONS + ">\n"); + createTab_str.append("<" + SORT_BUCKET + ">\n"); + createTab_str.append("<" + ROW_FORMAT + ">\n"); + if (!isHbaseTable) { + createTab_str.append("LOCATION\n"); + createTab_str.append("<" + TBL_LOCATION + ">\n"); + } + createTab_str.append("TBLPROPERTIES (\n"); + createTab_str.append("<" + TBL_PROPERTIES + ">)\n"); + ST createTab_stmt = new ST(createTab_str.toString()); // For cases where the table is external String tbl_external = ""; @@ -2114,7 +2123,10 @@ else if (sortCol.getOrder() == BaseSemanticAnalyzer.HIVE_COLUMN_ORDER_DESC) { createTab_stmt.add(LIST_PARTITIONS, tbl_partitions); createTab_stmt.add(SORT_BUCKET, tbl_sort_bucket); createTab_stmt.add(ROW_FORMAT, tbl_row_format); - createTab_stmt.add(TBL_LOCATION, tbl_location); + // Table location should not be printed with hbase backed tables + if (!isHbaseTable) { + createTab_stmt.add(TBL_LOCATION, tbl_location); + } createTab_stmt.add(TBL_PROPERTIES, tbl_properties); outStream.writeBytes(createTab_stmt.render()); diff --git a/ql/src/java/org/apache/hadoop/hive/ql/metadata/DefaultStorageHandler.java b/ql/src/java/org/apache/hadoop/hive/ql/metadata/DefaultStorageHandler.java index 83772bd..e183bf3 100644 --- a/ql/src/java/org/apache/hadoop/hive/ql/metadata/DefaultStorageHandler.java +++ b/ql/src/java/org/apache/hadoop/hive/ql/metadata/DefaultStorageHandler.java @@ -101,4 +101,8 @@ public Configuration getConf() { public void setConf(Configuration conf) { this.conf = conf; } + @Override + public String toString() { + return this.getClass().getName(); + } }