I am trying to do a filter with wildcard, example: df.filter($"dst_ip"==="1.1.1.*")
. Somehow, when I do df.show()
, it returns blank. Is there an alternative on how to do wildcard filter on a dataframe?
Asked
Active
Viewed 3,880 times
3

MaxU - stand with Ukraine
- 205,989
- 36
- 386
- 419

user1342124
- 601
- 1
- 7
- 15
1 Answers
3
Why don't you use a contains
:
df.filter($"dst_ip".contains("1.1.1."))
Or if you want the string at the beginning, you can use the like
just as in SQL:
df.filter($"dst_ip".like("1.1.1.%"))

SCouto
- 7,808
- 5
- 32
- 49
-
1Thanks! I didn't understand the syntax at first. I got it now with your help above. – user1342124 Jan 28 '18 at 01:32