首页 > 其他 > 详细

[Hive_add_7] Hive 实现最高气温统计

时间:2019-01-05 18:06:44      阅读:125      评论:0      收藏:0      [点我收藏+]

 0. 说明

  Hive 通过 substr() 函数实现最高气温统计

 


1. Hive 实现最高气温统计

  1.1 思路

  将一行文本加载为 String

  通过 substr() 函数截取年份和温度

  1.2 实现

  1. 创建 temp 表

create table temp(line string);

 

  2. 加载气温数据到 temp 表中

load data local inpath /home/centos/files/temp into table temp;

 

  3. 编写 SQL 语句

select year, max(temperature) from (select substr(line,16,4) as year, cast(substr(line,88,5) as int) as temperature from temp) a where temperature != 9999 group by year;

 

  类型转换  cast(temperature as int);

 


 

[Hive_add_7] Hive 实现最高气温统计

原文:https://www.cnblogs.com/share23/p/10224093.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!