Sqoop import --target-dir 不起作用,而是将文件放在默认目录中



Sqoop导入脚本:

sqoop import --connect jdbc:mysql://localhost/retail_db --username root --password cloudera --target-dir /user/cloudera/retail_db/products_test --table products --hive-import  --create-hive-table  --hive-table retail_db.products_test

成功导入 sqoop 和创建 Hive 表后 位置是/hive/warehouse/retail_db.db/products_test 而不是/user/cloudera/retail_db/products_test

蜂房:

SHOW CREATE TABLE products_test;

CREATE TABLE `products_test`(
`product_id` int, 
`product_category_id` int, 
`product_name` string, 
`product_description` string, 
`product_price` double, 
`product_image` string)
COMMENT 'Imported by sqoop on 2017/07/05 05:52:43'
ROW FORMAT SERDE 
'org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe' 
WITH SERDEPROPERTIES ( 
'field.delim'='u0001', 
'line.delim'='n', 
'serialization.format'='u0001') 
STORED AS INPUTFORMAT 
'org.apache.hadoop.mapred.TextInputFormat' 
OUTPUTFORMAT 
'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
'hdfs://quickstart.cloudera:8020/user/hive/warehouse/retail_db.db/products_test'
TBLPROPERTIES (
'COLUMN_STATS_ACCURATE'='true', 
'numFiles'='4', 
'totalSize'='173993', 
'transient_lastDdlTime'='1499259177')
Time taken: 0.892 seconds, Fetched: 25 row(s)

目录/user/cloudera是导入数据的地方,这将由Hive和CREATE TABLE获取。因此,要在此目录中创建 Hive 表,您需要重新构建查询,例如

sqoop import --connect jdbc:mysql://localhost/retail_db --username root --password cloudera --target-dir /user/cloudera/retail_db/products_test --table products --hive-import  --create-hive-table  --hive-table --warehouse-dir /user/cloudera retail_db.products_test

我添加了仓库目录(--仓库目录(选项。希望对您有所帮助。

最新更新