Filter spark DataFrame on string contains

Filter spark DataFrame on string contains

Asked on January 11, 2019 in Apache-spark.
Add Comment


  • 1 Answer(s)

    The problem can be solved by using contains and with help of arbitrary sequence, this works.

    df.filter($"foo".contains("bar"))
    

    like is used here:

    df.filter($"foo".like("bar"))
    

    Or rlike can be used ( Java regular expressions):

    df.filter($"foo".rlike("bar"))
    

    With the user needs like or rlike can be used.

    Answered on January 11, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.