cjm2671
cjm2671

Reputation: 19486

What might cause a type mismatch on a init of a splayed table in KDB?

I'm trying to create a new, empty, splayed table:

price_data: ([] s:`$(); t:`timestamp$(); o:`float$(); h:`float$(); l:`float$(); c:`float$(); v:`int$())

`:/home/data/price_data/ set price_data

I'm getting a type mismatch error. What am I doing wrong?

Upvotes: 0

Views: 784

Answers (1)

Mark Kelly
Mark Kelly

Reputation: 1780

When setting splayed tables all symbol columns need to be enumerated, otherwise it will throw a type error.

This can be achieved using .Q.en, which converts the symbol columns to integral values and a corresponding sym file containing the symbol values.

Enumerated symbol columns have type 20h instead of type 11h.

/ pre enumeration
q)type price_data`s
11h
/ after enumeration
q)type .Q.en[`:.;price_data]`s
20h
/ since we have no symbols in our table an empty sym file is generated
q)get`:sym
`symbol$()

Upvotes: 2

Related Questions