2021.11.29 09:34 AM
Hey, I am having an issue with the Fundamentals Capstone course (on Developer) with trying to obtain the unique option IDs from the trade table in part 1. I have loaded the trade table from the partitioned database using the table importer.
I am using the following code but I am getting a par error - unable to operate on a partitioned table.
q code: uniqueOpts:distinct trade`option_id
Does anyone have any thoughts on how to answer this?
Thanks 🙂
2021.11.29
10:44 AM
- last edited on
2021.12.03
03:42 AM
by
LeahS
exec won't work on a partitioned table directly. Need to have a select statement first.
exec option_id from select distinct option_id from trade
I would also recommend starting with qSQL before moving on to functional qSQL.
QSQL query templates | Basics | kdb+ and q documentation - Kdb+ and q documentation (kx.com)
2021.11.29 10:32 AM - edited 2021.12.03 03:46 AM
Hello,
Thanks for sharing this with the community. Great content!
I believe the error generated is a result of your method for retrieving the unique OptionIDs. Given your table is partitioned, this method of taking columns from tables will not work . Hence the 'unable to operate on a partitioned table' error.
I suggest querying the table, meaning avail of Functional qSQL Statements as an alternate approach to obtain the unique OptionIDs from the trade table.
Functional qSQL information can be studied here: https://code.kx.com/q/basics/funsql/
Specifically focus your attention on the functional form 'exec' https://code.kx.com/q/ref/exec/
In summary, rather than
uniqueOpts:distinct trade`option_id
Create uniqueOpts by following the syntax below (provided in the previous link) where square brackets mark optional elements. This is what we refer to as 'querying' the table.
exec [distinct] ps [by pb] from texp [where pw]
The above code is a 'hint' and requires modification.
Hope this helps.
Kind regards,
Leah
2021.11.29
10:44 AM
- last edited on
2021.12.03
03:42 AM
by
LeahS
exec won't work on a partitioned table directly. Need to have a select statement first.
exec option_id from select distinct option_id from trade
I would also recommend starting with qSQL before moving on to functional qSQL.
QSQL query templates | Basics | kdb+ and q documentation - Kdb+ and q documentation (kx.com)
2021.11.30 03:00 AM
Thank you for the help, Matt and Leah! 🙂
EMEA
Tel: +44 (0)28 3025 2242
AMERICAS
Tel: +1 (212) 447 6700
APAC
Tel: +61 (0)2 9236 5700
KX. All Rights Reserved.
KX and kdb+ are registered trademarks of KX Systems, Inc., a subsidiary of FD Technologies plc.