我还不知道为什么会出现不受支持的子查询类型错误,但如果将其转换为Javascript UDTF,则效果良好:
create or replace function tmp_fn(
DD float
,OSTRAT float
)
returns table (UROUNDED_SOQ float)
language javascript
as
$$
{
processRow: function (row, rowWriter, context){
rowWriter.writeRow({UROUNDED_SOQ: (row.DD * row.OSTRAT) / 7});
}
}
$$;
create or replace temporary table test_fn as
select 6 dd, 9 ostrat
union all
select 12 dd,38 ostrat
;
--this works, but of course because the argument values are hardcoded, this is useless to my application.
select
t.DD, t.OSTRAT
,f.UROUNDED_SOQ
from test_fn t
join table(tmp_fn(cast(6 as float),cast(9 as float))) f
;
--this does not work, this is the error "SQL compilation error: Unsupported subquery type cannot be evaluated"
select
t.DD, t.OSTRAT
,urounded_soq
from test_fn t, lateral(table(tmp_fn(t.dd::float,t.ostrat::float)))
;