diff --git a/code/common/merge.q b/code/common/merge.q index f309d7bc8..657ff4b14 100644 --- a/code/common/merge.q +++ b/code/common/merge.q @@ -40,6 +40,10 @@ checkenumerabletype:{[tablename;extrapartitiontype] getextrapartitions:{[tablename;extrapartitiontype] value each ?[tablename;();1b;extrapartitiontype!extrapartitiontype] }; +/ - functional select equivilent to select distinct [ extrapartitiontype ] from [ tablename ] group exec {first each string x} distinct [ extrapartitiontype ] from [ tablename ] + +getfirstcharpartitions:{[tablename;extrapartitiontype] raze each value (?[tablename;();();(distinct;first extrapartitiontype)]) group ?[tablename;();();({first each string x};(distinct;first extrapartitiontype))]}; + /-function to return partition directory chunks that will be called in batch by mergebypart function getpartchunks:{[partdirs;mergelimit] diff --git a/code/processes/wdb.q b/code/processes/wdb.q index f22b6f238..030fc1f53 100644 --- a/code/processes/wdb.q +++ b/code/processes/wdb.q @@ -168,9 +168,7 @@ savetablesbypart:{[dir;pt;forcesave;tablename;writedownmode] /- check if provided column extrapartitiontype indeed has an enumerable type in table if[writedownmode~`partbyenum;.merge.checkenumerabletype[tablename;extrapartitiontype]]; /- get list of distinct combinations for partition directories - extrapartitions:.merge.getextrapartitions[tablename;extrapartitiontype]; - if[writedownmode~`partbyfirstchar; - extrapartitions:value extrapartitions group .Q.fu[{first each string x}; extrapartitions:raze extrapartitions]]; + extrapartitions:$[writedownmode~`partbyfirstchar;.merge.getfirstcharpartitions;.merge.getextrapartitions][tablename;extrapartitiontype]; /- enumerate data to be upserted enumdata:.Q.en[hdbsettings[`hdbdir];0!.save.manipulate[tablename;`. tablename]]; .lg.o[`save;"enumerated ",(string tablename)," table"];