leprechaun1066
Joined 6 years ago
Joined 6 years ago
aj[`sym`time;t;q]
becomes t,'(`sym`time _q)(`sym`time#q)bin`sym`time#t
The rest of the aj function internals are there to handle edge cases, handling missing columns and options for filling nulls.A lot of the joins can be distilled to the core operators/functions in a similar manner. For example the plus-join is
x+0i^y(cols key y)#xLayers of "I have no idea what the machine is doing" on top of other layers of "I have no idea what the machine is doing". This will end well...
I do agree with the parent post. Calling them hallucinations is not an accurate way of describing what is happening and using such terms to personify these machines is a mistake.
This isn't to say the outputs aren't useful, we see that they can be very useful...when used well.
For example the user might ask for data with the constraint
where TradingDesk=`Eq, AvgPx>500.0
which kdb+ parses into ((=;`TradingDesk;(),`Eq);(>;`AvgPx;500.0))
As a dev on the system I can then have a function which takes in this constraint and a list of clients that I want to restrict the result to. That list of clients could come from another function related to the entitlements of the user who made the request: applyClientRestriction:{[constraint;clients] constraint,enlist(in;`Client;enlist clients)}
Which results in an extension of the constraint like this for two clients A and B: q)applyClientRestriction[((=;`TradingDesk;(),`Eq);(>;`AvgPx;500.0));`ClientA`ClientB]
((=;`TradingDesk;enlist`Eq);(>;`AvgPx;500.0);(in;`Client;enlist`ClientA`ClientB))
Then that gets passed to the function which executes the query on the table (kdb+ supports querying tables in a functional manner as well as with a structured query language) and the result has the restrictions applied.It's really nice because, once parsed, it's list processing like in a lisp and not string processing which is a pain.
I think this form might be a bit easier: {(x,x)#(x*x)#1,x#0}
Usually when someone solves problems with q, they don't use the way one would for Python/Java/C/C++/C#/etc.
This is probably a poor example, if I asked someone to write a function to create an nxn identity matrix for a given number the non-q solution would probably involve some kind of nested loop that checks if i==j and assigns 1, otherwise assigns 0.
In q you'd still check equivalence, but instead of looping, you generate a list of numbers as long as the given dimension and then compare each item of the list to itself:
{x=/:x:til x}3
An LLM that's been so heavily trained on an imperative style will likely struggle to solve similar (and often more complex) problems in a standard q manner.
https://news.ycombinator.com/item?id=14783539
https://news.ycombinator.com/item?id=21892432