I have two tables: Table 1 (tb1): Shows which symbols belong to which blocks (1 = belongs, NULL = doesn't belong)
SYMBOL | block1 | block2 | block3 | block4
-------|--------|--------|--------|-------
sym1 | | | 1 |
sym2 | | 1 | | 1
sym3 | 1 | | |
sym4 | | | 1 |
sym5 | | | | 1
Table 2 (tb2): Contains three numerical features for some symbols (note: not all symbols are included)
SYMBOL | col1 | col2 | col3
-------|------|------|------
sym1 | 1.1 | 2.1 | 3.1
sym3 | 1.2 | 2.2 | 3.2
sym4 | 1.3 | 2.3 | 3.3
For each block in tb1:
Find all symbols marked with 1.
For those symbols, look up their feature values (col1, col2, col3) in tb2 (if they exist).
Calculate the inner product between:
- The weight vector (from tb1's block column)
- Each feature column (col1/col2/col3) from tb2
For example:
- block1: Only sym3 is marked → Use its values (1.2, 2.2, 3.2).
- block3: sym1 + sym4 → Sum their values: (1.1+1.3, 2.1+2.3, 3.1+3.3) = (2.4, 4.4, 6.4).
- block2/block4: Their symbols (sym2, sym5) aren’t in tb2 → Return empty.
Here is my expected output:
col1 col2 col3
---- ---- -----
block1| 1.2 2.2 3.2
block2|
block3| 2.4 4.4 6.4
block4|
How to implement this inner product calculation in DolphinDB?