cancel
Showing results for 
Search instead for 
Did you mean: 

Double comma when converting qsql statements to functional statements

mmcalister
New Contributor

What does the presence of the double comma, (,,) before the where phrase part of a parsed select statement.

I know a single comma means it is enlisted

(see photo)

What are the implications in terms of converting to a functional statement

1 REPLY 1

Jason_Fealy
New Contributor III
New Contributor III

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....

(btw, your example has a bug: size should not be a symbol in your q-sql statement as it's a column name)

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/