'Write scala filter on data frame, a column should have more than two words

val tempDf = Df.filter(Df("column_1")==="200")

now wanted to filter tempDf on basis of one column (column_2) which should have more than 2 words.

val extractedDf = tempDf.filter(*)

How we can write the filter in scala at *.



Solution 1:[1]

You can use the size and split function.

val extractedDf = tempDf.filter(size(split($"column_2"," ")) > 2)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 过过招