KX Community

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

Home Forums kdb+ How to add a column to the Partition table? Re: How to add a column to the Partition table?

  • cillianreilly

    Member
    June 17, 2023 at 12:00 am

    You haven’t added the rk column to the 2023.06.01 partition.

     

    q){x!`rk in/:get each` sv/:(hsym`$string x),:`trade`.d}date 
    2023.06.01| 0 
    2023.06.02| 0 
    2023.06.05| 1 
    2023.06.06| 1

     

    You can reference dbmaint.q – it contains utility functions for working on partitioned databases. For this case, the fixtable function would help you here – adding the rk column into the partitions that don’t currently contain it.

    In general, better practice is to add the empty column to all partitions first (addcol), and then write down the partitions containing data. This keeps the HDB in a good state throughout the operation.