老熟女激烈的高潮_日韩一级黄色录像_亚洲1区2区3区视频_精品少妇一区二区三区在线播放_国产欧美日产久久_午夜福利精品导航凹凸

重慶分公司,新征程啟航

為企業提供網站建設、域名注冊、服務器等服務

云計算大數據學習路線課程大綱資料:hive內部函數

今天給大家分享一些云計算大數據學習路線課程大綱資料,這篇文章是關于hive內部函數的一些學習筆記資料,希望能給大家一些幫助:

成都創新互聯公司主營寧陜網站建設的網絡公司,主營網站建設方案,成都APP應用開發,寧陜h5微信平臺小程序開發搭建,寧陜網站營銷推廣歡迎寧陜等地區企業咨詢

云計算大數據學習路線課程大綱資料:hive內部函數

hive內部函數

1、取隨機數函數:rand()

語法 : rand(),rand(int seed) 返回值 : double 說明 : 返回一個0到1范圍內的隨機數。如果指定seed,則會得到一個穩定的隨機數序列

select rand();

select rand(10);

2、分割字符串函數:split(str,splitor)

語法 : split(string str, string pat) 返回值 : array 說明 : 按照pat字符串分割str,會返回分割后的字符串數組,注意特殊分割符的轉義

select split(5.0,"\.")[0];

select split(rand(10)*100,"\.")[0];

3、字符串截取函數:substr,substring

語法 : substr(string A, int start),substring(string A, int start) 返回值 : string 說明 :返回字符串A從start位置到結尾的字符串

語法 : substr(string A, int start, int len),substring(string A, int start, int len) 返回值 : string 說明 :返回字符串A從start位置開始,長度為len的字符串

select substr(rand()*100,0,2);

select substring(rand()*100,0,2);

4、If函數:if

語法 : if(boolean testCondition, T valueTrue, T valueFalseOrNull) 返回值 : T 說明 : 當條件testCondition為TRUE時,返回valueTrue;否則返回valueFalseOrNull

select if(100>10,"this is true","this is false");

select if(2=1,"男","女");

select if(1=1,"男",(if(1=2,"女","不知道")));

select if(3=1,"男",(if(3=2,"女","不知道")));

5、條件判斷函數:CASE

第一種格式:

語法 : CASE WHEN a THEN b [WHEN c THEN d]* [ELSE e] END 返回值 : T 說明 :如果a為TRUE,則返回b;如果c為TRUE,則返回d;否則返回e

第二種格式:

語法 : CASE a WHEN b THEN c [WHEN d THEN e]* [ELSE f] END 返回值 : T 說明 :如果a等于b,那么返回c;如果a等于d,那么返回e;否則返回f

select

case 6

when 1 then "100"

when 2 then "200"

when 3 then "300"

when 4 then "400"

else "others"

end

;

##創建表

create table if not exists cw(

flag int

)

;

load data local inpath '/home/flag' into table cw;

##第一種格式

select

case c.flag

when 1 then "100"

when 2 then "200"

when 3 then "300"

when 4 then "400"

else "others"

end

from cw c

;

##第二種格式

select

case

when 1=c.flag then "100"

when 2=c.flag then "200"

when 3=c.flag then "300"

when 4=c.flag then "400"

else "others"

end

from cw c

;

6、正則表達式替換函數:regexp_replace

語法 : regexpreplace(string A, string B, string C) 返回值 : string 說明 :將字符串A中的符合java正則表達式B的部分替換為C。注意,在有些情況下要使用轉義字符,類似oracle中的regexpreplace函數

select regexp_replace("1.jsp",".jsp",".html");

7、類型轉換函數: cast

語法 : cast(expr as ) 返回值 : Expected "=" to follow "type" 說明 : 返回轉換后的數據類型

select 1;

select cast(1 as double);

select cast("12" as int);

8、字符串連接函數:concat;帶分隔符字符串連接函數:concat_ws

語法 : concat(string A, string B…) 返回值 : string 說明 :返回輸入字符串連接后的結果,支持任意個輸入字符串

語法 : concat_ws(string SEP, string A, string B…) 返回值 : string 說明 :返回輸入字符串連接后的結果,SEP表示各個字符串間的分隔符

select "千峰" + 1603 + "班級";

select concat("千峰",1603,"班級");

select concat_ws("|","千峰","1603","班級");

9、排名函數:

rownumber(): 名次不并列 rank():名次并列,但空位 denserank():名次并列,但不空位

##數據

id class score

1 1 90

2 1 85

3 1 87

4 1 60

5 2 82

6 2 70

7 2 67

8 2 88

9 2 93

1 1 90 1

3 1 87 2

2 1 85 3

9 2 93 1

8 2 88 2

5 2 82 3

create table if not exists uscore(

uid int,

classid int,

score double

)

row format delimited fields terminated by '\t'

;

load data local inpath '/home/uscore' into table uscore;

select

u.uid,

u.classid,

u.score

from uscore u

group by u.classid,u.uid,u.score

limit 3

;

select

u.uid,

u.classid,

u.score,

row_number() over(distribute by u.classid sort by u.score desc) rn

from uscore u

;

取前三名

select

t.uid,

t.classid,

t.score

from

(

select

u.uid,

u.classid,

u.score,

row_number() over(distribute by u.classid sort by u.score desc) rn

from uscore u

) t

where t.rn < 4

;

查看三個排名區別

select

u.uid,

u.classid,

u.score,

row_number() over(distribute by u.classid sort by u.score desc) rn,

rank() over(distribute by u.classid sort by u.score desc) rank,

dense_rank() over(distribute by u.classid sort by u.score desc) dr

from uscore u

;

10.聚合函數:

min() max() count() count(distinct ) sum() avg()

count(1):不管正行有沒有值,只要出現就累計1 count(*):正行值只要有一個不為空就給類計1 count(col):col列有值就累計1 count(distinct col):col列有值并且不相同才累計1

11.null值操作

幾乎任何數和 NULL操作都返回NULL

select 1+null;

select 1/0;

select null%2;

12.等值操作

select null=null; #null

select null<=>null;#true


網站標題:云計算大數據學習路線課程大綱資料:hive內部函數
文章鏈接:http://www.xueling.net.cn/article/gisosj.html

其他資訊

在線咨詢
服務熱線
服務熱線:028-86922220
TOP
主站蜘蛛池模板: 色妹子综合网 | 99久久人妻精品免费二区 | 国产视频一区在线播放 | 亚洲区精品3d国漫同人 | 色爱区综合 | 久久ww| 十次啦综合怡春院 | 亚洲激情四射视频中文字幕久久 | 91桃色成人wangxhab | 在线欧美国产 | 97影院在线免费看 | 国产美女网站视频 | 91天天综合 | 1000部精品久久久久久久久 | 亚洲一区二区 | 精品视频一区二区三区中文字幕 | 国产极品粉嫩福利在线观看 | 欧美一区二区三区日本 | 黄色一级片免费的 | 免费一级欧美在线观看视频 | 少妇无码一区二区三区 | 成人精品久久一区二区三区 | 亚洲Av无码国产精品色午 | 一本一道色欲综合网 | 久久亚洲春色中文字幕久久久 | 国模少妇一区二区三区 | 日美一区二区 | 台湾佬成人 | 国产精品高清视亚洲乱码 | 日本公妇被公侵犯中文字幕2 | 国产日韩精品视频 | 一区二区三区国 | 51国偷自产一区二区三区的 | 久久久中日AB精品综合 | 久视频精品线在线观看的录制功能 | AV大片在线无码永久免费 | 韩国理伦伦片在线观看 | 亚洲一区二区制服在线 | 综合色综合 | 国产精品自在拍视频首页 | 亚洲AV中文无码乱人伦在线咪咕 |