hive
上海外来务工人员甲
这个作者很懒,什么都没留下…
展开
-
2020-09-08
HIVE NULL值比较:SELECT IF(3 = NULL,1,0);+------+--+| _c0 |+------+--+| 0 |+------+--+SELECT IF(3 <> NULL,1,0) --结果也是0SELECT 3<>'' --NULLSELECT '3'<>''; --true结论:1.任何(包括NULL)和NULL进行比较的结果都为NULL2.和空字符串比较要用字符类型...原创 2020-09-08 09:43:33 · 86 阅读 · 1 评论 -
hive null值排序
create table udl.zgc_0903_test( name string, money string, update_time string);insert into table udl.zgc_0903_test values('AAA','200','2020-01-01 12:00:00'),('AAA','260','2020-02-01 12:00:00'),('BBB','100','2020-01-01 1原创 2020-09-03 15:48:21 · 996 阅读 · 1 评论 -
Hive的NULL值和空值关联小计
创建两个表,关联键有空值和null值CREATE TABLE GCZHU.ZGC_TEST_0708 ASSELECT 1001 AS ID,50 AS NUM UNION ALLSELECT '' AS ID,60 AS NUM UNION ALLSELECT NULL AS ID,70 AS NUM;CREATE TABLE GCZHU.ZGC_TEST_070802 ASSELECT 1001 AS ID,777 AS SCORE UNION ALLSELECT '' AS ID原创 2020-07-08 15:07:39 · 1698 阅读 · 0 评论 -
Hive修改表字段名,踩坑记录
Hive修改表字段名,踩坑记录:Hive修改表字段名,基于新模型的字段命名规范基本全部重命名:执行命令示例(其中一条命令): ALTER TABLE test.info_class change class_id id_class string;查询修改的字段内容时,全部为null,包括之前分区的数据修复办法: 1.创建一个临时表 tbl,结构为表info_class修改之前的表结构2.用Hdfs命令将info_class表下的目录拷贝到临时表下3.修复分区:msck repair table原创 2020-07-03 09:52:07 · 7373 阅读 · 1 评论 -
hive函数lateral view explode小实验
SELECT device_name,COO FROM( SELECT device_name,SPLIT(cont,',') AS cont FROM ( SELECT 'ALP-AL00' AS device_name,'a,b,c,d' AS cont UNION ALL SELECT 'BLN-AL10' AS device_name,'Q,W,E,R' AS con...原创 2018-10-26 16:24:03 · 292 阅读 · 0 评论 -
hive中关于SUM(COUNT(1))的用法实践测试用例
SELECT * FROM temp.tmp_20181026 T;+------------+-----------+-----------+----------+--+| t.classes | t.name | t.course | t.score |+------------+-----------+-----------+----------+--+| a1 ...原创 2018-10-26 16:30:45 · 2692 阅读 · 2 评论 -
hive优化之去distinct
count(distinct ),在数据量大的情况下,容易数据倾斜,因为count(distinct)是按group by 字段分组,按distinct字段排序。1.单个distinctSelect device_name,count(distinct imei) from TableA group by device_name;使用group by替换:Select device_na...原创 2018-10-26 17:03:49 · 1137 阅读 · 0 评论