adding a symbol or string column to a splay table

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:aabb; 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

ctfa

0ids

1tii

2pf

3strC

4p1f

5id1s

6str1C

meta db_big

ctfa

0ids

1tii

2pf

3strC

4p1f

5id1s

6str1

Can anyone help?

Many thanks

David

check out dbmaint.q in code.kx.com. that’s doing this stuff for you already.On Wed, Sep 4, 2013 at 12:28 PM, David Bieber <david.bieber> wrote:> 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:aabb; ti:1 2 ; p:1.1 1.2; str:(“a&a”;“b&b”))> db_big: .Q.en[:c:/q/splay/] db_big&gt; :c:/q/splay/db_big/ set db_big>>> db_small: ( id:symbol$(); ti:int$() ; p:float$(); str:())&gt; db_small insert (ff;6;1.6;"")&gt; db_small: .Q.en[:c:/q/splay/] db_small>> :c:/q/splay/db_big/ upsert db_small;&gt;&gt;&gt; Adding new float column "p1" which is not a symbol works fine when upserting&gt; to splay&gt;&gt; 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>>> –>

Submitted via Google Groups</david.bieber>

actually, not sure if that works on splayed tables only, but it defworks on date-partitioned/splayed tables.On Wed, Sep 4, 2013 at 5:34 PM, wp wrote:> check out dbmaint.q in code.kx.com. that’s doing this stuff for you already.>> On Wed, Sep 4, 2013 at 12:28 PM, David Bieber <david.bieber> wrote:>> 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:aabb; ti:1 2 ; p:1.1 1.2; str:(“a&a”;“b&b”))>> db_big: .Q.en[:c:/q/splay/] db_big&gt;&gt; :c:/q/splay/db_big/ set db_big>>>>>> db_small: ( id:symbol$(); ti:int$() ; p:float$(); str:())&gt;&gt; db_small insert (ff;6;1.6;"")&gt;&gt; db_small: .Q.en[:c:/q/splay/] db_small>>>> :c:/q/splay/db_big/ upsert db_small;&gt;&gt;&gt;&gt;&gt;&gt; Adding new float column "p1" which is not a symbol works fine when upserting&gt;&gt; to splay&gt;&gt;&gt;&gt; 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>>>>>> –>>

Submitted via Google Groups</david.bieber>