Kdb how to remove a string key from a dictionary
Since the type of "list of keys" in your dictionary is 0h (mixed list or list of list)
q) type ("k1";"k2";"ABC")
q) 0h
and your only key type is 10h (string)
q) type "k1"
q) 10h
This is why kdb gives you a type error when matching.
Link: http://code.kx.com/q4m3/5_Dictionaries/
It says: "The left operand of the delete is the dictionary (target), and the right operand is the key value, the type of which matches the type of the target."
You can use the following to delete an entry:
q) (k@where not (k:key l2) like "k1")#l2
Key Value
k2 v2
ABC BLA BLA
source to share
I think you should use enlist
to remove a string key from a dictionary:
q)enlist["k1"]_("k1";"k2";"ABC")!("v1";"v2";"BLA BLA")
"k2" | "v2"
"ABC"| "BLA BLA"
_
(drop) accepts left input as a list of dictionary key elements (with the exception when it comes to character key). Try to imagine that in your case "k1" is an "atom" and to create a singleton list you can simply enlist
"k1".
source to share