Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-10-2023 12:53 AM
In Spark SQL, the CONTAINS function is not a built-in function.
As an alternative, you can use the below inbuilt functions
- LIKE function can be used to check whether a string contains a specific substring. The syntax is as follows:
Sample Code
SELECT * FROM table_name
WHERE column_name LIKE '%substring%'- INSTR function can be used to find the position of a substring within a string. If the substring is not found, the function returns 0. The syntax is as follows:
SELECT * FROM table_name WHERE INSTR(column_name, 'substring') > 0Or the good old Regex
SELECT * FROM table_name
WHERE column_name RLIKE 'regexp_pattern'Please let me know if this helps.