diff --git a/code/common/pubsub.q b/code/common/pubsub.q index a89c4a094..047b4bbe2 100644 --- a/code/common/pubsub.q +++ b/code/common/pubsub.q @@ -75,11 +75,12 @@ selfiltered:{[x;y] pub:{[t;x] if[not count x;:()]; if[count h:subrequestall[t];-25!(h;(`upd;t;x))]; - if[t in subrequestfiltered`tbl; - {[t;x] data:eval(?;t;x`filts;0b;x`columns);neg[x`handle](`upd;t;data)}[t;] - each select handle,filts,columns from subrequestfiltered where tbl=t - ]; - }; + if[t in .stpps.subrequestfiltered`tbl; + {[t;x;sels] data:eval(?;x;sels`filts;0b;sels`columns); + if[count data;neg[sels`handle](`upd;t;data)]}[t;x;] + each select handle,filts,columns from .stpps.subrequestfiltered where tbl=t + ]; + }; // publish and clear tables pubclear:{ diff --git a/tests/stp/TestCases.csv b/tests/stp/TestCases.csv index a26adacdd..3b462ff7f 100644 --- a/tests/stp/TestCases.csv +++ b/tests/stp/TestCases.csv @@ -7,6 +7,7 @@ RDB (or any Subscriber),Subscriptions,All Subscriptions,1.1.1,"Data is published ,,Update logs,1.1.6,"Data is published, it is saved in the log file",Update saved in log file,,MP,Done,subscription/subs.csv, ,,Error logs,1.1.7,"Bad update published, gets saved in error log",Bad update saved to log file,,MP,Done,subscription/subs.csv, ,,Filtered Subscription file missing ,1.1.8,Filtered sub file doesn't exist,Process fails to start,,MP,Done,subfile/subfilemissing.csv,is this one covered? +,,Publish only by filtered subsciptions,1.1.9,Subscriber subscribes with .u.sub[`table;`list`of`symbols],Consumer subscribes to specific list of sym data with only the specific data being published,,PK,In Progress,pubsub/pubsub.csv, RDB ,Recovery - single daily log file (tabperiod=`none),"RDB Restart, all subscriptions",2.1.1,"RDB subscribes for all data, is bounced",Data is the same in the RDB pre and post bounce,,AW,Done,recovery/recoverysinglelog.csv, ,,"RDB restart, sym subscriptions (using .rdb.subscribesyms variable)",2.1.2,"RDB subscribes to a subset of syms, is bounced",Data is the same in the RDB pre and post bounce,,AW,Done,recovery/recoverysinglelog.csv, ,,"RDB restart, complex filter using filtered subs functionality ",2.1.3,RDB subscribes to a subset of data using filtered functionality ,Data is the same in the RDB pre and post bounce,"These are similar to 2.1.1 but for this type of TP log file the TP may have multple log files, all of which should be replayed. So the set up should be: diff --git a/tests/stp/pubsub/pubsub.csv b/tests/stp/pubsub/pubsub.csv index b4902cbf9..7edf841be 100644 --- a/tests/stp/pubsub/pubsub.csv +++ b/tests/stp/pubsub/pubsub.csv @@ -37,4 +37,14 @@ run,0,0,q,psHandle(upsert;`trade;testtrade),1,,"Update trade table on pubsub" true,0,0,q,1~count psHandle(`trade),1,,"Check there is one row in trade table" run,0,0,q,neg[psHandle](`.stpps.pubclear;`trade),1,,"Call pubclear funtion" true,0,0,q,0~count psHandle(`trade),1,,"Check that trade table has been cleared" -true,0,0,q,1~.tst.upd,1,,"Check that local UPD function has been called" \ No newline at end of file +run,0,0,q,upd:upsert,1,,"Define upd for sub filter tests" +true,0,0,q,0~.tst.upd,1,,"Check that local UPD function has been called" +run,0,0,q,rdbHandle(`.u.sub;`trade;`AAPL`GOOG),1,,"Subscribe to filtered sym list" +run,0,0,q,rdbHandle"test:select from trade where i=(last;i)fby sym",1,,"Define set data to compare filter against" +run,0,0,q,rdbHandle".u.pub[`trade;test]",1,,"Force publish for the filtered list to check it is working as intended" +true,0,0,q,trade~rdbHandle"(select from test where sym in `AAPL`GOOG)",1,,"Check that published filtered sym list is same as select statement" +run,0,0,q,rdbHandle(`.u.sub;`trade;`AAPL`GOOG`MSFT),1,,"Re-subscribe with additional sym in the filtered sym list" +run,0,0,q,trade:0#trade,1,,"Empty local trade table to make sure nothing is in it before publishing filtered sym list" +run,0,0,q,rdbHandle".u.pub[`trade;test]",1,,"Force publish filter list again with updated sym list publishing to empty trade table" +true,0,0,q,trade~rdbHandle"(select from test where sym in `AAPL`GOOG`MSFT)",1,,"Check that updated published filtered sym list is same as select statement" +