Spark SQL,正则替换,regexp_extract

val regexString1=simpleColors.map(_.toUpperCase).mkString("(","|",")")
df.select(regexp_extract(col("Description"),regexString1,1).as("color_clean"),
col("Description")).show(2)
spark.sql("select regexp_extract(Description,'(BLACk|WHITE|RED|GREEN|BLUE)',1),
Description from dfTable").show(2)
    原文作者:王社英
    原文地址: https://www.jianshu.com/p/4b5a6d70fb9d
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞