Robert Kubrick
Robert Kubrick

Reputation: 8713

How to embed a function returning a string in a Q query?

I'm using Q.f to format column fields from integer to float with 4 digits precision:

fmt_price:{[val] .Q.f[4;](val*0.0001)}
select fmt_price[price] from mytable

The fmt_price works well at the q prompt, but if I embed the function in a query I get this error:

An error occurred during execution of the query. The server sent the response: `type

The fmt_price call works if I return a float or integer variable, rather than the result of Q.f.

Upvotes: 2

Views: 537

Answers (1)

user1895961
user1895961

Reputation: 1186

You need to do an each over the list. Currently you are passing a list of values to .Q.f, when it expects an atom. Something like the following is what you need:

fmt_price:{[val] .Q.f[4;] each (val*0.0001)} 

Upvotes: 1

Related Questions