美文网首页
spark知识点

spark知识点

作者: lansane | 来源:发表于2017-06-16 08:31 被阅读0次

    1、自定义函数UDF

    import org.apache.spark.sql.functions._

    val myDF = sqlContext.parquetFile("hdfs:/to/my/file.parquet")

    val coder: (Int => String) = (arg: Int) => {if (arg < 100) "little" else "big"}

    val sqlfunc = udf(coder)

    myDF.withColumn("Code", sqlfunc(col("Amt")))

    2、自定义聚合函数UDAF

    http://www.jianshu.com/p/833b72adb2b6

    相关文章

      网友评论

          本文标题:spark知识点

          本文链接:https://www.haomeiwen.com/subject/kospqxtx.html