mirror of
https://github.com/apache/sqoop.git
synced 2025-05-02 23:21:22 +08:00
SQOOP-3153: Sqoop export with --as-<spec_file_format> error message could be more verbose
(Ferenc Szabo via Szabolcs Vasas)
This commit is contained in:
parent
c975dc4c3b
commit
779eb01de4
@ -312,7 +312,7 @@ protected void destroy(SqoopOptions sqoopOpts) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
|
@ -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 @@
|
||||
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 void validateOptions(SqoopOptions options)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user