mirror of
https://github.com/apache/sqoop.git
synced 2025-05-03 23:41:35 +08:00
SQOOP-367 Codegen support for free-form query
git-svn-id: https://svn.apache.org/repos/asf/incubator/sqoop/trunk@1196921 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
1598c5a481
commit
d8a8c43009
@ -136,6 +136,11 @@ public void configureOptions(ToolOptions toolOptions) {
|
|||||||
.withDescription("Table to generate code for")
|
.withDescription("Table to generate code for")
|
||||||
.withLongOpt(TABLE_ARG)
|
.withLongOpt(TABLE_ARG)
|
||||||
.create());
|
.create());
|
||||||
|
codeGenOpts.addOption(OptionBuilder.withArgName("statement")
|
||||||
|
.hasArg()
|
||||||
|
.withDescription("SQL 'statement' to generate code for")
|
||||||
|
.withLongOpt(SQL_QUERY_ARG)
|
||||||
|
.create(SQL_QUERY_SHORT_ARG));
|
||||||
toolOptions.addUniqueOptions(codeGenOpts);
|
toolOptions.addUniqueOptions(codeGenOpts);
|
||||||
|
|
||||||
toolOptions.addUniqueOptions(getOutputFormatOptions());
|
toolOptions.addUniqueOptions(getOutputFormatOptions());
|
||||||
@ -160,6 +165,9 @@ public void applyOptions(CommandLine in, SqoopOptions out)
|
|||||||
if (in.hasOption(TABLE_ARG)) {
|
if (in.hasOption(TABLE_ARG)) {
|
||||||
out.setTableName(in.getOptionValue(TABLE_ARG));
|
out.setTableName(in.getOptionValue(TABLE_ARG));
|
||||||
}
|
}
|
||||||
|
if (in.hasOption(SQL_QUERY_ARG)) {
|
||||||
|
out.setSqlQuery(in.getOptionValue(SQL_QUERY_ARG));
|
||||||
|
}
|
||||||
|
|
||||||
applyCommonOptions(in, out);
|
applyCommonOptions(in, out);
|
||||||
applyOutputFormatOptions(in, out);
|
applyOutputFormatOptions(in, out);
|
||||||
@ -182,9 +190,16 @@ public void validateOptions(SqoopOptions options)
|
|||||||
validateOutputFormatOptions(options);
|
validateOutputFormatOptions(options);
|
||||||
validateHiveOptions(options);
|
validateHiveOptions(options);
|
||||||
|
|
||||||
if (options.getTableName() == null) {
|
if (options.getTableName() == null
|
||||||
|
&& options.getSqlQuery() == null) {
|
||||||
throw new InvalidOptionsException(
|
throw new InvalidOptionsException(
|
||||||
"--table is required for code generation." + HELP_STR);
|
"--" + TABLE_ARG + " or --" + SQL_QUERY_ARG
|
||||||
|
+ " is required for codegen. " + HELP_STR);
|
||||||
|
} else if (options.getTableName() != null
|
||||||
|
&& options.getSqlQuery() != null) {
|
||||||
|
throw new InvalidOptionsException(
|
||||||
|
"Cannot specify --" + TABLE_ARG + " and --" + SQL_QUERY_ARG
|
||||||
|
+ " together. " + HELP_STR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user