最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

kdb+ - kdb update function with iteration - Stack Overflow

programmeradmin0浏览0评论

Im trying to have a function where the output becomes the input of the next iteration. I pass in the table called tab, and want to pass each threshold.

Here is the func:

test:{[data;t]
      
       data:update check:t`t3 from data where id within (t`t1;t`t2)
            
      }/[tab;]threshold
        

Data:

tab:([]id:12 130 44 46 456;side:`S`S`B`S`B;entityVal:123 123 456 456 456;eventType:`New`Filled`New`Partial`Partial)
threshold:([]t1:100 10 39 60 80 100 ;t2:200 20 49 70 90 150;t3:`test1`test2`test3`tes4`tes5`test6);

Can anyone advise what is the issue with the function? Its currently giving a rank: Invalid rank or valence (parameter count) error.

Im trying to have a function where the output becomes the input of the next iteration. I pass in the table called tab, and want to pass each threshold.

Here is the func:

test:{[data;t]
      
       data:update check:t`t3 from data where id within (t`t1;t`t2)
            
      }/[tab;]threshold
        

Data:

tab:([]id:12 130 44 46 456;side:`S`S`B`S`B;entityVal:123 123 456 456 456;eventType:`New`Filled`New`Partial`Partial)
threshold:([]t1:100 10 39 60 80 100 ;t2:200 20 49 70 90 150;t3:`test1`test2`test3`tes4`tes5`test6);

Can anyone advise what is the issue with the function? Its currently giving a rank: Invalid rank or valence (parameter count) error.

Share Improve this question edited Mar 4 at 15:48 kka asked Mar 4 at 15:39 kkakka 253 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

Your syntax runs without error in my console.

q)f:{[data;t] data:update check:t`t3 from data where id within (t`t1;t`t2)}

/ - https://code.kx/q/ref/accumulators/#unary-application

q)tab f/threshold
id  side entityVal eventType check
----------------------------------
12  S    123       New       test2
130 S    123       Filled    test6
44  B    456       New       test3
46  S    456       Partial   test3
456 B    456       Partial

/Same as
q)f/[tab;] threshold
id  side entityVal eventType check
----------------------------------
12  S    123       New       test2
130 S    123       Filled    test6
44  B    456       New       test3
46  S    456       Partial   test3
456 B    456       Partial

over - https://code.kx/q/ref/over/

q)f over enlist[tab],threshold
id  side entityVal eventType check
----------------------------------
12  S    123       New       test2
130 S    123       Filled    test6
44  B    456       New       test3
46  S    456       Partial   test3
456 B    456       Partial
发布评论

评论列表(0)

  1. 暂无评论