-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial commit for verbose.q #87
base: main
Are you sure you want to change the base?
Conversation
// @param x String | ||
.finos.verbose.escapeID:{conv:-11h=type x;$[conv;`$;::]ssr[.h.hug[.Q.an except "_"]$[conv;string x;x];"%";"_"]}; | ||
|
||
.finos.verbose.numToOrdinalString: ((1 + til 11)!("First"; "Second"; "Third"; "Fourth"; "Fifth"; "Sixth"; "Seventh"; "Eighth"; "Ninth"; "Tenth";"Eleventh")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the goal of having this here? Why does it specifically go from 1 to 11?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
if[100h<>type fun; '"fun must be a lambda"]; | ||
if[100h<>type errorHandler; '"errorHandler must be a lambda"]; | ||
if[not type[params] within 0 20h; '"params must be a list"]; | ||
try[fun;params;errorHandler]}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is no global try
function yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will put in .finos.errorTrapDot and use that instead.
.finos.verbose.setKeyColNr:{[keycount;table] | ||
if[not type[keycount] in -6 -7h; '"keycount must be an integer"]; | ||
if[0>keycount; '"keycount must be nonnegative"]; | ||
if[not type[table] in 98 99h; '"2nd argument must be a table"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.Q.qt
could be used to check if the object is a table.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
]; | ||
keycount!table}; | ||
|
||
//workaround for inability to use table syntax with security.q |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we going to add security.q as well? If not then this is a stranded comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change it to be the more general term, "parse tree filters".
if[not 10h=type str; '".finos.verbose.sym only works on string argument"]; | ||
`$str}; | ||
|
||
//wrapper to allow xasc in secure gateway (raw xasc may modify table in-place) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"secure gateway" is a stranded reference. Repeated multiple times.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also changed to refer to "parse tree filters".
if[not .Q.qt[tbl]; '".finos.verbose.xkey expects a table"]; | ||
keyCols xkey tbl}; | ||
|
||
//wrapper to allow case-insenstive xasc in secure gateway (raw xasc may modify table in-place) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrong function name in the comment. Also this function is not really iasc
, which is unary, works on a list (can be a table), and returns a list of indices. Therefore the name is confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to xasci
until someone comes up with a better name.
s:((),sortCols)!{$[x in "sC";(lower;y);y]}'[(0!meta[?[tbl;();0b;{![x;x]}(),sortCols]])[;`t];sortCols]; | ||
.finos.verbose.xkey[xk] (0!tbl) iasc ?[tbl;();0b;s]}; | ||
|
||
//wrapper to allow case-insenstive xdesc in secure gateway (raw xdesc may modify table in-place) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See above, but with desc instead of asc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to xdesci
.
.finos.verbose.xkey[xk] (0!tbl) idesc ?[tbl;();0b;s]}; | ||
|
||
//wrapper to allow null-ignoring xasc in secure gateway (raw xasc may modify table in-place) | ||
.finos.verbose.nasc:{[sortCols;tbl] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is new functionality, not an equivalent of a built-in q operator/function. It might be better to put into a separate file (query.q?) and add a thin wrapper here if necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
$[(sd<cd);fun1[sd;min[ed,cd-1]];()],$[(ed>cd-1);fun2[max[sd,cd];ed];()] | ||
}; | ||
|
||
//by default these are identity, specify the timezone parameter to have these overwritten in setup.q |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the referenced setup.q, these are useless as well as anything that depends on them.
first value flip `nr xasc ![([] constr: constrList; nr: (1 + count constrList) + til count constrList); | ||
enlist (min';(in;(.finos.verbose.collectFields';`constr);enlist pre)); | ||
0b; | ||
.istat.FIELDAS[`i;`nr]]}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaked proprietary function name, also other occurrences below.
//@param o symbol list specifying your domain specific ordering | ||
//@param t the table which columns should be rearranged | ||
// | ||
.finos.verbose.fixColumnOrderGEN: {[o;t] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another "screaming" suffix.
keys[t], o inter cols value[t]; // leave keys untouched sort value cols against ordering | ||
98h ~ type t; // if not keyed table | ||
o inter cols t; // sort all cols against ordering | ||
'"invalid branch" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could use a better error message.
// This function can be used for example to calculate the midprice of and index (weighted set of instruments). | ||
// | ||
.finos.verbose.aggregateFieldValuesAsOf: {[t; k; p; v; colname; binop] | ||
piv: fills .ms.pivot.pvtfw[t; k; p; v; (); ()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leaked proprietary function name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Deleted.
// unkeys a table. It is just a projection of .finos.verbose.xkey setting the first parameter to empty list | ||
.finos.verbose.unkey: .finos.verbose.xkey[()]; | ||
|
||
.finos.verbose.priv.validateSelectArgs:{[tbl;constr;grp;stat;cnt;ord] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would prefer the params of all the qsql wrappers conform to the traditional t/c/b/a naming; perhaps tbl
contr
by
aggs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are inherited names, but to me stat
makes more sense because the a
is not necessarily an aggregation.
THE FOLLOWING DISCLAIMER APPLIES TO ALL SOFTWARE CODE AND OTHER MATERIALS CONTRIBUTED IN CONNECTION WITH THIS SOFTWARE:
THIS SOFTWARE IS LICENSED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND ANY WARRANTY OF NON-INFRINGEMENT, ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THIS SOFTWARE MAY BE REDISTRIBUTED TO OTHERS ONLY BY EFFECTIVELY USING THIS OR ANOTHER EQUIVALENT DISCLAIMER IN ADDITION TO ANY OTHER REQUIRED LICENSE TERMS.
ONLY THE SOFTWARE CODE AND OTHER MATERIALS CONTRIBUTED IN CONNECTION WITH THIS SOFTWARE, IF ANY, THAT ARE ATTACHED TO (OR OTHERWISE ACCOMPANY) THIS SUBMISSION (AND ORDINARY COURSE CONTRIBUTIONS OF FUTURES PATCHES THERETO) ARE TO BE CONSIDERED A CONTRIBUTION. NO OTHER SOFTWARE CODE OR MATERIALS ARE A CONTRIBUTION.