Spark udf,udaf
来源:互联网 发布:淘宝上迷彩服是正品吗 编辑:程序博客网 时间:2024/05/22 04:59
udf
def filterTdWithOp(operator: String): Boolean = { val x = ".*中国联通.*" val y = ".*CHN-UNICOM.*" val z = ".*China Unicom.*" if (operator!=null && operator.matches(x + "|" + y + "|" + z)) true else false }sqlContext.udf.register("filterTdWithOp", filterTdWithOp _)td.registerTempTable("td")val tdOp = sqlContext.sql("select *,filterTdWithOp(operator) as fiOp from td").filter("fiOp = true")
udaf
去看官网比较好
object MaxPoint extends Aggregator[Input,Input, Input] {override def zero: Input = Input(0,0,0,"") // Combine two values to produce a new value. For performance, the function may modify `buffer` // and return it instead of constructing a new object override def reduce(b: Input, a: Input): Input = { if(b.pointNum>a.pointNum) b else a } // Merge two intermediate values override def merge(b: Input, a: Input): Input = { if(b.pointNum>a.pointNum) b else a } override def finish(reduction: Input): Input = reduction}
spark2.0之后引入了两个新方法
阅读全文
0 0
- Spark udf,udaf
- Spark SQL UDF和UDAF示例
- 第72课:Spark UDF和UDAF解密学习笔记
- 如果在SPARK函数中使用UDF或UDAF
- [2.5]详解spark sql用户自定义函数:UDF与UDAF
- 详解spark sql用户自定义函数:UDF与UDAF
- 详解spark sql用户自定义函数:UDF与UDAF
- Spark 之 Spark SQL源码函数解读及UDF/UDAF例子 spark研习第六集
- Hive UDF与UDAF
- udf udaf udtf
- HIVE UDF/UDAF/UDTF
- hive UDF UDAF
- hive udf 与udaf
- hive udf \udaf\udtf
- hive udf和udaf
- Hive Udf 与Udaf
- hive UDF UDAF
- hive UDF UDAF
- 几张GIF看ConstraintLayout的特新
- python基础学习一——基础要素
- hadoop之Configuration.java
- 比特币源码解析(1)
- H5网站模板——前台和后台
- Spark udf,udaf
- 最短路之SPFA模板
- Pycharm2016.2.x激活方法
- Android-学习记录(1)
- Dubbo相关知识
- ubuntu 查看apt-get有哪些软件
- HDU
- Web安全工程师
- ActiveMQ