databricks SQL UDF in select statement

pepco
New Contributor III

In the Unity Catalog we can now create/register SQL UDFs. There are two types - one that returns table and other that returns just a value. If the function that returns value is based on the SQL query and joins it would in standard relational databases represent a correlated query executed for each row - which is usually a code smell in the relational databases. 

A very simple example (I just made it up):

select b.value
from table1 a
join table2 b
   on 1 = 1
   and b.col = a.id
   and b.col = p_parameter1
join table 3 c
   on 1 = 1
   and c.col = p_parameter2
   and ...


The function that returns single value based on simple logic; i.e. based on the input parameters is during execution extrapolated into the query. Basically, it's super helpful for hiding complex case statements or amounts recalculation using the same logic.

Since Databricks is using columnar storage, how does it behave for functions that contain joins? Does it also expand the underlying query into the main query? If yes, does it mean that for every row it adds underlying query?