Reputation: 3
We've seen issues where a kdb database is corrupted and are looking for a way to implement a check that every kdb column is the same length in a particular table. Any recommendation on how to do this?
i.e., would like to get a return value of each column in a table and it's length.
These tables have upwards of 200 columns. Any way to go about this efficiently?
Any help is appreciated. Thank you.
Upvotes: 0
Views: 612
Reputation: 3179
Something like this might work for you.
q)tables[]
`positions`quote`trade
q)count each flip trade
time | 40000
sym | 40000
src | 40000
price | 40000
amount| 40000
side | 40000
You can run the same thing on partitioned data as well.
q)count each flip select from ohlc where date=last date
date | 1440
sym | 1440
exchange | 1440
timestamp| 1440
open | 1440
high | 1440
low | 1440
close | 1440
volume | 1440
EDIT: The methods used above will only work on tables which are not corrupted, which may not be best suited to your use case.
If the data is corrupted, you can get
each column from its location on disk and count it.
q)cols[ohlc]!{count get hsym`$"/path/to/hdb/2020.02.09/ohlc/",string x}each cols ohlc
date | 1440
sym | 1440
date | 1440
exchange | 1440
timestamp| 1439
open | 1440
high | 1440
low | 1440
close | 1440
volume | 1440
Upvotes: 2