Reputation: 499
We have KDB query which sources data from different columns and one of the columns has Character array type ('C'), i.e. it contains text.
What we want is enlist
it when we query for data like this
select enlist column_with_character_arr from table
i.e. to have ("value1") inside a list so we will be able to add one more element to this list later on, say, ("value1", "value2"). How to do it? Because currently when we try to enlist
or add ,()
it fails with length error.
Upvotes: 0
Views: 2230
Reputation: 3969
You are missing each
here. Use:
select enlist each column_with_character_arr from table
ex:
q) t:([]v:("abc";"xyz"))
q) select enlist each v from t
Why length error on select (),v from t?
Because comma(,
) in select query separates different columns we want in output, i.e.
select col1,col2 from tbl
So in query : select (),v from t
: first column (before comma) has no value and second column is v
and hence count of both columns are different. That's why it gives `length
error.
To make it run, use:
q) select ((),v) from t
But this will not enlist each item of v
. It's just appending null to v
column.
Upvotes: 2