立即注册 登录
About云-梭伦科技 返回首页

SuperDove的个人空间 https://www.aboutyun.com/?47062 [收藏] [复制] [分享] [RSS]

日志

spark sql自定义udf

已有 1251 次阅读2017-8-21 13:08 |个人分类:spark

import org.apache.spark.sql.functions._
val convert = udf((str:String) =>
"1"
)
val df = hiveContext.sql("")
val df2 = hiveContext.sql("select 1 as time")
hiveContext.udf.register("convert",((str:String) =>
if(str.substring(5,7).toInt>=1 && str.substring(5,7).toInt<=3) "1"
))
df.withColumn("",df2("time").substr(1,2))
.withColumn("",convert(df2("")))

路过

雷人

握手

鲜花

鸡蛋

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 立即注册

关闭

推荐上一条 /2 下一条