'Spark script cannot read "||" operator?

The code below suppose to filter the data contains string x or y. It works fine in spark shell, but when I run the script in bash it only finds the data contains y and ignored x.

val targetData= Namedata.filter(x => (x(1).contains(x)||x(1).contains(y)))

Anyone know how to fix this??

Thank you for your help



Solution 1:[1]

This code works:

val targetData= Namedata.filter(r => (r(1).contains(x)||r(1).contains(y)))

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 Tyler2P