问题
I have a field in a table being stored as such:
id (array<struct<peopleidl:string,householdidl:string>>)
So a sample result looks like this:
[{peopleidl=Xi3020rmDOhU2iWYUu3AXytMOggv6jdRK8_xyzy_COup1vd3uU0-OcWz4C3vW-ew9IeZEN, householdidl=null}]
I'm attempting to use the REGEXP_EXTRACT
function to capture everything between the =
sign and the ,
so the new field would simply be Xi3020rmDOhU2iWYUu3AXytMOggv6jdRK8_xyzy_COup1vd3uU0-OcWz4C3vW-ew9IeZEN
But when I try:
REGEXP_EXTRACT(idls, '=(.+),') AS id
The Regex part should be correct given what I tested here:
But when I run the query I'm met with this error:
SYNTAX_ERROR: line 1:8: Unexpected parameters (array(row(peopleidl varchar,householdidl varchar)), varchar(6), integer) for function regexp_extract. Expected: regexp_extract(varchar(x), JoniRegExp, bigint) , regexp_extract(varchar(x), JoniRegExp)
Does anyone know how I might be able to accomplish what I need?
回答1:
To be honest, I don't know why do you use regexp function to retrieve the data. You should just use dot notation and unnest function to do this.
https://docs.aws.amazon.com/athena/latest/ug/rows-and-structs.html
来源:https://stackoverflow.com/questions/51678474/issue-with-regexp-extract-function