本文介绍了Sqoop作业从sql server导入数据忽略模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将模式名称传递给 sqoop job 将数据从 SQL Server 导入 hdfs

  sqoop job --create job_name  -  import --connectjdbc: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:执行SQL语句:** SELECT t。* FROM [source_table] AS t WHERE 1 = 0 ** 
15/08/28 10:53:09 ERROR manager.SqlManager:执行错误声明:com.microsoft.sqlserver.jdbc.SQLServerException:无效的对象名称'source_table'。
com.microsoft.sqlserver.jdbc.SQLServerException:无效的对象名称'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(SQLServe rPreparedStatement.java:285)
在org.apache.sqoop.manager.SqlManager.execute(SqlManager.java:750)
在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)
。在org.apache.sqoop.manager.SqlManager.getColumnTypes(SqlManager.java:226)
在org.apache.sqoop.manager.ConnManager.getColumnTypes(ConnManager.java:295)
。在组织.apache.sqoop.orm.ClassWriter.getColumnTypes(ClassWriter.java:1773)
在org.apache.sqoop.orm.ClassWriter.generate(ClassWriter.java:1578)
在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)在org.apache处
。 sqoop.tool.JobTool.execJob(JobTool.java:228)
处org.apache.sqoop.Sqoop org.apache.sqoop.tool.JobTool.run(JobTool.java:283)
。运行(Sqoop.java:143)
在org.apache.hadoop.util.ToolRunner.run(ToolRunner.java:70)
在org.apache.sqoop.Sqoop.runSqoop(Sqoop.java:在org.apache.sqoop.Sqoop.runTool(Sqoop.java:218 179)

在org.apache.sqoop.Sqoop.runTool(Sqoop.java:227)
。在组织.apache.sqoop.Sqoop.main(Sqoop.java:236)

有何建议?

解决方案

我遇到了同样的问题,我改用下面的命令:

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


How do I pass a schema name to sqoop job importing data from SQL Server to hdfs?

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

When I execute the job using

sqoop job -exec job_name

The query that is generated is missing the schema name.

It fails with following error message:

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)

Any suggestions?

解决方案

I came across the same problem, and i used the following command instead,

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

这篇关于Sqoop作业从sql server导入数据忽略模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-17 19:53