KDB附加具有不同列的表

时间:2017-06-01 08:58:06

标签: kdb q-lang

我有两个表,它们有一些共同的列和另一个表没有的一些列。

atab:flip `items`sales`prices`athing!(`anut`abolt`acam`acog;6 8 0 3;10 20 15 20; 50.2 32.6 1.18 -3.9)

btab:flip `items`sales`prices`bthing!(`bnut`bbolt`bcam`bcog;6 8 0 3;10 20 15 20; 1 0 0 1)

并且我正在尝试将它们组合在一起,以便列将它设置为两个表的并集,因此在我的情况下,列将是项目,销售,价格,athing,bthing以及初始表没有相应列的位置,充满了一些不适用的值

此处

失败
atab upsert btab

错误

ERROR:mismatch

有没有办法可以(轻松地)做到这一点?

1 个答案:

答案 0 :(得分:4)

q)atab uj btab
items sales prices athing bthing
--------------------------------
anut  6     10     50.2
abolt 8     20     32.6
acam  0     15     1.18  
acog  3     20     -3.9
bnut  6     10            1
bbolt 8     20            0
bcam  0     15            0
bcog  3     20            1

http://code.kx.com/q/ref/joins/#uj-ujf-union-join