建表
create external table stg_log_xetlparse_error
(
err_id int
,err_source string
,act_id string
,data string
)
COMMENT '未被解析的埋點數據'
PARTITIONED BY (month STRING comment "按月的分區表字段",day string comment "按天的分區表字段")
ROW FORMAT DELIMITED
FIELDS TERMINATED BY '\001'
LINES TERMINATED BY '\n'
STORED AS TEXTFILE
LOCATION '/log_data/stg_log_xetlparse_error';
插入數據
insert into table stg_log_xetlparse_error PARTITION ( month='2018-01',day='2018-01-01')
select 1,"a","b","c"
在HDFS上的存儲目錄
[wenhuanhuan@task1-sandbox include]$ hadoop fs -text /log_data/stg_log_xetlparse_error/month=2018-01/day=2018-01-01/000000_0
1abc
[wenhuanhuan@task1-sandbox include]$ hadoop fs -ls /log_data/stg_log_xetlparse_error/month=2018-01
Found 2 items
drwxrwxr-x - wenhuanhuan bigdata 0 2018-05-30 17:21 /log_data/stg_log_xetlparse_error/month=2018-01/day=2018-01-01
drwxrwxr-x - wenhuanhuan bigdata 0 2018-05-30 17:27 /log_data/stg_log_xetlparse_error/month=2018-01/day=2018-01-02