How to create table that not with `timesym fields

95 views
Skip to first unread message

hzadonis

unread,
Aug 28, 2021, 11:15:17 AM8/28/21
to AquaQ kdb+/TorQ
Hi, Masters:
  I know that tickerplant.q has a tick function which check the table should be created with `timesym fields. But it is also has table that without the fields. I tried create table in the RDB session, such as set the "-schemafile rdbtable.q" in the start_TorQ.bat/sh file. There's no error but table not created.
  Why? my understanding is not match the designed solution? any other method? Thanks!

Regards
hzadonis

hzadonis

unread,
Aug 30, 2021, 2:12:19 AM8/30/21
to AquaQ kdb+/TorQ
One solution is modify the tick function in tickerplant.q file. 
There's "...each t..." to scan all tables created via database.q file, the purpose is make sure `time`sym fields in each table and `sym is group field. You can modify "...each (`quote`trade)...". Then other table without `time`sym structure can be created.
I'll test if there's other question.

hzadonis

unread,
Aug 30, 2021, 4:12:06 AM8/30/21
to AquaQ kdb+/TorQ
But comes a question is how to load csv file into the table? The function works fine out of the TorQ env.

Nick Ordonez

unread,
Sep 10, 2021, 2:14:48 AM9/10/21
to AquaQ kdb+/TorQ
Hi, 

The standard TorQ Tickerplant is based on the standard kdb+ Tick Tickerplant. With the standard TorQ TP, both a time field and sym field are required. Time is expected to be the first field in each message and will be added automatically if it's not present. Sym is required for subscriptions. One way to work around these requirements would be to, as you mentioned before, modify the code in tickerplant.q. However, you may find it easier to use the TorQ Segmented Tickerplant instead as it has the same functionality as the standard TP without these restrictions. 

You'll load segmentedtickerplant.q instead of tickerplant.q. By default, the segmented TP will look for a time field and add one to each message if it's not present, but you can get around this by modifying .stplg.updtab for each of the tables in $KDBAPPCONFIG/settings/segmentedtickerplant.q (example). Something like {[x;y] x}, where x is the incoming message and y is the current time, will work just fine. You'll want .stplg.updtab to look something like this for each of the relevant tables:

table1 | {[x;y] x}
table2 | {[x;y] x}
...

The flag -schemafile is only used to pass the schema information to the tickerplant on TP startup. By default, when the RDB starts up it retrieves the schema from the Tickerplant. If this isn't happening, check .rdb.schema on the RDB as it should be set to 1b. 

For loading a csv file into TorQ, you have a few options: load into a separate process and push it to the TP, load it directly into the RDB, or load it directly into the HDB. It mostly depends on what you want to do with it. Loading the actual data into a given process, whether its within TorQ or not, should follow the same steps

If loading from a separate process, you could do the following:
  1. Connect to the Tickerplant from the client process
  2. Load the csv file from the client process and save it as a table ( for example, table:("FFJJCCS";enlist",") 0: `:path/to/example.csv)
  3. From the client process, call upd on the TP and provide the name of the table you wish to push to as well as the table you created in step 2
  4. Check to make sure that the content of the csv was pushed to the subscribers 
If loading directly into the RBD, you can load the content of the csv as you would normally and then upsert it to a table:
  • `table upsert  ("FFJJCCS";enlist",") 0: `:path/to/example.csv
Thanks,

Nick

hzadonis

unread,
Jan 12, 2022, 2:48:41 AM1/12/22
to AquaQ kdb+/TorQ
Hi, Nick. Thank you. Let me try the method your mentioned. It seems easizer than tickplant.
Reply all
Reply to author
Forward
0 new messages