Seems like I should be able to join a user defined table function to a select statement. Unfortunately I get an error. On review of other similar questions there was some talk about this being a bug in Snowflake that was fixed, but I do not know if that bugfix covered this exact case.
Note that for my application- assuming I can get past this error, I need to add many about 10 more input arguments and 10+ output values to the function, so a single output scalar function solution will NOT work.
create function tmp_fn(
dd float
,ostrat float
)
returns table (
urounded_soq float
) as
'
select
cast(dd * ostrat / cast(7 as float) as float) as unrounded_soq
'
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.*
,f.*
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.*
,f.*
from test_fn t
join table(tmp_fn(cast(t.dd as float),cast(t.ostrat as float))) f
;
Noted that according to:
select current_version();
my snowflake version is 4.19.2