2015-08-28 101 views
0

如何將模式名稱傳遞到sqoop job將數據從SQL Server導入到hdfs從sql server導入數據的Sqoop作業忽略模式

sqoop job --create job_name -- import --connect "jdbc:sqlserver://server:port;database=datatabase_name;username=user;password=password" --table source_table --as-avrodatafile --target-dir data/target_folder -- --schema schema_name 

當我執行使用

sqoop job -exec job_name 

所生成缺少架構名稱查詢工作。

它失敗,以下錯誤消息:

15/08/28 10:53:09 INFO manager.SqlManager: Executing SQL statement: **SELECT t.* FROM [source_table] AS t WHERE 1=0** 
15/08/28 10:53:09 ERROR manager.SqlManager: Error executing statement: com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'source_table'. 
com.microsoft.sqlserver.jdbc.SQLServerException: Invalid object name 'source_table'. 
     at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDatabaseError(SQLServerException.java:216) 
     at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1515) 
     at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:404) 
     at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:350) 
     at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:5696) 
     at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1715) 
     at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:180) 
     at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:155) 
     at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQuery(SQLServerPreparedStatement.java:285) 
     at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:750) 
     at org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:759) 
     at org.apache.sqoop.manager.SqlManager.getColumnInfoForRawQuery(SqlManager.java:269) 
     at org.apache.sqoop.manager.SqlManager.getColumnTypesForRawQuery(SqlManager.java:240) 
     at org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:226) 
     at org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:295) 
     at org.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1773) 
     at org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1578) 
     at org.apache.sqoop.tool.CodeGenTool.generateORM(CodeGenTool.java:96) 
     at org.apache.sqoop.tool.ImportTool.importTable(ImportTool.java:478) 
     at org.apache.sqoop.tool.ImportTool.run(ImportTool.java:601) 
     at org.apache.sqoop.tool.JobTool.execJob(JobTool.java:228) 
     at org.apache.sqoop.tool.JobTool.run(JobTool.java:283) 
     at org.apache.sqoop.Sqoop.run(Sqoop.java:143) 
     at org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70) 
     at org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:179) 
     at org.apache.sqoop.Sqoop.runTool(Sqoop.java:218) 
     at org.apache.sqoop.Sqoop.runTool(Sqoop.java:227) 
     at org.apache.sqoop.Sqoop.main(Sqoop.java:236) 

有什麼建議?

回答

2

我遇到了同樣的問題,我用下面的命令來代替,

sqoop job --exec job_name -- -- --schema schema_name

+0

此外,作業--create中的模式參數也可以丟棄 – Pradeep

+0

工作。謝謝! – Gocht

0

試試這個:

sqoop job --create job_name -- import --connect "jdbc:sqlserver://server:port;database=datatabase_name;username=user;password=password" --table source_table --as-avrodatafile --target-dir data/target_folder -- --schema schema_name --verbose --columns .....list of columns here(comma separated)

0

捎帶上普拉迪普的答案,這裏是如何我在作業模式中使用模式命令創建作業:

sqoop job --create job_name -- import --connect "jdbc:sqlserver://server:port;database=datatabase_name;username=user;password=password" --table source_table --as-avrodatafile --target-dir data/target_folder -- -- --schema schema_name 

請注意,最後有三套--- -- --schema schema_name

我正在使用它來自動創建執行增量更新的作業。爲了利用sqoop自動跟蹤增量更新的能力,我需要使用一份工作。