# adding a symbol or string column to a splay table

**URL:** <https://forum.kx.com/t/adding-a-symbol-or-string-column-to-a-splay-table/8359>\
**Category:** Community Support\
**Tags:** kdb-and-q\
**Created:** [September 4, 2013, 12:28pm UTC](https://forum.kx.com/t/adding-a-symbol-or-string-column-to-a-splay-table/8359 "2013-09-04T12:28:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![david\_bieber](https://avatars.discourse-cdn.com/v4/letter/d/ee59a6/32.png) [@david\_bieber](https://forum.kx.com/u/david_bieber)\
**Post date:** [September 4, 2013, 12:28pm UTC](https://forum.kx.com/t/adding-a-symbol-or-string-column-to-a-splay-table/8359/1 "2013-09-04T12:28:00Z")

</div>

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&nbsp;

> > >

> 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) &nbsp;

> @[`: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

---

<div class="post-metadata">

**Author:** ![wp1](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@wp1](https://forum.kx.com/u/wp1)\
**Post date:** [September 4, 2013, 5:34pm UTC](https://forum.kx.com/t/adding-a-symbol-or-string-column-to-a-splay-table/8359/2 "2013-09-04T17:34:00Z")

</div>

check out dbmaint.q in [code.kx.com](http://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:`aa`bb; 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\>

---

<div class="post-metadata">

**Author:** ![wp1](https://avatars.discourse-cdn.com/v4/letter/w/db5fbb/32.png) [@wp1](https://forum.kx.com/u/wp1)\
**Post date:** [September 4, 2013, 5:35pm UTC](https://forum.kx.com/t/adding-a-symbol-or-string-column-to-a-splay-table/8359/3 "2013-09-04T17:35:00Z")

</div>

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](http://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:`aa`bb; 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\>
