About Hive create a partition directory and can be found in the three methods of data

About Hive create a partition directory and can be found in the three methods of data

1. Use the dfs -mkdir dfs -put create partitions and directories and upload data, respectively, performed at this time msck repair table table name command will be able to query the data

1. dfs -mkdir -p / user / hive / warehouse-master / pv_log / day = 20191115; Create directory partition

 

 2. dfs -put /opt/module/hiveTest/pv_15.log / user / hive / warehouse-master / pv_log / day = 20191115 / upload data to the local directory partition

 

3. The select * from pv_log where day = '20191115'; 20,191,115 not find the data that day

 

 

4. msck repair table pv_log; repaired after this statement, and then execute a query can query the data that day 20191115

 

 

2. Use the dfs -mkdir dfs -put create partitions and directories and upload data, respectively, then execute alter table table add partition (partition name directory) command can query the data

1. dfs -mkdir -p / user / hive / warehouse-master / pv_log / day = 20191116; partitions created directory, and using dfs -put /opt/module/hiveTest/pv_16.log / user / hive / warehouse-master / pv_log / day = 20191116 / upload data to the local directory partition

 

 2. Run the alter table pv_log add partition (day = '20191116'); the statement, query data can be

 

 3. dfs -mkdir create a partition directory, then execute the 'local data path where' load data local inpath into table table partition (partition directory name); the statement, query data can be

1. dfs -mkdir -p / user / hive / warehouse-master / pv_log / day = 20191117; Create directory partition

 

 2. load data local inpath '/opt/module/hiveTest/pv_17.log' into table pv_log partition (day = '20191117'); the statement after the loading data, the data can be queried

 

 

Guess you like

Origin www.cnblogs.com/zhangchenchuan/p/11870902.html