-
-
Notifications
You must be signed in to change notification settings - Fork 312
[aggr-] allow ranking rows by key column #2417
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
97e1812
[aggr-] cap runtime when formatting memo status
midichef 5417f19
[aggr-] fix chooser lacking aggs starting with 'p'
midichef bfffb47
[aggr-] display stdev error note for lists of size 1
midichef 3ff8104
[aggr-] add rank aggregator, cmds addcol-aggregate/sheetrank
midichef 149370a
[rank-] make rank and sheetrank use column sort orderings
midichef a06ace7
[rank-] add Progress indicators to rank and sheetrank
midichef 351796f
remove extra import
saulpw 3d44bca
Merge branch 'develop' into aggr_rank
anjakefala ef9f383
[rank-] rename to addcol-rank-sheet
anjakefala File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!vd -p | ||
{"sheet": "global", "col": null, "row": "disp_date_fmt", "longname": "set-option", "input": "%b %d, %Y", "keystrokes": "", "comment": null} | ||
{"longname": "open-file", "input": "sample_data/test.jsonl", "keystrokes": "o"} | ||
{"sheet": "test", "col": "key2", "row": "", "longname": "key-col", "input": "", "keystrokes": "!", "comment": "toggle current column as a key column"} | ||
{"sheet": "test", "col": "key2", "row": "", "longname": "addcol-aggregate", "input": "count", "comment": "add column(s) with aggregator of rows grouped by key columns"} | ||
{"sheet": "test", "col": "qty", "row": "", "longname": "type-float", "input": "", "keystrokes": "%", "comment": "set type of current column to float"} | ||
{"sheet": "test", "col": "qty", "row": "", "longname": "addcol-aggregate", "input": "rank sum", "comment": "add column(s) with aggregator of rows grouped by key columns"} | ||
{"sheet": "test", "col": "qty_sum", "row": "", "longname": "addcol-rank-sheet", "input": "", "comment": "add column with the rank of each row based on its key columns"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
key2 key2_count key1 qty qty_rank qty_sum test_sheetrank amt | ||
foo 2 2016-01-01 11:00:00 1.00 1 31.00 5 | ||
0 2016-01-01 1:00 2.00 1 66.00 2 3 | ||
baz 3 4.00 1 292.00 4 43.2 | ||
#ERR 0 #ERR #ERR 1 0.00 1 #ERR #ERR | ||
bar 2 2017-12-25 8:44 16.00 2 16.00 3 .3 | ||
baz 3 32.00 2 292.00 4 3.3 | ||
0 2018-07-27 4:44 64.00 2 66.00 2 9.1 | ||
bar 2 2018-07-27 16:44 1 16.00 3 | ||
baz 3 2018-07-27 18:44 256.00 3 292.00 4 .01 | ||
foo 2 2018-10-20 18:44 30.00 2 31.00 5 .01 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
deptno job mgr sheetrank_1asc2asc3desc sheetrank_1asc2desc sheetrank_default_sort empno ename hiredate sal comm | ||
10 CLERK 7782 1 3 1 7934 MILLER Jan 23, 1982 1300.00000 | ||
10 MANAGER 7839 2 2 2 7782 CLARK Jun 19, 1981 2450.00000 | ||
10 PRESIDENT 3 1 3 7839 KING Nov 17, 1981 5000.00000 | ||
20 ANALYST 7566 4 7 4 7788 SCOTT Jul 13, 1987 3000.00000 | ||
20 ANALYST 7566 4 7 4 7902 FORD Dec 03, 1981 3000.00000 | ||
20 CLERK 7902 5 6 6 7369 SMITH Feb 17, 1981 800.00000 | ||
20 CLERK 7788 6 5 5 7876 ADAMS Jul 13, 1987 1100.00000 | ||
20 MANAGER 7839 7 4 7 7566 JONES Apr 12, 1981 2975.00000 | ||
30 CLERK 7698 8 10 8 7900 JAMES Dec 03, 1981 950.00000 | ||
30 MANAGER 7839 9 9 9 7698 BLAKE May 11, 1981 2850.00000 | ||
30 SALESMAN 7698 10 8 10 7499 ALLEN Feb 20, 1981 1600.00000 300.00000 | ||
30 SALESMAN 7698 10 8 10 7521 WARD Feb 22, 1981 1250.00000 500.00000 | ||
30 SALESMAN 7698 10 8 10 7654 MARTIN Sep 28, 1981 1250.00000 1400.00000 | ||
30 SALESMAN 7698 10 8 10 7844 TURNER Sep 18, 1981 1500.00000 0.00000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!vd -p | ||
{"sheet": "global", "col": null, "row": "disp_date_fmt", "longname": "set-option", "input": "%b %d, %Y", "keystrokes": "", "comment": null, "replayable": null} | ||
{"sheet": "global", "row": "disp_float_fmt", "longname": "set-option", "input": "%.05f", "keystrokes": ""} | ||
{"sheet": "global", "row": "default_width", "longname": "set-option", "input": "50", "keystrokes": ""} | ||
{"col": "", "row": "", "longname": "open-file", "input": "sample_data/employees.sqlite", "keystrokes": "o", "replayable": true} | ||
{"sheet": "employees", "col": "", "row": 1, "longname": "open-row", "input": "", "keystrokes": "Enter", "comment": "open current row with sheet-specific dive", "replayable": true} | ||
{"sheet": "emp", "col": "deptno", "row": "", "longname": "key-col-on", "input": "", "comment": "set current column as a key column", "replayable": true} | ||
{"sheet": "emp", "col": "job", "row": "", "longname": "key-col-on", "input": "", "comment": "set current column as a key column", "replayable": true} | ||
{"sheet": "emp", "col": "mgr", "row": "", "longname": "key-col-on", "input": "", "comment": "set current column as a key column", "replayable": true} | ||
{"sheet": "emp", "col": "empno", "row": "", "longname": "key-col-off", "input": "", "comment": "unset current column as a key column", "replayable": true} | ||
{"sheet": "emp", "col": "", "row": "", "longname": "addcol-rank-sheet", "input": "", "comment": "add column with the rank of each row based on its key columns", "replayable": true} | ||
{"sheet": "emp", "col": "emp_sheetrank", "row": "", "longname": "rename-col", "input": "sheetrank_default_sort", "keystrokes": "^", "comment": "rename current column", "replayable": true} | ||
{"sheet": "emp", "col": "deptno", "row": "", "longname": "sort-asc", "input": "", "keystrokes": "[", "comment": "sort ascending by current column; replace any existing sort criteria", "replayable": true} | ||
{"sheet": "emp", "col": "job", "row": "", "longname": "sort-desc-add", "input": "", "keystrokes": "z]", "comment": "sort descending by current column; add to existing sort criteria", "replayable": true} | ||
{"sheet": "emp", "col": "", "row": "", "longname": "addcol-rank-sheet", "input": "", "comment": "add column with the rank of each row based on its key columns", "replayable": true} | ||
{"sheet": "emp", "col": "emp_sheetrank", "row": "", "longname": "rename-col", "input": "sheetrank_1asc2desc", "keystrokes": "^", "comment": "rename current column", "replayable": true} | ||
{"sheet": "emp", "col": "deptno", "row": "", "longname": "sort-asc", "input": "", "keystrokes": "[", "comment": "sort ascending by current column; replace any existing sort criteria", "replayable": true} | ||
{"sheet": "emp", "col": "job", "row": "", "longname": "sort-asc-add", "input": "", "keystrokes": "z[", "comment": "sort ascending by current column; add to existing sort criteria", "replayable": true} | ||
{"sheet": "emp", "col": "mgr", "row": "", "longname": "sort-desc-add", "input": "", "keystrokes": "z]", "comment": "sort descending by current column; add to existing sort criteria", "replayable": true} | ||
{"sheet": "emp", "col": "", "row": "", "longname": "addcol-rank-sheet", "input": "", "comment": "add column with the rank of each row based on its key columns", "replayable": true} | ||
{"sheet": "emp", "col": "emp_sheetrank", "row": "", "longname": "rename-col", "input": "sheetrank_1asc2asc3desc", "keystrokes": "^", "comment": "rename current column", "replayable": true} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we need a separate
listtype
? Seems like we could just use the sameaggr.type
in both cases, and remove thisisinstance
(which is usually a code smell for me).Uh oh!
There was an error while loading. Please reload this page.
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.
The way list aggregators work now, there is a need for two distinct types,
type
andlisttype
.type
is for the result of the aggregator. For example, this is used bymemo-aggregate
. That's whytype
isanytype
forListAggregators
. This type would be used whenever we want to hold the entire result (a list) in a cell.But we also need a separate type for the elements of the list. This is for when the aggregator result goes in a column, like for
addcol-aggregate
, where each cell holds not the result itself, but an element of the list result.If I try to get rid of one or the other types, I run into problems. For
RankAggregator
, if I get rid of thelisttype=int
switch totype=int
, I get an error in the statusbar forz+
rank
:'''
text_rank=int() argument must be a string, a bytes-like object or a real number, not 'list'
'''
But if instead I make
RankAggregator
usetype=anytype
, the column added byaddcol-aggregate
rank
does not get the typeint
.The need for two types is awkward. And I see your point about
isinstance
being a code smell. (That is a helpful heuristic, and I'll use it in the future.) It's accurately pointing out strain in the design: most aggregators produce a single value, list aggregators produce a list.Maybe
rank
should not be an aggregator. It's unlikely people want a list object holding the ranks. Most people want a column holding the ranks. What if we replaceaddcol-aggregate
+rank
with an equivalent commandaddcol-grouprank
(in addition to the existingaddcol-sheetrank
)? And we would reserveaddcol-aggregate
for finding group values likesum
,mean
,median
, as you suggested earlier. What do you think?(I would also consider changing the name
addcol-aggregate
. Maybe toaddcol-group-aggregate
.)