Quantcast
Channel: Active questions tagged aws-lambda - Stack Overflow
Viewing all articles
Browse latest Browse all 3993

Redshift query with regexp_replace works in Redshift console but not Python lambda

$
0
0

One of the fields in my Redshift table is structured like {event_type} 2024-01-01, so I am using regexp_replace to remove the date from the event type. I am calling Redshift via a Python Lambda like this

client = boto3.client("cluster-name", aws_region, aws_access_key_id, aws_secret_access_key, aws_session_token)query = """    select id, regexp_replace(event_type, '\\s+\\d{4}-\\d{2}$', '') as event    from table"""

But the regex expression does not work, all results returned by the query still have the date attached.

However, if I try the query in the Redshift console, the field is transformed correctly.

I assumed it was something to do with the \\s and the escape characters, I tried it with three and four slashes instead of two, but that didn't work


Viewing all articles
Browse latest Browse all 3993

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>