sqoop导入,具有带where子句的sql查询和并行处理

91zkwejq  于 2021-05-31  发布在  Hadoop
关注(0)|答案(1)|浏览(365)

我在mysql中有一个如下表:
订单详情:

+---------+------------+-------------------+--------------+                                                                                                                                                        
| 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)

请告知我的进口声明中需要更改的内容。

3pvhb19x

3pvhb19x1#

sqoop并行执行不会发生在垂直拆分中,而是发生在水平拆分中。
--拆分依据应为列名。列应该是均匀分布的。
https://sqoop.apache.org/docs/1.4.0-incubating/sqoopuserguide.html#id1765770
阅读:7.2.4。控制并行性

相关问题