upsert a partitioned table

I want to upsert to a (date) partitioned table in the hdb

Is the following right way to do it:

tab: select from table

tab upsert updated_records

{ .Q.dpt[`:hdb;x;tab] } each date_list_from_hdb

Thanks.

You can load a table in, upsert in memory and write back down, though you can upsert directly to splayed tables on disk 

https://code.kx.com/q/ref/upsert/#splayed-table

Just watch out for things like attributes/enumerations 

Here is a code snippet that i use to append/save to the partitioned table. Its from the book “Machine Learning and Big data with kdb+/q”.  The book forms a good combo with “q tips”. The snippet is written in k and i couldnt understand it completely. But I’ll try my best to explain its working :)

k).quantQ.io.dpftsAppend:{[d;p;f;t;s;o]
    if[~&/.Q.qm’r:+.Q.enxs[$;d;;s]. . :t;'unmappable];     {[d;t;o;x]@[d;x;o;t x]}[d:.Q.par[d;p;t];r;o;]'[!r];     @[d;.d;:;f,r@&~f=r:!r];
    @[.q.xasc[f] d;f;`p#];
    t};
the o argument above is used for saving(:) and inserting(,)

for saving

{
   qt set select from quotes where date=x;    .quantQ.io.dpftsAppend[mydbdir;x;code;qt;sym; :];
    delete qt from `.;
} each 2016.04.07 2016.04.08 2016.04.11

for appending

qt : morequotes;
.quantQ.io.dpftsAppend[mydbdir;2016.04.07;code;qt;sym;  _**, ]**_; delete qt from .;

Regards

Rohith

Looking at the definition of .quantQ.io.dpftsAppend, it uses .Q.qm, which was removed in later versions of kdb, just to note in case you run into errors