Function by changing the schema of the table

Hi,

I have a table called tbl with 4 columns, A,B,C,D, with the following
schema

q)meta tbl

c t f a
A s
B c
C f
D f

Then the following query was executed on tbl:

tbl: select C:C[where D=max(D)], D:max(D),by A,B from tbl;

this causes, the schema of tbl to be changed to
q)meta tbl

c t f a
A s
B c
C F
D f

Type of Column C has changed to ‘F’ from ‘f’. I have a C++ code which
interacts with q database, and while retrieving the values from the
database for C, D ( via kF() ) the values for D come out correct but
the values for C are being fetched as 0, despite the q console showing
non-zero values for C.

How do I fetch correct values for type ‘F’ from the c++ code? Also,
why does the by statement change the schema to ‘F’.?

I tried an explicit typecast like tbl: select C:"f"C[where D=max(D)],
D:max(D),by A,B from tbl;
This didn’t help either.

Regards,
Nav

On Fri, May 8, 2009 at 4:11 PM, Nav <nav.andraste> wrote:> q)meta tbl> c ? ? ? ? ? | t f a> ------------ | -----> A ? ? ? ? ? | s> B ? ? ? ? ? | c> C ? ? ? ? ? | f> D ? ? ? ? ? | f>> Then the following query was executed on tbl:>> tbl: select ?C:C[where D=max(D)], D:max(D),by A,B from tbl;>> this causes, the schema of tbl to be changed to> q)meta tbl> c ? ? ? ? ? | t f a> ------------ | -----> A ? ? ? ? ? | s> B ? ? ? ? ? | c> C ? ? ? ? ? | F> D ? ? ? ? ? | fwhat exactly do you want to get back? all rows where D is at itsglobal max? all rows where D is at its max for that (A;B) pair?the first would be “select from tbl where D=max D”; the second wouldbe “select from tbl where D=(max;D)fby(a;b)”“F” is the type of a list (vector) of floats; making it “first C[whereD=max(D)]” would solve your type issue, but probably not give you acorrect answer</nav.andraste>

Thanks Aaron, that helps!Regards,Nav