0

I have a splayed table which I can select data from just fine.

When I try to view the meta data I get a `sym error. Can anyone suggest reasons why this might happen?

 q)meta tablename
 k){$[(20h>t)|77h<t:@x;`;98h>@. t:!x;`;t]}
 'sym
 .:
 `sym
 q.Q))
Donald_W
  • 1,773
  • 21
  • 35
Hopper06
  • 89
  • 2
  • 10
  • load the sym file in - should have got loaded when the db started up, really. – Manish Patel Oct 02 '14 at 15:52
  • I have tried \l path/sym, but when I load this, table is no longer accessible. Is there a particular way I should load the sym file? It is not automatically loading. – Hopper06 Oct 02 '14 at 16:04
  • Is the root of the historical database contains the sym file? can you do a `get \`:sym` to read the file? So long as the sym file is in the root of the hdb, it should get read in. So if you do `\l /root/to/hdb` that will load all the tables + the sym file – Manish Patel Oct 02 '14 at 16:35

2 Answers2

2

Enum vector is not loaded into the session. To replicate start up q inside an hdb partition - splayed tables are all valid but as the sym is not loaded, meta will fail.

glen@aquaq:~>q hdb1/

q)2#trades
sym time                          src price size
------------------------------------------------
3   2014.04.22D08:00:00.937000000 10  25.02 5167
3   2014.04.22D08:00:04.567000000 9   25.05 3376
q)meta trades
k){$[(20h>t)|77h<t:@x;`;98h>@. t:!x;`;t]}
'sym
.:
`sym
q.Q))\\

q)sym:get`:../sym
q)meta trades
c    | t f a
-----| -----
sym  | s   p
time | p
src  | s
price| f
size | i

All the best!

glenny
  • 119
  • 3
  • Is there a specific place a sym file is meant to be stored? I have a feeling my issue stems from my sym file not being in the correct directory. – Hopper06 Oct 02 '14 at 15:57
  • I am using a script to create and splay the table, and the script is storing the sym file in another directory. So it is not "automatically" putting the sym file where it "should" be. Can you be more specific about where it should be, besides "in a directory above the splayed table files?" How high above? In the same directory as the tablename folder? I've tried that, and it isn't working... – Hopper06 Oct 02 '14 at 16:06
  • >In the same directory as the tablename folder? I've tried that, and it isn't working. Can you elaborate on this as your example shows, it should work like the standard way e.g. q)t:([] a:1_til 10;b:reverse 1_til 10;sym:9?`3;time:9#.z.p) q)`:hdb1/table/ set .Q.en[`:hdb1] t Although if the sym file is going in a non-standard place, then the correct way to load it in is not the "\l /path/to/sym" command that you mentioned in your post, but using 'load' e.g. load`:./path/to/sym – glenny Oct 02 '14 at 16:35
1

You are getting error because enumerated sym file is missing. Normally Q interpreter looks it into one directory above splayed directory.

For ex: If you give a save command like this:

       q)  t:([]sym:`a`b;id:1 2)

       q) `:/home/test/t/ set .Q.en[`:test] t

It will create directory 't' inside /home/test for splayed table 't' and create enumerated 'sym' file in directory /home/test.

To load this table:

       q)\l /home/test

Other thing is, you can also load enumerated 'sym' file manually like this:

       q)sym:get `:path to sym file

All tables in memory will automatically get mapped to this new list.

Reference: http://code.kx.com/q4m3/14_Introduction_to_Kdb+/#1422-splayed-tables-with-symbol-columns

Thomas Smyth - Treliant
  • 4,993
  • 6
  • 25
  • 36
Rahul
  • 3,914
  • 1
  • 14
  • 25
  • Yes! The manual load command is what I needed, because my sym file is not located in the standard place. This worked! Thank you very, very much. @glenny, I know you mentioned this also but I couldn't quite understand it from your explanation. Thank you for taking the time to answer, however! I appreciate the help from everyone. – Hopper06 Oct 02 '14 at 17:38