Thanks for your comment!
If I got it correctly, you would like to handle that your custom SQL functions returns an array.
Then you could register your function with your aimed return type with a BasicTypeReference instance.
private static final BasicTypeReference<String[]> RETURN_TYPE = new BasicTypeReference<>("string[]", String[].class, SqlTypes.ARRAY);
As an example, a function called array_first_and_last that gets the first and last elements of the array would be somehow like this in the post example:
select array[p.tags[1], p.tags[array_length(p.tags, 1)]]
from products p
where ...
After a correct registering and rendering implementation, you should be able to use it in a JPA repository as follows:
@Query("select array_first_and_last(p.tags) as array from Product p where p.sku = :sku")
String[] getFirstAndLastTagsBySku(@\Param("sku") String sku);
Hope it helps! Cheers 👍