问题
I am trying to load the data for each date and then sort the sym column and apply the parted attribute. But I don’t know how to use the .Q.dpft function to save to the same table?
There is a trade table in hdb. Here is my function:
\l dbdir;
test:{
trade:select from trade where date = x;
trade:`sym xasc trade;
.Q.dpft[dbdir;x;`sym;`trade]}each date;
Doesn’t seem to be working though. The error is ``trade`
回答1:
I think you need to pass the table trade & dbdir as arguments to your function since you're referencing them inside the function.
test:{[dbdir;table;x]
trade:select from table where date = x;
.Q.dpft[dbdir;x;`sym;table]}[dbdir;`trade]each date
Also perhaps worth noting that .Q.dpft will take care of sorting the sym column for you, so no need to sort it separately.
来源:https://stackoverflow.com/questions/65044905/using-q-dpft-function-to-resave-table