I am getting error 'cast
when I try to union join (uj
) two very simple, five row tables in KDB+.
What is the cause of the error in the below code?
q)t1b
Symbol | RIC
---------| ---------
000001.SZ| 000001.SZ
000001.ZK| 000001.ZK
000002.SZ| 000002.SZ
000002.ZK| 000002.ZK
000004.SZ| 000004.SZ
q)t2b
Symbol| RIC
------| ------
1301 | 1301.T
1332 | 1332.T
1333 | 1333.T
1334 | 1334.T
1352 | 1352.T
q)meta t1b
c | t f a
------| -----
Symbol| s
RIC | s
q)meta t2b
c | t f a
------| -----
Symbol| s
RIC | s
q)keys t1b
,`Symbol
q)keys t2b
,`Symbol
q)t1b uj t2b
k){+.[x;(!+y;i);:;.+y z i:&z<#y]}
'cast
q))
If I strip the primary key, join, then re-apply primary key, it works. But why? Surely, I am missing something fundamental about KDB+ here.
q)tuj: `Symbol xkey (() xkey t1b) uj (() xkey t2b)
q)tuj
Symbol | RIC
---------| ---------
000001.SZ| 000001.SZ
000001.ZK| 000001.ZK
000002.SZ| 000002.SZ
000002.ZK| 000002.ZK
000004.SZ| 000004.SZ
1301 | 1301.T
1332 | 1332.T
1333 | 1333.T
1334 | 1334.T
1352 | 1352.T
q)meta tuj
c | t f a
------| -----
Symbol| s
RIC | s
q)keys tuj
,`Symbol