Spark SQL,正则,regexp_replace

val simpleColors=Seq("black","white","red","green","blue")
val regexString=simpleColors.map(_.toUpperCase).mkString("|")
df.select(regexp_replace(col("Description"),regexString,"COLOR")
.as("color_clean"),col("Description"))
.show(2)
spark.sql("select regexp_replace(Description,'black|white|red|green|blue','COLOR') 
as color_clean,Description from dfTable ").show(2)
    原文作者:王社英
    原文地址: https://www.jianshu.com/p/268c12277a7f
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞