2016-10-13 44 views
0

HDP-2.5.0.0使用Ambari 2.4.0.1- --schema不Sqoop創建蜂箱表

我可以從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-table,本 - --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. 

回答

1

如果變元在命令行中給出了t --,然後將後續參數直接發送到底層工具。

查看sqoop代碼後,我發現在--create-hive-table流程不會轉到底層工具。這就是爲什麼你不能在你的命令中使用-- --schema。的source codeImportTool

有用的部分:source codeCreateHiveTable

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); 
    } 

有用的部分:

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與導入命令。如果您希望sqoop爲您創建配置單元表並在該表中導入數據。它應該適合你。

+0

那麼這是否意味着--create-hive-table無法從源模式讀取?任何可以實施的解決方法? –

+0

我假設沒有'--schema Coaching',你不能讀這張表。所以你可以把你的表放在默認模式('dbo',我猜)並繼續。或者您可以更改sqoop的源代碼並在本地構建並繼續。 –

+0

@KaliyugAntagonist檢查更新的答案 –