KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Type error from Q chk Re: Type error from Q chk

  • rocuinneagain

    Member
    March 16, 2023 at 12:00 am

    There’s a thread with some info on stackoverflow:

    https://stackoverflow.com/questions/67272148/q-chk-gives-a-type-error-when-ran-on-a-hdb-how-can-i-debug-or-what-should-i

     

    Running strace -p pid may help show where .Q.chk is falling down.

     

    This is a basic outline of a helper function I created before to debug a part error when trying to load a HDB.

    It may be a good starting point for finding the root cause issue for you too.

    // https://code.kx.com/q/ref/system/#capture-stderr-output
    q)tmp:first system"mktemp" 
    
    q){d:1_string x;{y:string y;(y;"D"$y),{r:system x;show last r;$[1~"J"$last r;(1b;-1_r;"");(0b;();-1_r)]} "ls ",x,"/",y," > ",tmp," 2>&1;echo $? >> ",tmp,";cat ",tmp}[d] each key x} `:badHDB
    q)tab:flip `part`date`osError`files`error!flip {d:1_string x;{y:string y;(y;"D"$y),{r:system x;$[0~"J"$last r;(0b;-1_r;"");(1b;();first r)]} "ls ",x,"/",y," > ",tmp," 2>&1;echo $? >> ",tmp,";cat ",tmp}[d] each key x} `:badHDB
    The resulting table:
    part          date       osError files   error 
    ----------------------------------------------------------------------------------------------------------- 
    "2001.01.01"  2001.01.01 0       ,"tab1" "" 
    "2001.01.01"             0       ,"tab2" "" 
    "2002.01.01"  2002.01.01 1       ()      "ls: cannot open directory 'badHDB/2002.01.01': Permission denied"
    For a larger HDB filter down to partitions with issues:
    select from tab where or[null date;osError]