Search code examples
kdb

How to run the functional version of <select from 10#trade>?


I want to execute the following in an RDB or any other proc:

?[(10;#;`trade);();0b;()] (1)

I have a parser that converts string qsql queries to functional form and then send them from the gw to the correct process to be resolved. All well with more complex queries , but now someone wants to run 10#trade.

In order for my parser to work I need to convert it to the functional form of select from 10#trade. The only problem is that when I do that I get a Mismatched error on the process.

I cannot seem to run (1) even directly on the process.


Solution

  • Your example is trying to mix a parse tree with a functional select which is not going to work.

    You can limit from within a select/functional-select:

    parse"select[5] from trade"
    ?
    `trade
    ()
    0b
    ()
    5
    ?[`trade;();0b;();5]
    a
    -
    1
    1
    1
    1
    1
    

    To do exactly what you asked would be:

    ?[eval  (#;5;`trade);();0b;()]
    a
    -
    1
    1
    1
    1
    1