0

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?

1 Answer 1

2

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

Sign up to request clarification or add additional context in comments.

2 Comments

.ds.hdb.fnCol[:.; materialEvents; eventType;{@[x;where 10h=type each x;{:/app/source/DEV/HDB/IBS/sym?enlist `$x}]} ] have ran the following but seem to have some strange values coming in now.Whats the "sym" part for?
code.kx.com/q/basics/enumerations symbols are stored on disk as enumerations

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.