我想将HDFS中的数据导出到架构中的SQL Server表my_schema
.
我试着--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
也:
导入和导出作业都支持自定义模式 - 从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 \