Hi,I’m just getting started in q, so please forgive me if this is a sillyquestion.In some (most?) cases, it appears that q prohibits duplicate columnnames, or at least attempts to avoid accidental introduction of them,while in others (well, at least one other) it appears to allow them.For example if:t:( name: Dent
Beeblebrox`Prefect; iq:98 42 126then:select name, iq, iq1:iq+2, iq from treturns a table with duplicate col name ‘iq1’.Is this a bug or a feature? Are there other cases where duplicatecolumn names can arise? Is it a mistake to code under the assumptionthat column names are unique?Thanks.
Having used quite a few versions of KDB (q being the language maininterface in the version4 line) it seems as if the answer to yourquestion is: Yes, it is a mistake to make such an assumption.It seems like the way to avoid column name collision in K has alwaysused a simple algorithm where a number is appended to columns that areselected, but not named explicitly in a select.As you can see in this very simple example, a number is appended tothe “extra” selection of columns:q)t:( sym:a
b; val: 1 2)q)select val,val,val,val from tval val1 val2 val3------------------1 1 1 12 2 2 2So I never assume that duplicate column names can not arise - which isusually not a problem either since it is often easy to avoid suchstrangeness by explicitly naming columns in selection.
On Jun 14, 6:24?pm, Lindqvist <lindqvist.h…> wrote:> Having used quite a few versions of KDB (q being the language main> interface in the ?version4 line) it seems as if the answer to your> question is: Yes, it is a mistake to make such an assumption.Thanks for the response.</lindqvist.h…>