--schema不能与Sqoop create-hive-table一起使用

时间:2016-10-13 07:29:31

标签: hortonworks-data-platform sqoop

使用Ambari 2.4.0.1的HDP-2.5.0.0

我能够从SQL Server源数据库中创建HCatalog中的表,例如:

sqoop import --null-string '\\N' --null-non-string '\\N' --hive-delims-replacement '\0D' --hcatalog-home /usr/hdp/current/hive-webhcat --hcatalog-database MS_Management_Coaching --hcatalog-table TripAggregate --create-hcatalog-table --hcatalog-storage-stanza 'stored as orc tblproperties ("orc.compress"="ZLIB")' --validate --connect 'jdbc:sqlserver://<DB server>;database=Management' --username uname--password pwd--table TripAggregate -- --schema Coaching

但是当我尝试使用Clone impl of Rc时,无论我在哪里定位它, - --chema选项都不起作用:

-bash-4.2$ sqoop create-hive-table --hive-database test --connect 'jdbc:sqlserver://<DB Server>;database=Management' --username uname--password pwd--table TripAggregate -- --schema Coaching
Warning: /usr/hdp/2.5.0.0-1245/accumulo does not exist! Accumulo imports will fail.
Please set $ACCUMULO_HOME to the root of your Accumulo installation.
16/10/12 21:28:13 INFO sqoop.Sqoop: Running Sqoop version: 1.4.6.2.5.0.0-1245
16/10/12 21:28:13 WARN tool.BaseSqoopTool: Setting your password on the command-line is insecure. Consider using -P instead.
16/10/12 21:28:13 ERROR tool.BaseSqoopTool: Error parsing arguments for create-hive-table:
16/10/12 21:28:13 ERROR tool.BaseSqoopTool: Unrecognized argument: --
16/10/12 21:28:13 ERROR tool.BaseSqoopTool: Unrecognized argument: --schema
16/10/12 21:28:13 ERROR tool.BaseSqoopTool: Unrecognized argument: DriverCoaching
Try --help for usage instructions.

1 个答案:

答案 0 :(得分:1)

  

如果在命令行中给出参数--,则后续参数将直接发送到基础工具。

在查看sqoop代码后,我发现在--create-hive-table流程中没有转到底层工具。这就是您无法在命令中使用-- --schema的原因。

ImportTool的{​​{3}}的有用部分:

 public void validateOptions(SqoopOptions options)
      throws InvalidOptionsException {

    // If extraArguments is full, check for '--' followed by args for
    // mysqldump or other commands we rely on.
    options.setExtraArgs(getSubcommandArgs(extraArguments));
    int dashPos = getDashPosition(extraArguments);

    if (hasUnrecognizedArgs(extraArguments, 0, dashPos)) {
      throw new InvalidOptionsException(HELP_STR);
    }

    validateImportOptions(options);
    validateIncrementalOptions(options);
    validateCommonOptions(options);
    validateCodeGenOptions(options);
    validateOutputFormatOptions(options);
    validateHBaseOptions(options);
    validateHiveOptions(options);
    validateHCatalogOptions(options);
    validateAccumuloOptions(options);
  }

CreateHiveTable的{​​{3}}的有用部分:

 public void validateOptions(SqoopOptions options)
      throws InvalidOptionsException {

    if (hasUnrecognizedArgs(extraArguments)) {
      throw new InvalidOptionsException(HELP_STR);
    }

    validateCommonOptions(options);
    validateOutputFormatOptions(options);
    validateHiveOptions(options);

    if (options.getTableName() == null) {
      throw new InvalidOptionsException(
          "--table is required for table definition importing." + HELP_STR);
    }
  }

你看到后来没有检查-- args。

修改

默认情况下,

--hive-import会创建配置表,您可以使用-- --schema和import命令。如果您希望sqoop为您创建配置单元表并导入该表中的数据。它应该适合你。