Hive建立外部表
CREATE EXTERNAL TABLE `table_name`(
`column1` string,
`column2` string,
`column3` string)
PARTITIONED BY (
`proc_date` string)
ROW FORMAT SERDE
'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat'
OUTPUTFORMAT
'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION
'hdfs://ns-hf/...'
TBLPROPERTIES ()TBLPROPERTIES (
'transient_lastDdlTime'='')
添加分区并加载分区数据:
alter table table_name add partition (proc_date='${hivevar:pdate}') location '...'(不改变源数据存储位置)
load data inpath '...' into table table_name partition(proc_date='${hivevar:pdate}');(会将源数据切到hive表指定的路径下)
删除分区:alter table table_name drop if exists partition(proc_date='${hivevar:pdate}');
from:https://blog.csdn.net/zx_blog/article/details/79128429
CREATE EXTERNAL TABLE IF NOT EXISTS dev.dev_test
(waybill_code string,
start_time string,
end_time string,
vehicle_number string,
carrier string
)
PARTITIONED BY (dt string)
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\t'
LOCATION 'hdfs://ns14/user/test/dev_test/';
alter table dev.dev_test add partition (dt='2021-05-14') location 'hdfs://ns14/user/test/dev_test/2021-05-14';
浙公网安备 33010602011771号