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

disbfnqx  于 2021-06-03  发布在  Sqoop
关注(0)|答案(1)|浏览(399)

hdp-2.5.0.0使用ambari 2.4.0.1
我可以从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

但是,当我尝试使用--create hive表时--schema选项不起作用,无论我将其放置在何处:

-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.
qpgpyjmq

qpgpyjmq1#

如果争论 -- 在命令行上给定,然后将后续参数直接发送到基础工具。
在研究了sqoop代码之后,我在 --create-hive-table 流不会流向基础工具。所以你不能使用 -- --schema 听你指挥。
源代码的有用部分 ImportTool :

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 :

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为您创建配置单元表并导入该表中的数据。它应该对你有用。

相关问题