How do I cross-join a table with a list?
hive, join, sql
Solution
select a.*, b.val
from a lateral view explode(array(1,2,3,4)) b as val;
Problem
If I have a table `mytable` and a list ``` set vals = (1,2,3,4); ``` and I want to cross-join the table with the list (getting a new table which has 4 time as many rows as the original table and an extra `val` column), do I have a better option than creating an explicit temp table? What I can do is: ``` select a.*, b.val from mytable a cross join (select stack(4,1,2,3,4) as (val) from (select * from mytable limit 1) z) b; ``` EDIT: My main use case would be passing `-hiveconf vals='4,1,2,3,4'` to `hive` and replacing `stack(4,1,2,3,4)` with `stack(${hiveconf:vals})` in the above code.