You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
They can be emulated using correlated subqueries that UNNEST and ARRAY_AGG the array in order to use ordinary SQL to MAP (SELECT), FILTER (WHERE), etc.
When combining such array lambda functions, such as ARRAY_MAP(ARRAY_FILTER(...)), the current emulation isn't aware of the combination and produces such beasts (using kotlin):
select(array("1", "2", "3", "4").map { s -> s.cast(INTEGER) } .anyMatch { i -> i.mod(2).ne(0) })
Produces this monster in PostgreSQL:
select (case
when (
select coalesce(
array_agg(cast(e asint)),
case
when array['1', '2', '3', '4'] is not null then cast(array[] asint[])
end
)
from unnest(array['1', '2', '3', '4']) as t (e)
) is not null then exists (
select1as"one"from unnest((
select coalesce(
array_agg(cast(e asint)),
case
when array['1', '2', '3', '4'] is not null then cast(array[] asint[])
end
)
from unnest(array['1', '2', '3', '4']) as t (e)
)) as t (e)
where mod(e, 2) <>'0'
)
end)
When it should instead generate this:
select (case
when array['1', '2', '3', '4'] is not null then exists (
select1as"one"from unnest(array['1', '2', '3', '4']) as t (e)
where mod(cast(e asint), 2) <>0
)
end)
The text was updated successfully, but these errors were encountered:
jOOQ 3.20 added support for array lambda functions:
They can be emulated using correlated subqueries that
UNNEST
andARRAY_AGG
the array in order to use ordinary SQL toMAP
(SELECT
),FILTER
(WHERE
), etc.When combining such array lambda functions, such as
ARRAY_MAP(ARRAY_FILTER(...))
, the current emulation isn't aware of the combination and produces such beasts (using kotlin):Produces this monster in PostgreSQL:
When it should instead generate this:
The text was updated successfully, but these errors were encountered: