KX Community

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

Home Forums kdb+ KDB table with an array as element Re: KDB table with an array as element

  • gdickson

    Member
    August 19, 2022 at 12:00 am

    To define any column in a table as a list or an array, you can simply specify the column type with an empty set of parentheses, (), on definition. Following this definition, you can then upsert the price array along with the time value, and the column value for that table will be assigned to a float list type (upper-case F in meta command indicates the column is a list of floats, as opposed to a float atom which would be identified with a lower case f):

    q)t:([]time:`time$();price:()) 
    q)`t upsert (.z.t;60.57 60.61) `t 
    q)t 
    time price 
    ------------------------ 
    21:47:06.298 60.57 60.61 
    
    q)meta t 
    c    | t f a 
    -----| ----- 
    time | t 
    price| F