title: How to calculate product of columns followed by sum over all columns?
body: <p>Table 1 --Spark DataFrame table</p>
  
  <p><a href="https://i.stack.imgur.com/dwR2v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dwR2v.png" alt="enter image description here"></a></p>
  
  <p>There is a column called "productMe" in Table 1; and there are also other columns like a, b, c and so on whose schema name is contained in a schema array T.</p>
  
  <p>What I want is the inner product of columns(product each row of the two columns) in schema array T with the column productMe(Table 2). And sum each column of Table 2 to get Table 3.</p>
  
  <p>Table 2 is not necessary if you have good idea to get Table 3 in one step.</p>
  
  <p>Table 2  -- Inner product table</p>
  
  <p><a href="https://i.stack.imgur.com/xo8gX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xo8gX.png" alt="enter image description here"></a></p>
  
  <p>For example, the column "a·productMe" is (3*0.2, 6*0.6, 5*0.4) to get (0.6, 3.6, 2)</p>
  
  <p>Table 3 -- sum table</p>
  
  <p><a href="https://i.stack.imgur.com/CTsyh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CTsyh.png" alt="enter image description here"></a></p>
  
  <p>For example, the column "sum(a·productMe)" is 0.6+3.6+2=6.2.</p>
  
  <p>Table 1 is DataFrame of Spark, how can I get Table 3? </p>