KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ In funtional qSQL, what is the meaning when the operator is a list?

  • In funtional qSQL, what is the meaning when the operator is a list?

    Posted by vivo on October 11, 2022 at 12:00 am

    In the below code, I can understand the meaning of (<), but cannot understand the meaning of (‘;~:;<). Why line 3 keeps 4 rows, while line 4 keeps 6 rows? What is the meaning of “~:” here?

     

    t:([] c1:`a`b`c`d`e`f; c2:1 1 1 2 2 2; c3:10 20 30 40 50 60);
    ?[t;enlist((<);`c3;(44));0b;`symbol$()]; // I can understand this
    ?[t;enlist((';~:;<);`c3;({y-x};(min;15 25 35 45);44));0b;`symbol$()]; // why keep 4 rows?
    ?[t;enlist((';~:;<);`c3;({y-x};(min;35 45);44));0b;`symbol$()]; // why keep 6 rows?

     

    vivo replied 8 months, 2 weeks ago 2 Members · 1 Reply
  • 1 Reply
  • gyorokpeter-kx

    Member
    October 11, 2022 at 12:00 am

    The queries are the functional equivalents of:

    select from t where c3<44 select from t where c3>={y-x}
    [min 15 25 35 45;44] 
    select from t where c3>={y-x}
    [min 35 45;44]

    In the 2nd example, min 15 25 35 45 evaluates to 15, {y-x}[15;44] is 29, and the condition c3>=29 is true for 4 rows.

    In the 3rd example, min 35 45 is 35, {y-x}[35;44] is 9 and all rows satisfy c3>=9.

    In the functional form, (‘;~;<) is just the representation of >=. If you type >= at the console, you can see it comes back as ~<, which is the composition of the operators ~ (not) and < (less than). The functional form includes the ‘ (composition) operator.

     

     

     

     

     

     

Log in to reply.