forked from deephaven/web-client-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Do not show Group column for tree-tables
- If a table has no grouped columns or only one grouped column, no point in adding an extra Group column for that situation as it is just duplicate information - Fixes deephaven#1831 - Added unit tests, and tested with the following snippet: ```python from deephaven import read_csv, agg from deephaven.constants import NULL_INT from deephaven import empty_table _source = empty_table(100).update_view(["ID = i", "Parent = i == 0 ? NULL_INT : (int)(i / 4)"]) _insurance = read_csv("https://media.githubusercontent.com/media/deephaven/examples/main/Insurance/csv/insurance.csv") agg_list = [agg.avg(cols=["bmi", "expenses"])] small_by_list = ["region"] by_list = ["region", "age"] no_group_tree = _source.tree(id_col="ID", parent_col="Parent") no_group_agg = insurance.rollup(aggs=agg_list, by=small_by_list, include_constituents=True) group_rollup_no_agg = insurance.rollup(aggs=[], by=by_list, include_constituents=True) group_rollup_agg = insurance.rollup(aggs=agg_list, by=by_list, include_constituents=True) ```
- Loading branch information
Showing
4 changed files
with
74 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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,29 @@ | ||
import dh from '@deephaven/jsapi-shim'; | ||
import IrisGridTestUtils from './IrisGridTestUtils'; | ||
import IrisGridTreeTableModel from './IrisGridTreeTableModel'; | ||
|
||
const irisGridTestUtils = new IrisGridTestUtils(dh); | ||
|
||
describe('IrisGridTreeTableModel', () => { | ||
const expectedVirtualColumn = expect.objectContaining({ | ||
name: '__DH_UI_GROUP__', | ||
displayName: 'Group', | ||
isProxy: true, | ||
}); | ||
const columns = irisGridTestUtils.makeColumns(); | ||
|
||
test.each([ | ||
[0, columns, columns], | ||
[1, columns, columns], | ||
[2, columns, [expectedVirtualColumn, ...columns]], | ||
[columns.length, columns, [expectedVirtualColumn, ...columns]], | ||
])( | ||
`create virtual columns with group length %`, | ||
(groupedLength, allColumns, expected) => { | ||
const groupedColumns = allColumns.slice(0, groupedLength); | ||
const table = irisGridTestUtils.makeTreeTable(allColumns, groupedColumns); | ||
const model = new IrisGridTreeTableModel(dh, table); | ||
expect(model.columns).toEqual(expected); | ||
} | ||
); | ||
}); |
This file contains 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