Databricks SQL Wildcard Operator Not Parsed Correctly
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 02:37 AM
Hello there,
Wasn't sure if this was just an error on my part, but I'm using a Databricks Pro SQL warehouse and unity catalogue to pull some data from my tables. I'm having this issue where whenever I try and use a wildcard operator with my LIKE clause, I'm getting a Parse error.
When I write a query like SELECT * FROM table_name WHERE column_name LIKE 'string' it works fine. But when I include a wildcard operator in my query, SELECT * FROM table_name WHERE column_name LIKE 'string%', then it throws a parse error. Specifically the error says, Parse error at line: 1, column: 3620: Incorrect syntax near ''%string%'', with the string portion surrounded by two single quotes.
My column is a string column in the table. Anyone else experience something similar?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 03:59 AM
Is this only happening with Pro warehouse, if you test with Serverless for example does it work? I have tested using syntax
SELECT * FROM table_name WHERE column_name LIKE 'string%' and it has worked as expected for me on Serverless.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2024 04:10 AM
My organization doesn't have serverless SQL enabled, so I'm not able to try that out. But I did try a query with a wildcard operator on a different table and Pro warehouse and it worked like expected. Looks like it might be an issue with the table itself.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2025 01:41 AM
Hi @nomnomnom543 ,
Try this SELECT * FROM table_name WHERE LEFT(column_name, LENGTH('string')) = 'string';

