kdbkdb+

KDB+ DB maintenance


in my table I am seeing mixed datatypes which I want to fix by running dbmaint distinct eventTypes display in the image

I need to make sure that eventType holds a list of symbols so anything that doesnt match that needs ran against db maint however Im not sure how to do that. Using fnCol or castCol?


Solution

  • With mixed types it is not a simple cast.

    You should use: https://github.com/KxSystems/kdb/blob/master/utils/dbmaint.md#fncol

    Something along the lines of:

    1. Finds all cells containing strings
    2. Cast the strings to symbols
    3. Enlist the symbols (an assumption this is needed as your enumerated symbol is a list as shown by , in the output)
    4. Enumerate the symbol list
    fncol[`:/full/path/to/HDB;
          `table;
          `eventType;{
                      @[x;
                        where 10h=type each x;
                        {`:/full/path/to/HDB/sym?enlist `$x}]}
         ]
    

    Make sure to take a backup of your data before attempting this change. One option on this is to use copycol and then perform fncol on the original. Once you confirm the data is correct after you can deletecol the backup column.

    Test on a small dummy HDB first to write and confirm your logic is correct