组屋 table 比较
HDB table comparision
以问答形式发布此问题。
为什么 2 个相同表(其中一个从 HDB 中选择)之间的布尔匹配生成 0b
而不是 1b
?
q)trade:trade2:`sym`time xasc ([] sym:5?`apple`google;time:5?.z.t;price:100+5?1.)
q).Q.dpft[`:tmp;.z.d-1;`sym;`trade]
`trade
加载HDB
\l tmp/
q)hist:select from trade where date=.z.d-1
q)hist
date sym time price
---------------------------------------
2018.04.23 apple 02:31:39.330 100.2392
2018.04.23 apple 04:25:17.604 100.1508
2018.04.23 apple 07:57:14.764 100.2782
2018.04.23 google 02:59:16.636 100.1567
2018.04.23 google 14:35:31.860 100.9785
q)(`date xcols update date:.z.d-1 from trade2)
date sym time price
---------------------------------------
2018.04.23 apple 02:31:39.330 100.2392
2018.04.23 apple 04:25:17.604 100.1508
2018.04.23 apple 07:57:14.764 100.2782
2018.04.23 google 02:59:16.636 100.1567
2018.04.23 google 14:35:31.860 100.9785
Table 比较生成 false(0b
)
q)(`date xcols update date:.z.d-1 from trade2)~hist
0b
不匹配是由于从 HDB 选择的 table 的 sym
列 (20h
) 的类型。
\l tmp/
q)hist:select from trade where date=.z.d-1
q)type exec sym from hist
20h
q)type exec sym from trade2
11h
q)type exec value sym from hist
11h
虽然它看起来完全像符号但是有一个 new 类型 20h
,类似于下面的 (from Kx wiki)
q)type `city?city:`london`paris`rome
21h
使用 value
和 sym
得到想要的结果:
q)(`date xcols update date:.z.d-1 from trade2)~update value sym from hist
1b
以问答形式发布此问题。
为什么 2 个相同表(其中一个从 HDB 中选择)之间的布尔匹配生成 0b
而不是 1b
?
q)trade:trade2:`sym`time xasc ([] sym:5?`apple`google;time:5?.z.t;price:100+5?1.)
q).Q.dpft[`:tmp;.z.d-1;`sym;`trade]
`trade
加载HDB
\l tmp/
q)hist:select from trade where date=.z.d-1
q)hist
date sym time price
---------------------------------------
2018.04.23 apple 02:31:39.330 100.2392
2018.04.23 apple 04:25:17.604 100.1508
2018.04.23 apple 07:57:14.764 100.2782
2018.04.23 google 02:59:16.636 100.1567
2018.04.23 google 14:35:31.860 100.9785
q)(`date xcols update date:.z.d-1 from trade2)
date sym time price
---------------------------------------
2018.04.23 apple 02:31:39.330 100.2392
2018.04.23 apple 04:25:17.604 100.1508
2018.04.23 apple 07:57:14.764 100.2782
2018.04.23 google 02:59:16.636 100.1567
2018.04.23 google 14:35:31.860 100.9785
Table 比较生成 false(0b
)
q)(`date xcols update date:.z.d-1 from trade2)~hist
0b
不匹配是由于从 HDB 选择的 table 的 sym
列 (20h
) 的类型。
\l tmp/
q)hist:select from trade where date=.z.d-1
q)type exec sym from hist
20h
q)type exec sym from trade2
11h
q)type exec value sym from hist
11h
虽然它看起来完全像符号但是有一个 new 类型 20h
,类似于下面的 (from Kx wiki)
q)type `city?city:`london`paris`rome
21h
使用 value
和 sym
得到想要的结果:
q)(`date xcols update date:.z.d-1 from trade2)~update value sym from hist
1b