How would I got about passing an ARRAY of STRUCTS into my user-defined function (using standard SQL)?
Firstly, a bit of context:
Table schema:
id STRING
customer STRING
request STRUCT<
headers STRING
body STRING
url STRING
>
response STRUCT<
size INT64
body STRING
>
outgoing ARRAY<
STRUCT<
request STRUCT<
url STRING,
body STRING,
headers STRING
>,
response STRUCT<
size INT64,
body STRING
>
>
>
User-defined function:
CREATE TEMPORARY FUNCTION extractDetailed(
customer STRING,
request STRUCT<
headers STRING,
body STRING
>,
outgoing ARRAY<
STRUCT<
request STRUCT<url STRING>,
response STRUCT<body STRING>
>
>
)
RETURNS STRING
LANGUAGE js AS """
""";
SELECT extractDetailed(customer, STRUCT(request.headers, request.body), outgoing)
FROM request_logs
As for my problem: I can't seem to figure out how to select part of the outgoing
ARRAY, and pass it to the user-defined function as an array.
Effectively, I'm trying to simulate the following user-defined function call:
extractDetailed(
"customer id",
{ "headers": "", "body": "" },
[
{
"request": { "url": "" },
"response": { "body": "" }
},
{
"request": { "url": "" },
"response": { "body": "" }
}
]
);
I have recently stumbled across some documentation that might help unlock it, I just can't seem to figure out how to make it fit. I'm really struggling with this, and would appreciate any help in resolving it.