如何有效地从多个表和动态列的表中排除浮点数和整数列表的非空值

问题描述 投票:0回答:1

如何有效地从多个表和动态列的表中排除浮点数和整数列表的非空值

tab1:update volume:0n from ([] date:2024.01.01+til 10;sym:10?`appl`msgt`googl;volume:10#(enlist 0.5+300?til 100);price:10?10.5) where i in (1;5;8);

tab2:update price:0n from ([] date:2024.01.01+til 10;sym:10?`appl`msgt`googl;spread:10#(enlist 0.5+300?til 100);price:10?10.5) where i in (1;5;8);

//columns to check
(`tab1;`volume`price);
(`tab2;`spread`price);

我们如何有效地检查每个表的上述列是否存在空值。

如果列表中 tab1 中的任何一列为空,那么我们不想显示该行。 示例:从 tab1 中选择,其中成交量不为空且价格不为空 // 这里成交量的类型为 float list,价格为 float。

注意:表可以是任意数量的表和任意数量的列,我们需要检查的列类型可以是 int、float、list of int、list if float。

enter image description here

enter image description here

kdb
1个回答
0
投票

有这样的事吗?

q)select from tab1 where not any each null volume,not any each null price
date       sym   volume                                  ..
---------------------------------------------------------..
2024.01.01 appl  84.5 63.5 93.5 54.5 38.5 97.5 88.5 58.5 ..
2024.01.03 msgt  84.5 63.5 93.5 54.5 38.5 97.5 88.5 58.5 ..
2024.01.04 msgt  84.5 63.5 93.5 54.5 38.5 97.5 88.5 58.5 ..
2024.01.05 msgt  84.5 63.5 93.5 54.5 38.5 97.5 88.5 58.5 ..
2024.01.07 googl 84.5 63.5 93.5 54.5 38.5 97.5 88.5 58.5 ..
2024.01.08 appl  84.5 63.5 93.5 54.5 38.5 97.5 88.5 58.5 ..
2024.01.10 appl  84.5 63.5 93.5 54.5 38.5 97.5 88.5 58.5 ..
q)parse"select from tab1 where not any each null volume,not any each null price"
?
`tab1
,((~:;(k){x'y};max$["b"];(^:;`volume)));(~:;(k){x'y};max$..
0b
()
q)({?[x;{(not;(each;any;(null;x)))}each y;0b;()]}.(`tab1;`volume`price))~select from tab1 where not any each null volume,not any each null price
1b

这应该适用于多个表/列

q){?[x;{(not;(each;any;(null;x)))}each y;0b;()]}.'((`tab1;`volume`price);(`tab2;`spread`price))
+`date`sym`volume`price!(2024.01.01 2024.01.03 2024.01.04..
+`date`sym`spread`price!(2024.01.01 2024.01.03 2024.01.04..
© www.soinside.com 2019 - 2024. All rights reserved.