0

My scala dataframe has a column that has the datatype array(element: String). I want to display those rows of the dataframe that has the word "hello" in that column.

I have this:

display(df.filter($"my_column".contains("hello")))

I get an error because of data mismatch. It says that argument 1 requires string type, however, 'my:column' is of array<string> type.

1
  • try array_contains function Commented Sep 7, 2018 at 11:53

1 Answer 1

1

You can use array_contains function

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

df.filter(array_contains(df.col("my_column"), "hello")).show
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.