Issue with REGEXP_EXTRACT function

▼魔方 西西 提交于 2019-12-13 08:25:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!