Sqoop导入具有带where子句和并行处理的SQL查询

时间:2018-12-15 17:21:35

标签: hadoop bigdata sqoop

我在mysql中有一个表,如下所示:

Order_Details:

+---------+------------+-------------------+--------------+                                                                                                                                                        
| orderid | order_date | order_customer_id | order_status |                                                                                                                                                        
+---------+------------+-------------------+--------------+                                                                                                                                                        
| A001    | 10/30/2018 | C003              | Completed    |                                                                                                                                                        
| A002    | 10/30/2018 | C005              | Completed    |                                                                                                                                                        
| A451    | 11/02/2018 | C376              | Pending      |                                                                                                                                                        
| P9209   | 10/30/2018 | C234              | Completed    |                                                                                                                                                        
| P92099  | 10/30/2018 | C244              | Pending      |                                                                                                                                                        
| P9210   | 10/30/2018 | C035              | Completed    |                                                                                                                                                        
| P92398  | 10/30/2018 | C346              | Pending      |                                                                                                                                                        
| P9302   | 10/30/2018 | C034              | Completed    |                                                                                                                                                        
+---------+------------+-------------------+--------------+ 

以及以下描述:

mysql> desc Order_Details_Sankha;                                                                                                                                                                                  
+-------------------+-------------+------+-----+---------+-------+                                                                                                                                                 
| Field             | Type        | Null | Key | Default | Extra |                                                                                                                                                 
+-------------------+-------------+------+-----+---------+-------+                                                                                                                                                 
| orderid           | varchar(20) | NO   | PRI |         |       |                                                                                                                                                 
| order_date        | varchar(20) | YES  |     | NULL    |       |                                                                                                                                                 
| order_customer_id | varchar(20) | YES  |     | NULL    |       |                                                                                                                                                 
| order_status      | varchar(20) | YES  |     | NULL    |       |                                                                                                                                                 
+-------------------+-------------+------+-----+---------+-------+  

我正在使用以下 sqoop导入进行并行处理

sqoop import 
--connect jdbc:mysql://ip-10-0-1-10.ec2.internal/06july2018_new 
--username labuser 
--password abc123
--driver com.mysql.jdbc.Driver 
--query "select * from Order_Details where order_date = '10/30/2018'  AND \$CONDITIONS" 
--target-dir /user/sankha087_gmail_com/outputs/EMP_Sankha_1112201888 
--split-by ","   
--m 3

,我收到以下错误消息

18/12/15 17:15:14 WARN security.UserGroupInformation: PriviledgedActionException as:sankha087_gmail_com (auth:SIMPLE) cause:java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You hav
e an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '), MAX(,) FROM (select * from Order_Details_Sankha where order_date = '10/30/201' a
t line 1                                                                                                                                                                                                           
18/12/15 17:15:14 ERROR tool.ImportTool: Import failed: java.io.IOException: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to 
your MySQL server version for the right syntax to use near '), MAX(,) FROM (select * from Order_Details_Sankha where order_date = '10/30/201' at line 1                                                            
        at org.apache.sqoop.mapreduce.db.DataDrivenDBInputFormat.getSplits(DataDrivenDBInputFormat.java:207)                                                                                                       
        at org.apache.hadoop.mapreduce.JobSubmitter.writeNewSplits(JobSubmitter.java:305)                                                                                                                          
        at org.apache.hadoop.mapreduce.JobSubmitter.writeSplits(JobSubmitter.java:322)                                                                                                                             
        at org.apache.hadoop.mapreduce.JobSubmitter.submitJobInternal(JobSubmitter.java:200)                                                                                                                       
        at org.apache.hadoop.mapreduce.Job$10.run(Job.java:1307)   

请在我的导入声明中告知需要更改的内容。

1 个答案:

答案 0 :(得分:0)

垂直拆分不会发生并行并行执行,水平拆分会发生并行并行执行。

-分隔符应为列名。列应该是均匀分布的列。

https://sqoop.apache.org/docs/1.4.0-incubating/SqoopUserGuide.html#id1765770

阅读:7.2.4。控制并行性