Search code examples
kdb

Create a splayed table in q


I have a table trades that I want to splay in the directory splay I have created.

From what I have researched, the correct syntax is:

`:splay/ set trades

I have tried this, however I get an error 'type.

I've managed to save a flat table using:

`:splay/flattrades set trades

Solution

  • this is documented on the official doc site: https://code.kx.com/q/kb/splayed-tables/

    The issue is likely that you haven't enumerated the symbol columns using .Q.en.

    If you're still getting errors even after enumeration it could potentially be due to inconsistent datatypes within your columns (e.g. a column having a mixture of longs and ints). You can check this using something like:

    distinct type''[trades]
    

    assuming your trades table is an in-memory table. The above should return only one unique datatype for each column.