#1、Hive基本操作:查看dw.full_h_usr_base_user的详细信息,可以获取数据文件的存放路径desc formatted dw.full_h_usr_base_user;dfs -ls dfs -ls hdfs://BIGDATA:9000/user/hive/warehouse/dw.db/full_h_usr_base_user;删除外表full_h_usr_base_user的数据dfs -rmdir dfs -ls hdfs://BIGDATA:9000/user/hive/warehouse/dw.db/full_h_usr_base_user;
#192.168.1.181 192.168.1.1#2、创建带有map数据类型的外表create external table dw.full_h_usr_base_user(user_id string comment '用户id',reg_ip string comment 'ip',reg_ip_geo_map map<string,string> comment --map数据类型创建方法'city_id,city_name,isp,province_id,province_name,country_id,country_name,postzip,district,province')comment '用户测试表'partitioned by(ds string comment '当前时间,用于分区字段')row format delimitedfields terminated by '\t'collection items terminated by ","--map键值对逗号分割map keys terminated by ":"--map键值冒号分割stored as TEXTFILE;--存储为文本类型
#3、加载数据(指定user_id和reg_ip即可,reg_ip_geo_map可以通过UDF运算出来)load data local inpath '/opt/data/dw.full_h_usr_base_user.del'overwrite into table dw.full_h_usr_base_user partition(ds='2017-09-25');
hive之Python UDF函数操作map数据 详解 全是干货
最新推荐文章于 2024-06-12 14:06:37 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)