Search code examples
kdb

Wrong type error when creating a table with symbols with spaces in kdb/q


I am trying to create a table of symbols in kdb, where the values of the table have spaces within. I have got

tab:([colOne:`$"value 1"`$"value 2"]colTwo:`$"value 3"`$"value 4")

currently, but this just returns

ERROR: `type (wrong type)

i have followed http://www.kdbfaq.com/kdb-faq/tag/sym-with-a-space


Solution

  • Should be:

    tab:([colOne:`$("value 1";"value 2")]colTwo:`$("value 3";"value 4"))
    

    Remember that evaluation in q is left-to-right:

    colTwo:`$"value 3"`$"value 4"
    `$"value 4" will be evaluated to symbol
    

    Then it will try to apply this symbol to what's on the left:

    "value 3" `$"value 4"
    

    which will give you 'type