目录
百战程序员,全站22050+开发课程+文档 ,学习精选优质好课快人一步!观看视频 快捷键ALT+N

大数据全系列 教程

1869个小节阅读:467.8k

收藏
全部开发者教程

408考研

JAVA全系列 教程

面向对象的程序设计语言

Python全系列 教程

Python3.x版本,未来主流的版本

人工智能 教程

顺势而为,AI创新未来

大厂算法 教程

算法,程序员自我提升必经之路

C++ 教程

一门通用计算机编程语言

微服务 教程

目前业界流行的框架组合

web前端全系列 教程

通向WEB技术世界的钥匙

大数据全系列 教程

站在云端操控万千数据

AIGC全能工具班

A

A A

White Night

阅读(214)
赞(0)

5.1.7 内置的聚合函数(UDAF)

多进一出:进来多个值,聚合后变成一个值。

返回类型函数说明
bigintcount(*) ,
count(expr), count(DISTINCT expr[, expr., expr.])
返回记录条数。
doublesum(col),
sum(DISTINCT col)
求和
doubleavg(col),
avg(DISTINCT col)
求平均值
doublemin(col)返回指定列中最小值
doublemax(col)返回指定列中最大值
doublevar_pop(col)返回指定列的方差
doublevar_samp(col)返回指定列的样本方差
doublestddev_pop(col)返回指定列的偏差
doublestddev_samp(col)返回指定列的样本偏差
doublecovar_pop(col1, col2)两列数值协方差
doublecovar_samp(col1, col2)两列数值样本协方差
doublecorr(col1, col2)返回两列数值的相关系数
doublepercentile(col, p)返回数值区域的百分比数值点。0<=P<=1,否则返回NULL,不支持浮点型数值。
arraypercentile(col, array(p~1,,\ [, p,,2,,]…))返回数值区域的一组百分比值分别对应的数值点。0<=P<=1,否则返回NULL,不支持浮点型数值。
doublepercentile_approx(col, p[, B])Returns an approximate p^th^ percentile of a numeric column (including floating point types) in the group. The B parameter controls approximation accuracy at the cost of memory. Higher values yield better approximations, and the default is 10,000. When the number of distinct values in col is smaller than B, this gives an exact percentile value.
arraypercentile_approx(col, array(p~1,, [, p,,2_]…) [, B])Same as above, but accepts and returns an array of percentile values instead of a single one.
array<struct{‘x’,'y’}>histogram_numeric(col, b)Computes a histogram of a numeric column in the group using b non-uniformly spaced bins. The output is an array of size b of double-valued (x,y) coordinates that represent the bin centers and heights
arraycollect_set(col)返回无重复记录

5.1.8 内置表生成函数(UDTF)

一进多出:进来一个值,经过处理变成多个值出去。

返回类型函数说明
数组explode(array a)数组一条记录中有多个参数,将参数拆分,每个参数生成一列。
 json_tupleget_json_object 语句:select a.timestamp, get_json_object(a.appevents, ‘$.eventid’), get_json_object(a.appenvets, ‘$.eventname’) from log a; json_tuple语句: select a.timestamp, b.* from log a lateral view json_tuple(a.appevent, ‘eventid’, ‘eventname’) b as f1, f2

案例演示:

 

北京市昌平区回龙观镇南店村综合商业楼2楼226室

©2014-2023 百战卓越(北京)科技有限公司 All Rights Reserved.

京ICP备14032124号-2