Home › Forums › kdb+ › Double comma when converting qsql statements to functional statements › Re: Double comma when converting qsql statements to functional statements
-
The list of constraints (index 2) is itself a parse tree which means value cannot be applied to the output of parse. For a simple example like this, it’s just a matter of removing a level of nesting but just to illustrate….
q)show t:([]a:1 2;b:10 20); a b ---- 1 10 2 20 q)show pt:parse"select from t where a>1"; // parse tree at index 2 ? `t ,,(>;`a;1) 0b () q)value pt // value cannot be applied 'type [0] value pt // value cannot be applied ^ q)@[pt;2;eval] // evalute the parse tree at index 2 which removes a level of nesting ? `t ,(>;`a;1) 0b () q) q)value @[pt;2;eval] // value can be applied to output a b ---- 2 20 q) q)?[t;enlist(>;`a;1);0b;()] ~ value @[pt;2;eval] // matches manually typed functional form 1b
Some further reading which includes more complex examples https://code.kx.com/q/wp/parse-trees/