'How can I allow users to submit q queries and interpret them as a string?

I want to allow users to write real q queries like

select from table where date=.z.d

Is it possible to use something like

E)select from table where date=.z.d

and then use the input to that E) to parse the query and do stuff with it?

kdb


Solution 1:[1]

If you create a function called .E.e, anything you pass to it will be interpreted as a string, so you can do something like this to start parsing your input:

q).E.e: {" " vs x}
q)E)select from table where date = .z.d
"select"
"from"
"table"
"where"
"date"
,"="
".z.d"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Matthew Greenlees