hive匯入HDFS資料
HDFS檔案路徑:/user/test/qar_test.txt
檔案格式:***,***,***
建立hive表:
create table test_load(type STRING,num INT,time STRING)
partitioned by(name STRING) //分割槽
row format delimited
fields terminated by ',' //以逗號分隔
stored as TEXTFILE
匯入HDFS檔案資料:
load data inpath 'hdfs://Master:9000/user/test/qar_test'
into table test_load
partition (name=‘MH');
報錯:
FAILED: SemanticException Line 1:17 Invalid path ''hdfs://Master:9000/user/test/qar_test'': No files matching path hdfs://Master:9000/user/test/qar_test
路徑不對,這個就很奇怪了。我再查詢MySQL資料庫(我的hive元資料放在MySQL資料庫中,其它方法類似)。
查詢hive下的DBS表DB_LOCATION_URI列:select DB_LOCATION_URI from DBS;
+----------------------------------------+
| DB_LOCATION_URI |
+----------------------------------------+
| hdfs://10.1.51.200:9000/hive/warehouse |
+----------------------------------------+
所以我將匯入命令換成:
load data inpath 'hdfs://10.1.51.200:9000/user/test/qar_test'
into table test_load
partition (name=‘MH');
正確執行。