Sqoop 导出到 SQL 服务器:架构?

Sqoop export to SQL Server: schemas?

我想将 HDFS 中的数据导出到架构 my_schema 中的 SQL 服务器 table。

我试过 --schema 像导入命令:

sqoop export \
--libjars /opt/mapr/sqoop/sqoop-1.4.6/lib/sqljdbc4.jar \
--connect "jdbc:sqlserver://MY-SERVER-DNS;database=my_db;" \
--schema "myschema" \
--table "my_table" \
--export-dir /path/to/my/hdfs/dir

ERROR tool.BaseSqoopTool: Unrecognized argument: --schema

--table "schema.table"

sqoop export \
--libjars /opt/mapr/sqoop/sqoop-1.4.6/lib/sqljdbc4.jar \
--connect "jdbc:sqlserver://MY-SERVER-DNS;database=my_db;" \
--table "my_schema.my_table" \
--export-dir /path/to/my/hdfs/dir

INFO manager.SqlManager: 
Executing SQL statement: SELECT t.* FROM [my_schema.my_table] AS t WHERE 1=0 

ERROR manager.SqlManager: Error executing statement: 
com.microsoft.sqlserver.jdbc.SQLServerException:
Invalid object name 'my_schema.my_table'.

有什么办法可以用 sqoop 做到这一点吗?或者其他技术?

编辑:

sqoop export \
--libjars /opt/mapr/sqoop/sqoop-1.4.6/lib/sqljdbc4.jar \
--connect "jdbc:sqlserver://MY-SERVER-DNS;database=my_db;schema=my_schema;" \
--table "my_table" \
--export-dir /path/to/my/hdfs/dir

INFO manager.SqlManager: Executing SQL statement: SELECT t.* FROM [my_table] AS t WHERE 1=0
16/07/25 10:46:21 ERROR manager.SqlManager: 
Error executing statement: com.microsoft.sqlserver.jdbc.SQLServerException:
Invalid object name 'my_table'.

这不是识别模式。

在连接字符串中提供架构:

jdbc:sqlserver://MY-SERVER-DNS;databaseName=my_db;schema=my_schema;

所以您的导出 sqoop 命令应该是:

sqoop export \
--libjars /opt/mapr/sqoop/sqoop-1.4.6/lib/sqljdbc4.jar \
--connect "jdbc:sqlserver://MY-SERVER-DNS;databaseName=my_db;schema=my_schema;" \
--table "my_table" \
--export-dir /path/to/my/hdfs/dir

另外:

Custom schemas are supported for both import and export job - 根据 sqoop 指南中的语法,--schema 应作为 -- --schema:

传递

所以您的导出 sqoop 命令应该是:

sqoop export \
--libjars /opt/mapr/sqoop/sqoop-1.4.6/lib/sqljdbc4.jar \
--connect "jdbc:sqlserver://MY-SERVER-DNS;databaseName=my_db;" \
--export-dir /path/to/my/hdfs/dir
--table "my_table" \
-- --schema my_schema \