update column type when no rows matched

Viewed 62
"b" ~ meta[update b:1b from ([]a:1 2) where a=3][`b;`t]

But how does q knows what type should it be in the column b without any matched rows (where a=3) in update expression?

1 Answers

It infers the type from your statement, it doesn't matter if there was a match or not. It takes the null of whatever type you've specified for the column.

Same thing if there was a match:

q)update b:.z.D from ([]a:1 2) where a=2
a b
------------
1
2 2021.05.14

It fills the matches with your value, but the non-matches get the corresponding null for that datatype. Boolean is a grey area as there technically isn't a null but 0b is the assumed null Boolean

Related