Trouble Using Complex Regex Expression in Athena via Metabase

Hello everyone,

I've been working on a native query in Athena that involves using a regex expression with Metabase. Here's the query I'm using:

select * from <table> where regexp_like(col_name, {{match_filter}})

The match_filter is a string filter, and it determines the results based on the regex match. When I use a simple string like 'trial_text' as the filter, everything works perfectly. However, when I try to use a more complex regex expression like '^(?!.\btrial_text\b).$', which is meant to exclude anything containing 'trial_text,' I encounter an error in Metabase. The error message is as follows:

[Simba][AthenaJDBC](100071) An error has been thrown from the AWS Athena client. line 49:46: mismatched input '^'. Expecting: ',', <expression> [Execution ID not available]

Strangely, the same query runs without any issues directly in Athena. It seems like there might be an issue with how Metabase handles complex expressions with special characters.

Could someone please assist me in resolving this issue?

Just to clarify the situation,

I have two queries:

  1. select * from t1 where regexp_like(col, 'trial_text')
    
  2. select * from t1 where regexp_like(col, '^(?!.*\btrial_text\b).*$')
    

I'm attempting to parameterize the second parameter using a text filter called match_filter like this:

select * from t1 where regexp_like(col, {{match_filter}})

The first query works perfectly fine when I use 'trial_text' as input. However, it's not working when I use '^(?!.\btrial_text\b).$' as input.