You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ab...@apache.org on 2012/09/13 19:20:36 UTC
git commit: SQOOP 600: HBase table family presence is not working
correctly on new HBase versions
Updated Branches:
refs/heads/trunk 3fee25eb8 -> 0b2a688d3
SQOOP 600: HBase table family presence is not working correctly on new HBase versions
(Jarek Jarcec Cecho via Abhijeet Gaikwad)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/0b2a688d
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/0b2a688d
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/0b2a688d
Branch: refs/heads/trunk
Commit: 0b2a688d36f36e7cbc3c0b3bb621df500ec81003
Parents: 3fee25e
Author: Abhijeet Gaikwad <ab...@apache.org>
Authored: Thu Sep 13 22:46:25 2012 +0530
Committer: Abhijeet Gaikwad <ab...@apache.org>
Committed: Thu Sep 13 22:46:25 2012 +0530
----------------------------------------------------------------------
.../org/apache/sqoop/mapreduce/HBaseImportJob.java | 31 +++++++++------
1 files changed, 19 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/0b2a688d/src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java b/src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java
index a2a167b..467c5fd 100644
--- a/src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java
+++ b/src/java/org/apache/sqoop/mapreduce/HBaseImportJob.java
@@ -181,13 +181,14 @@ public class HBaseImportJob extends DataDrivenImportJob {
}
// Check to see if the table exists.
- HTableDescriptor tableDesc = new HTableDescriptor(tableName);
+ HTableDescriptor tableDesc = null;
byte [] familyBytes = Bytes.toBytes(familyName);
HColumnDescriptor colDesc = new HColumnDescriptor(familyBytes);
if (!admin.tableExists(tableName)) {
if (options.getCreateHBaseTable()) {
// Create the table.
LOG.info("Creating missing HBase table " + tableName);
+ tableDesc = new HTableDescriptor(tableName);
tableDesc.addFamily(colDesc);
admin.createTable(tableDesc);
} else {
@@ -195,18 +196,24 @@ public class HBaseImportJob extends DataDrivenImportJob {
LOG.warn("This job may fail. Either explicitly create the table,");
LOG.warn("or re-run with --hbase-create-table.");
}
- } else if (!tableDesc.hasFamily(familyBytes)) {
- if (options.getCreateHBaseTable()) {
- // Create the column family.
- LOG.info("Creating missing column family " + familyName);
- admin.disableTable(tableName);
- admin.addColumn(tableName, colDesc);
- admin.enableTable(tableName);
- } else {
- LOG.warn("Could not find column family " + familyName + " in table "
+ } else {
+ // Table exists, so retrieve their current version
+ tableDesc = admin.getTableDescriptor(Bytes.toBytes(tableName));
+
+ // Check if current version do have specified column family
+ if (!tableDesc.hasFamily(familyBytes)) {
+ if (options.getCreateHBaseTable()) {
+ // Create the column family.
+ LOG.info("Creating missing column family " + familyName);
+ admin.disableTable(tableName);
+ admin.addColumn(tableName, colDesc);
+ admin.enableTable(tableName);
+ } else {
+ LOG.warn("Could not find column family " + familyName + " in table "
+ tableName);
- LOG.warn("This job may fail. Either create the column family,");
- LOG.warn("or re-run with --hbase-create-table.");
+ LOG.warn("This job may fail. Either create the column family,");
+ LOG.warn("or re-run with --hbase-create-table.");
+ }
}
}