sqoop2增量导入无法指定last value问题解决方法

来源:互联网 发布:优化生活环境的英文 编辑:程序博客网 时间:2024/04/26 22:22

在用sqoop 1.99.6创建任务进行增量导入时,在incremental read后需要输入check column和last value,但是再输入last value时输入任何值都会提示超出了size,size为-1。以下是这个问题的解决方法。

sqoop 1.99.6版本尚不稳定,源码存在错误,上个问题的错误原因在于a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java中存在错误代码,一共存在两处错误

第一处为:

@@ -433,7 +433,7 @@ public final class ConfigFiller {
     String opt = ConfigOptions.getOptionKey(prefix, input);
     if (line.hasOption(opt)) {
       String value = line.getOptionValue(ConfigOptions.getOptionKey(prefix, input));
-      if(value.length() > input.getMaxLength()) {
+      if((input.getMaxLength() >= 0) && (value.length() > input.getMaxLength())) {
         errorMessage(input, "Size of input exceeds allowance for this input"
           + " field. Maximal allowed size is " + input.getMaxLength());
       }

第二处为:

@@ -1039,7 +1039,7 @@ public final class ConfigFiller {
       input.setValue(userTyped);
 
       // Check that it did not exceeds maximal allowance for given input
-      if(userTyped.length() > input.getMaxLength()) {
+      if((input.getMaxLength() >= 0) && (userTyped.length() > input.getMaxLength())) {
         errorMessage("Size of input exceeds allowance for this input"
           + " field. Maximal allowed size is " + input.getMaxLength());
         return fillInputStringWithBundle(input, reader, bundle);


修改后把sqoop-shell-1.99.6.jar中的ConfigFiller.class替换成修改后的.class,即可进行正常的增量导入。

参考:https://git-wip-us.apache.org/repos/asf?p=sqoop.git;a=commitdiff;h=c54f92854746cb16995d11b3dcf9c395839af358;hp=ecdb8167b48097f7aee7a439e38f2792d3cab2b2


1 0