You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ch...@apache.org on 2013/01/04 11:28:13 UTC
git commit: SQOOP-804: Warn if hive special arguments will be used
without --hive-import
Updated Branches:
refs/heads/trunk b79c4b9e8 -> 8029ed0cf
SQOOP-804: Warn if hive special arguments will be used without --hive-import
(Jarek Jarcec Cecho via Cheolsoo Park)
Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/8029ed0c
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/8029ed0c
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/8029ed0c
Branch: refs/heads/trunk
Commit: 8029ed0cfc98c1cc7abac9922100b33305d184e8
Parents: b79c4b9
Author: Cheolsoo Park <ch...@apache.org>
Authored: Fri Jan 4 02:27:27 2013 -0800
Committer: Cheolsoo Park <ch...@apache.org>
Committed: Fri Jan 4 02:27:27 2013 -0800
----------------------------------------------------------------------
src/java/com/cloudera/sqoop/SqoopOptions.java | 4 ++
src/java/org/apache/sqoop/SqoopOptions.java | 10 ++++--
src/java/org/apache/sqoop/tool/BaseSqoopTool.java | 28 ++++++++++++++-
3 files changed, 37 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/sqoop/blob/8029ed0c/src/java/com/cloudera/sqoop/SqoopOptions.java
----------------------------------------------------------------------
diff --git a/src/java/com/cloudera/sqoop/SqoopOptions.java b/src/java/com/cloudera/sqoop/SqoopOptions.java
index 8d4f202..ffec2dc 100644
--- a/src/java/com/cloudera/sqoop/SqoopOptions.java
+++ b/src/java/com/cloudera/sqoop/SqoopOptions.java
@@ -88,6 +88,10 @@ public class SqoopOptions
org.apache.sqoop.SqoopOptions.clearNonceDir();
}
+ public static String getHiveHomeDefault() {
+ return org.apache.sqoop.SqoopOptions.getHiveHomeDefault();
+ }
+
/**
* {@inheritDoc}.
* @deprecated
http://git-wip-us.apache.org/repos/asf/sqoop/blob/8029ed0c/src/java/org/apache/sqoop/SqoopOptions.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/SqoopOptions.java b/src/java/org/apache/sqoop/SqoopOptions.java
index 613f797..3e0ec3e 100644
--- a/src/java/org/apache/sqoop/SqoopOptions.java
+++ b/src/java/org/apache/sqoop/SqoopOptions.java
@@ -766,14 +766,18 @@ public class SqoopOptions implements Cloneable {
SqoopOptions.curNonce = null;
}
+ public static String getHiveHomeDefault() {
+ // Set this with $HIVE_HOME, but -Dhive.home can override.
+ String hiveHome = System.getenv("HIVE_HOME");
+ return System.getProperty("hive.home", hiveHome);
+ }
+
private void initDefaults(Configuration baseConfiguration) {
// first, set the true defaults if nothing else happens.
// default action is to run the full pipeline.
this.hadoopHome = System.getenv("HADOOP_HOME");
- // Set this with $HIVE_HOME, but -Dhive.home can override.
- this.hiveHome = System.getenv("HIVE_HOME");
- this.hiveHome = System.getProperty("hive.home", this.hiveHome);
+ this.hiveHome = getHiveHomeDefault();
this.inputDelimiters = new DelimiterSet(
DelimiterSet.NULL_CHAR, DelimiterSet.NULL_CHAR,
http://git-wip-us.apache.org/repos/asf/sqoop/blob/8029ed0c/src/java/org/apache/sqoop/tool/BaseSqoopTool.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/tool/BaseSqoopTool.java b/src/java/org/apache/sqoop/tool/BaseSqoopTool.java
index d795646..c0221c9 100644
--- a/src/java/org/apache/sqoop/tool/BaseSqoopTool.java
+++ b/src/java/org/apache/sqoop/tool/BaseSqoopTool.java
@@ -991,14 +991,13 @@ public abstract class BaseSqoopTool extends com.cloudera.sqoop.tool.SqoopTool {
protected void validateHiveOptions(SqoopOptions options)
throws InvalidOptionsException {
- // Empty; this method is present to maintain API consistency, and
- // is reserved for future constraints on Hive options.
if (options.getHiveDelimsReplacement() != null
&& options.doHiveDropDelims()) {
throw new InvalidOptionsException("The " + HIVE_DROP_DELIMS_ARG
+ " option conflicts with the " + HIVE_DELIMS_REPLACEMENT_ARG
+ " option." + HELP_STR);
}
+
// Many users are reporting issues when they are trying to import data
// directly into hive warehouse. This should prevent users from doing
// so in case of a default location.
@@ -1018,6 +1017,31 @@ public abstract class BaseSqoopTool extends com.cloudera.sqoop.tool.SqoopTool {
LOG.warn("--target-dir or --warehouse-dir into /user/hive/warehouse in");
LOG.warn("case that you will detect any issues.");
}
+
+ // Warn about using hive specific arguments without hive import itself
+ if (!options.doHiveImport()
+ && ((options.getHiveHome() != null
+ && options.getHiveHome().equals(SqoopOptions.getHiveHomeDefault()))
+ || options.doOverwriteHiveTable()
+ || options.doFailIfHiveTableExists()
+ || (options.getHiveTableName() != null
+ && !options.getHiveTableName().equals(options.getTableName()))
+ || options.getHivePartitionKey() != null
+ || options.getHivePartitionValue() != null
+ || options.getMapColumnHive().size() > 0)) {
+ LOG.warn("It seems that you've specified at least one of following:");
+ LOG.warn("\t--hive-home");
+ LOG.warn("\t--hive-overwrite");
+ LOG.warn("\t--create-hive-table");
+ LOG.warn("\t--hive-table");
+ LOG.warn("\t--hive-partition-key");
+ LOG.warn("\t--hive-partition-value");
+ LOG.warn("\t--map-column-hive");
+ LOG.warn("Without specifying parameter --hive-import. Please note that");
+ LOG.warn("those arguments will not be used in this session. Either");
+ LOG.warn("specify --hive-import to apply them correctly or remove them");
+ LOG.warn("from command line to remove this warning.");
+ }
}
protected void validateHBaseOptions(SqoopOptions options)