Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

KDB\Q: How to run an iterative union join from within a ticker function?

Tags:

kdb

I am trying to run an iterative union join on a table from within a tick function according to the kdb tick architecture as follows:

table1:([]time:`timespan$();sym:`symbol$();var1:`float$());

if[not system"t";system"t 1000";
    .z.ts:{
        table2: ...
        table1:table1 uj table2 / throws non descriptive error
        `table1 uj table2 / throws type error
    }

non descriptive error:

'table1
[0] ()

I am trying to maintain a local table that keeps the last 500 or so rows (with dynamic columns) in order to run further processing. However I can't seem to update the table from within the tick function. How should one implement this functionality? Thanks

like image 569
James Avatar asked Dec 31 '22 16:12

James


1 Answers

You are getting 'table1 as an error as it is not defined locally within .z.ts. In kdb if there is local assignment to a specific variable within a function, kdb references that variable locally within the function. In the example of table1 you assign it locally within .z.ts but then attempt to reference table1 which you assigned globally outside of .z.ts. To fix your issue you must assign table1 globally within .z.ts like so table1::table1 uj table2.

table1:([]time:`timespan$();sym:`symbol$();var1:`float$());

if[not system"t";system"t 1000";
    .z.ts:{
        table2: ...
        table1::table1 uj table2

like image 94
Matt Moore Avatar answered May 16 '23 08:05

Matt Moore