kdb - 组屋表比较
问题描述
以问答方式发布此问题。
为什么 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
加载组屋
\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
表比较生成 false( 0b
)
q)(`date xcols update date:.z.d-1 from trade2)~hist
0b
解决方案
不匹配是由于从 HDB 中选择的表的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
虽然它看起来完全像 symbol 但有一个新类型20h
,类似于以下内容(来自 Kx wiki)
q)type `city$10?city:`london`paris`rome
21h
使用value
withsym
来获得所需的结果:
q)(`date xcols update date:.z.d-1 from trade2)~update value sym from hist
1b
推荐阅读
- excel - Worksheet_change 事件和切片器过滤器连接冲突
- javascript - 如何使 JavaScript 注册验证与 example.php 文件一起使用?
- python - 将列表中的每个项目添加到字符串的循环
- java - 如何运行 akka grpc java 示例
- android - React Native - 从 android 内容 uri 获取文件名
- go - 从 ffmpeg image2pipe 保存连续的图像流
- react-native - 如何在 react-native 中编码字符串?
- python - 将列表项与对列表进行比较,并输出匹配对
- angular - NGRX 存储 - 服务器上的数据更改未应用于状态
- c# - 验证我收到的是否是整数