sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From va...@apache.org
Subject sqoop git commit: SQOOP-3153: Sqoop export with --as-<spec_file_format> error message could be more verbose
Date Fri, 15 Dec 2017 08:31:42 GMT
Repository: sqoop
Updated Branches:
  refs/heads/trunk c975dc4c3 -> 779eb01de


SQOOP-3153: Sqoop export with --as-<spec_file_format> error message could be more verbose

(Ferenc Szabo via Szabolcs Vasas)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/779eb01d
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/779eb01d
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/779eb01d

Branch: refs/heads/trunk
Commit: 779eb01de4358f039a5c8c8edb76ffdcd5c4ffd6
Parents: c975dc4
Author: Szabolcs Vasas <vasas@apache.org>
Authored: Fri Dec 15 09:29:07 2017 +0100
Committer: Szabolcs Vasas <vasas@apache.org>
Committed: Fri Dec 15 09:29:07 2017 +0100

----------------------------------------------------------------------
 .../org/apache/sqoop/tool/BaseSqoopTool.java    |  2 +-
 src/java/org/apache/sqoop/tool/ExportTool.java  | 32 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/779eb01d/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 6a4dcb0..b4f972c 100644
--- a/src/java/org/apache/sqoop/tool/BaseSqoopTool.java
+++ b/src/java/org/apache/sqoop/tool/BaseSqoopTool.java
@@ -312,7 +312,7 @@ public abstract class BaseSqoopTool extends com.cloudera.sqoop.tool.SqoopTool
{
   }
 
   /**
-   * Examines a subset of the arrray presented, and determines if it
+   * Examines a subset of the array presented, and determines if it
    * contains any non-empty arguments. If so, logs the arguments
    * and returns true.
    *

http://git-wip-us.apache.org/repos/asf/sqoop/blob/779eb01d/src/java/org/apache/sqoop/tool/ExportTool.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/sqoop/tool/ExportTool.java b/src/java/org/apache/sqoop/tool/ExportTool.java
index cd6cdf3..4bd2fed 100644
--- a/src/java/org/apache/sqoop/tool/ExportTool.java
+++ b/src/java/org/apache/sqoop/tool/ExportTool.java
@@ -19,6 +19,8 @@
 package org.apache.sqoop.tool;
 
 import java.io.IOException;
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.commons.cli.CommandLine;
@@ -41,6 +43,16 @@ import static org.apache.sqoop.manager.SupportedManagers.MYSQL;
 public class ExportTool extends com.cloudera.sqoop.tool.BaseSqoopTool {
 
   public static final Log LOG = LogFactory.getLog(ExportTool.class.getName());
+  public static final String NOT_SUPPORTED_FILE_FORMAT_ERROR_MSG = "Please note that the
export tool " +
+          "detects the file format automatically and does not support it as an argument:
%s";
+
+  private final List<String> unsupportedArguments =
+    Collections.unmodifiableList(
+      Arrays.asList(
+        BaseSqoopTool.FMT_PARQUETFILE_ARG,
+        BaseSqoopTool.FMT_AVRODATAFILE_ARG,
+        BaseSqoopTool.FMT_SEQUENCEFILE_ARG)
+  );
 
   private CodeGenTool codeGenerator;
 
@@ -383,6 +395,26 @@ public class ExportTool extends com.cloudera.sqoop.tool.BaseSqoopTool
{
     vaildateDirectExportOptions(options);
   }
 
+  @Override
+  /** {@inheritDoc} */
+  protected boolean hasUnrecognizedArgs(String [] argv, int offset, int len) {
+    boolean unrecognizedArgs = super.hasUnrecognizedArgs(argv, offset, len);
+    for (String arg : argv) {
+      if (unsupportedArguments.contains(stripLeadingHyphens(arg))) {
+        LOG.error(String.format(NOT_SUPPORTED_FILE_FORMAT_ERROR_MSG, arg));
+      }
+    }
+    return unrecognizedArgs;
+  }
+
+  private String stripLeadingHyphens(String arg) {
+    if (arg != null
+            && arg.startsWith("--")) {
+      return arg.substring(2);
+    }
+    return arg;
+  }
+
   void vaildateDirectExportOptions(SqoopOptions options) throws InvalidOptionsException {
     if (options.isDirect()) {
       validateHasDirectConnectorOption(options);


Mime
View raw message