Strip or Regex function in Spark 1.3 Dataframe

后端 未结 1 1073
故里飘歌
故里飘歌 2021-01-24 00:13

I have some code from PySpark 1.5 that I unfortunately have to port backwards to Spark 1.3. I have a column with elements that are alpha-numeric but I only want the digits. An e

1条回答
  •  隐瞒了意图╮
    2021-01-24 00:55

    As long as you use HiveContext you can execute corresponding Hive UDFs either with selectExpr:

    df.selectExpr("regexp_extract(old_col,'([0-9]+)', 1)")
    

    or with plain SQL:

    df.registerTempTable("df")
    sqlContext.sql("SELECT regexp_extract(old_col,'([0-9]+)', 1) FROM df")
    

    0 讨论(0)
提交回复
热议问题