Hi folks, Is there any way to extract an array of ...
# troubleshooting
s
Hi folks, Is there any way to extract an array of a single column from an array of rows in flink SQL? I want to do something like below.
person_array
is an array of rows like
ARRAY<ROW< name string, age int > >
and I want to extract just the name fields into another array
ARRAY< string >
. I'd like to know if there's a way to do this with the built-in functions before writing a UDF
Copy code
SELECT
ARRAY[person_array.name] as person_names
FROM
  my_table
-- this is obviously wrong syntax
r
One way I can think is to apply UNNEST on the column, and then doing a ARRAY_AGG on the column, by applying group on the unique column
s
you mean
COLLECT
right? there is no
array_agg
in the flink SQL. I feel like there should be a simpler way to do this without unnest
r
Yep, ahh sorry abt that. I think I saw it in MySQL