I have the following datasets:
User Table
+-------+---------+
|user_id| value|
+-------+---------+
| user1|[1, 2, 3]|
| user2|[4, 5, 6]|
| user3|[7, 8, 9]|
+-------+---------+
Items Table
+---------------+---------------+---------------+
| item1| item2| item3|
+---------------+---------------+---------------+
|[0.5, 0.6, 0.7]|[0.2, 0.3, 0.4]|[0.1, 0.8, 0.9]|
+---------------+---------------+---------------+
I want to generate the following DS by multiplying UsersXItems
+-------+-----+-----+-----+
|user_id|item1|item2|item3|
+-------+-----+-----+-----+
| user1| 3.8| 2| 4.4|
| user2| 9.2| 4.7| 9.8|
| user3| 14.6| 7.4| 15.2|
+-------+-----+-----+-----+
I was initially thinking on a cross join to get all fields together and then doing the multiplication row by row and column by column but that seems like the wrong approach (and a very slow and memory-intensive process).
Is there a better approach I should use?
I'm using Scala and Spark 3.1