kdb - 保护执行,2 例
问题描述
为什么在第一个受保护的情况下执行工作,但在第二个没有?:
q)t:([]a:1 2;b:3 4);
q)@[@[cols t; ; :; `bb]; (cols t)?`b; `columnNotFound]
`a`bb
q)@[@[cols t; ; :; `cc]; (cols t)?`c; `columnNotFound] // 1. works perfectly
`columnNotFound
q)@[@[cols t; (cols t)?`c; :; `cc]; `; `columnNotFound] // 2. exception does not handled
'length
[0] @[@[cols t; (cols t)?`c; :; `cc]; `; `columnNotFound]
^
更新:
嗯,我尝试后怀疑:
q)@[{@[cols t; (cols t)?`c; :; `cc]}; `; `columnNotFound]
`columnNotFound
解决方案
受保护的执行正在使用您提供的参数。前两个示例是预测,但最后一个不是,因此执行失败。
q){@[cols t;x;:;`bb]}(cols t)?`b
`a`bb
q){@[cols t;x;:;`cc]}(cols t)?`c / thrown into error trap
'length
[1] {@[cols t;x;:;`cc]}
^
q))\
q)@[cols t;(cols t)?`c;:;`cc] / fails on execution
'length
[0] @[cols t;(cols t)?`c;:;`cc]
^
q)
在您的upd中,将@
apply 设为函数会强制使用受保护执行中的参数。
q){@[cols t;(cols t)?`c;:;`cc]}`
'length
[1] {@[cols t;(cols t)?`c;:;`cc]}
^
q))
推荐阅读
- java - 深度复制模板类
- ios - JSONDecoder 无法解码 Array 但可以解码 String
- javascript - Vue.js 跨组件共享输入数据
- python - 如何让 Mypy 在 Callable 中识别类的协议成员资格?
- powershell - 为特定页面组合 pdftk 字符串
- .net - 对 .Net 4.0 的 TLS 1.3 支持
- python - kivy:如何从 FileChooserListView 中的所有项目中删除突出显示
- asp.net-core - masstransit 与 asp.net core 3.1 的集成
- java - Apache commons csv解析尝试读取集合大小后面的下一条记录
- php - 是否有一个 SQL 查询可以用来满足一组相当复杂的条件?