KX Community

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

Home Forums kdb+ Changing column type fails

  • Changing column type fails

    Posted by smdesai on February 28, 2023 at 12:00 am

    Hello, I have a table that’s loaded by some data from an odbc call and the structure is as follows:

     

    q)meta res 
    c         | t f a 
    ----------| ----- 
    id        | C 
    first_name| C 
    last_name | C 
    email     | C

     

    Updating the column type for “id” to a symbol using the following fails.

     

    q)update "S"$id from res 
    'id [0] 
    update "S"$id from res

     

    Any reason as to why? This is on arm64 (Apple Silicon) where I’ve built odbc.so from the kdb github project. The same code however works on on m64 (Apple Intel), but this uses the stock odbc.so that’s provided by the above mentioned kdb project.

    smdesai replied 8 months, 2 weeks ago 2 Members · 3 Replies
  • 3 Replies
  • gyorokpeter-kx

    Member
    February 28, 2023 at 12:00 am

    Can you make sure that the res variable you do the meta on is the same that you are trying to update? E.g. global vs local variable, or other queries changing it in the meantime. Or there being a space in the column name (possible if parsing from CSV).

    This works:

    q)res:([]id:("AA";"BB");first_name:("CC";"DD");last_name:("EE";"FF");email:("GG";"HH")) 
    q)meta res 
    c         | t f a 
    ----------| ----- 
    id        | C 
    first_name| C 
    last_name | C 
    email     | C 
    
    q)update "S"$id from res 
    id first_name last_name email 
    ----------------------------- 
    AA "CC" "EE" "GG" 
    BB "DD" "FF" "HH"
  • smdesai

    Member
    February 28, 2023 at 12:00 am

    It’s the same variable and the problem seems to be much worse in that I can’t even do the following:

    q)select id from res 
    'id 
    [0] select id from res

    It looks as if something is screwed up doing the following odbc query:

    \l odbc.k h:.odbc.open `db

    userq:”select id,first_name,last_name,email from user”

    res:.odbc.eval[h;userq]

    .odbc.close h

  • smdesai

    Member
    March 3, 2023 at 12:00 am

    Well, I found the root cause of the issue, it’s the way I built odbc.so for Apple Silicon. I’ve rebuilt it and everything works as expected.

Log in to reply.