adding a symbol or string column to a splay table

427 views
Skip to first unread message

David Bieber

unread,
Sep 4, 2013, 7:28:41 AM9/4/13
to personal...@googlegroups.com
I am having problems when I want to add column symbol or string to a splay table. I encounter a type error when trying to add data to the splay. Below is an example of the errors I am having.

For instance if I make a splay table as follows and upsert a small table into the splay it works 
db_big: ([] id:`aa`bb; ti:1 2 ; p:1.1 1.2; str:("a&a";"b&b"))
db_big: .Q.en[`:c:/q/splay/] db_big
`:c:/q/splay/db_big/ set db_big


db_small: ([] id:`symbol$(); ti:`int$() ; p:`float$(); str:())
`db_small insert (`ff;6;1.6;"")
db_small: .Q.en[`:c:/q/splay/] db_small

`:c:/q/splay/db_big/ upsert db_small;

Adding new float column "p1" which is not a symbol works fine when upserting to splay

db_small: ([] id:`symbol$(); ti:`int$() ; p:`float$(); str:())
`db_small insert (`ff;6;1.6;"")
db_small: .Q.en[`:c:/q/splay/] db_small

`:c:/q/splay/db_big/ upsert db_small;

@[`:c:/q/splay/db_big; `p1; : ; (count db_big)#0n]
.[`:c:/q/splay/db_big/.d;(); , ; `p1]

db_small: ([] id:`symbol$(); ti:`int$() ; p:`float$();str:();p1:`float$())
`db_small insert (`ff;6;1.6;"";1.7)
db_small: .Q.en[`:c:/q/splay/] db_small

`:c:/q/splay/db_big/ upsert db_small;


However if I try to add a new columns id1:symbol and str1:string to the splay table the upsert fails (type error). Same error occurs if I only add one column (either symbol or string)  

@[`:c:/q/splay/db_big; `id1; : ; (count db_big)#`]
.[`:c:/q/splay/db_big/.d;(); , ; `id1]

@[`:c:/q/splay/db_big; `str1; : ; (count db_big)#()]
.[`:c:/q/splay/db_big/.d;(); , ; `str1]

db_small: ([] id:`symbol$(); ti:`int$() ; p:`float$();str:();p1:`float$();id1:`symbol$();str1:())
`db_small insert (`ff;6;1.6;"";1.7;`gg;"")
db_small: .Q.en[`:c:/q/splay/] db_small

`:c:/q/splay/db_big/ upsert db_small;

I can see that I should in some way use .Q.en when adding a symbol or string column but I haven't found anything in the docs.

meta db_small
c t f a
0 id s
1 ti i
2 p f
3 str C
4 p1 f
5 id1 s
6 str1 C

meta db_big
c t f a
0 id s
1 ti i
2 p f
3 str C
4 p1 f
5 id1 s
6 str1

Can anyone help?

Many thanks

David


wp

unread,
Sep 4, 2013, 12:34:19 PM9/4/13
to personal...@googlegroups.com
check out dbmaint.q in code.kx.com. that's doing this stuff for you already.
> --
> You received this message because you are subscribed to the Google Groups
> "Kdb+ Personal Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to personal-kdbpl...@googlegroups.com.
> To post to this group, send email to personal...@googlegroups.com.
> Visit this group at http://groups.google.com/group/personal-kdbplus.
> For more options, visit https://groups.google.com/groups/opt_out.

wp

unread,
Sep 4, 2013, 12:35:18 PM9/4/13
to personal...@googlegroups.com
actually, not sure if that works on splayed tables only, but it def
works on date-partitioned/splayed tables.
Reply all
Reply to author
Forward
0 new messages