Skip to content
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

feat: Partitioned Table UI Enhancements #2110

Merged
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
4caeb92
feat: Partitioned Table UI Enhancements
AkshatJawne Jun 26, 2024
a2f8b9b
modify data extraction and test case
AkshatJawne Jun 26, 2024
831bae4
change name to baseTable and remove unnecessary border
AkshatJawne Jun 26, 2024
45bc6d8
make changes according to review
AkshatJawne Jun 27, 2024
81bdecc
fix formatting issues
AkshatJawne Jun 27, 2024
42dc49d
fix more formatting issues
AkshatJawne Jun 27, 2024
8cff366
small visual changes
AkshatJawne Jun 28, 2024
8ed8875
resolve merge conflicts
AkshatJawne Jul 2, 2024
a97cf27
fix formatting issues
AkshatJawne Jul 2, 2024
01a3225
make changes based on review
AkshatJawne Jul 4, 2024
16db737
temp workaround
AkshatJawne Jul 4, 2024
bc17e40
refactor logic to update partition options
AkshatJawne Jul 4, 2024
9bf8999
WIP fixing rendering issues
AkshatJawne Jul 5, 2024
99096c2
WIP state not working as intended
AkshatJawne Jul 5, 2024
804592b
fix empty table bug
AkshatJawne Jul 8, 2024
292e1ad
WIP still investigating cause of chromium failures
AkshatJawne Jul 9, 2024
dbf69a2
WIP fix formatting issue
AkshatJawne Jul 9, 2024
420bf9e
WIP small changes
AkshatJawne Jul 12, 2024
0762fbb
WIP fix formatter file not getting pushed
AkshatJawne Jul 12, 2024
82f72cb
WIP wanting to test change
AkshatJawne Jul 12, 2024
41bc31a
WIP test context menu change
AkshatJawne Jul 12, 2024
30226d6
WIP test chamhe
AkshatJawne Jul 12, 2024
1601d84
WIP revert old changes
AkshatJawne Jul 12, 2024
a092033
WIP Bender solution
AkshatJawne Jul 16, 2024
7c82824
fix issues with empty table
AkshatJawne Jul 17, 2024
d9fc4ca
remove null check
AkshatJawne Jul 17, 2024
e588409
remove early return
AkshatJawne Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 87 additions & 57 deletions packages/iris-grid/src/IrisGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
IrisGridContextMenuHandler,
IrisGridCopyCellMouseHandler,
IrisGridDataSelectMouseHandler,
IrisGridPartitionedTableMouseHandler,
IrisGridFilterMouseHandler,
IrisGridRowTreeMouseHandler,
IrisGridSortMouseHandler,
Expand Down Expand Up @@ -734,6 +735,7 @@
new IrisGridContextMenuHandler(this, dh),
new IrisGridDataSelectMouseHandler(this),
new PendingMouseHandler(this),
new IrisGridPartitionedTableMouseHandler(this),
];
if (canCopy) {
keyHandlers.push(new CopyKeyHandler(this));
Expand Down Expand Up @@ -895,8 +897,8 @@
const changedInputFilters =
inputFilters !== prevProps.inputFilters
? inputFilters.filter(
inputFilter => !prevProps.inputFilters.includes(inputFilter)
)
inputFilter => !prevProps.inputFilters.includes(inputFilter)

Check failure on line 900 in packages/iris-grid/src/IrisGrid.tsx

View workflow job for this annotation

GitHub Actions / unit

Insert `··`
)

Check failure on line 901 in packages/iris-grid/src/IrisGrid.tsx

View workflow job for this annotation

GitHub Actions / unit

Insert `··`
: [];
if (changedInputFilters.length > 0) {
const { advancedSettings } = this.props;
Expand Down Expand Up @@ -1380,11 +1382,11 @@
advancedFilters: ReadonlyAdvancedFilterMap,
searchFilter: DhType.FilterCondition | undefined
) => [
...(customFilters ?? []),
...IrisGridUtils.getFiltersFromFilterMap(quickFilters),
...IrisGridUtils.getFiltersFromFilterMap(advancedFilters),
...(searchFilter !== undefined ? [searchFilter] : []),
],
...(customFilters ?? []),

Check failure on line 1385 in packages/iris-grid/src/IrisGrid.tsx

View workflow job for this annotation

GitHub Actions / unit

Delete `··`
...IrisGridUtils.getFiltersFromFilterMap(quickFilters),

Check failure on line 1386 in packages/iris-grid/src/IrisGrid.tsx

View workflow job for this annotation

GitHub Actions / unit

Delete `··`
...IrisGridUtils.getFiltersFromFilterMap(advancedFilters),

Check failure on line 1387 in packages/iris-grid/src/IrisGrid.tsx

View workflow job for this annotation

GitHub Actions / unit

Replace `········` with `······`
...(searchFilter !== undefined ? [searchFilter] : []),

Check failure on line 1388 in packages/iris-grid/src/IrisGrid.tsx

View workflow job for this annotation

GitHub Actions / unit

Delete `··`
],

Check failure on line 1389 in packages/iris-grid/src/IrisGrid.tsx

View workflow job for this annotation

GitHub Actions / unit

Delete `··`
{ max: 1 }
);

Expand Down Expand Up @@ -2060,37 +2062,62 @@
keyTable.applySort(sorts);
keyTable.setViewport(0, 0);

return new Promise((resolve, reject) => {
// We want to wait for the first UPDATED event instead of just getting viewport data here
// It's possible that the key table does not have any rows of data yet, so just wait until it does have one
keyTable.addEventListener(
dh.Table.EVENT_UPDATED,
(event: CustomEvent<DhType.ViewportData>) => {
try {
const { detail: data } = event;
if (data.rows.length === 0) {
// Table is empty, wait for the next updated event
return;
}
const row = data.rows[0];
// Core JSAPI returns undefined for null table values, IrisGridPartitionSelector expects null
// https://github.com/deephaven/deephaven-core/issues/5400
const values = keyTable.columns.map(
column => row.get(column) ?? null
);
const newPartition: PartitionConfig = {
partitions: values,
mode: 'partition',
};
keyTable.close();
resolve(newPartition);
} catch (e) {
keyTable.close();
reject(e);
// We want to wait for the first UPDATED event instead of just getting viewport data here
// It's possible that the key table does not have any rows of data yet, so just wait until it does have one
keyTable.addEventListener(
dh.Table.EVENT_UPDATED,
(event: CustomEvent<DhType.ViewportData>) => {
try {
const { detail: data } = event;
if (data.rows.length === 0) {
this.setState({
partitionConfig: { partitions: [], mode: 'empty' },
});
return partitionConfig;
}
const row = data.rows[0];
const values = keyTable.columns.map(column => row.get(column));
const newPartition: PartitionConfig = {
partitions: values,
mode: model.isPartitionAwareSourceTable ? 'partition' : 'keys',
};
keyTable.close();
return newPartition;
AkshatJawne marked this conversation as resolved.
Show resolved Hide resolved
} catch (e) {
keyTable.close();
log.error('Error getting initial partition config', e);
}
}
);
return { partitions: [], mode: 'loading' };
}

/**
* Selects a partition key from the table based on the provided row index.
*
* @param rowIndex The index of the row from which the partition will be selected.
* @returns A promise that resolves when the partition key has been successfully selected.
*/
selectPartitionKeyFromTable(rowIndex: GridRangeIndex): void {
const { model } = this.props;
assertNotNull(rowIndex);
if (isPartitionedGridModel(model)) {
const data = this.getRowDataMap(rowIndex);
const partitionColumnSet = new Set(
model.partitionColumns.map(column => column.name)
);
});
const values = Object.entries(data)
.filter(([key, _]) => partitionColumnSet.has(key))
.map(([key, columnData]) => columnData.value);
const newPartition: PartitionConfig = {
partitions: values,
mode: 'partition',
};
this.setState({
isSelectingPartition: true,
partitionConfig: newPartition,
});
}
}

copyCell(
Expand Down Expand Up @@ -2532,7 +2559,11 @@

handlePartitionChange(partitionConfig: PartitionConfig): void {
this.startLoading('Partitioning...');
this.setState({ partitionConfig });
const { partitionConfig: prevConfig } = this.state;
if (prevConfig !== partitionConfig) {
this.setState({ partitionConfig });
}
// this.setState({ partitionConfig });
}

handleTableLoadError(error: unknown): void {
Expand Down Expand Up @@ -3125,10 +3156,10 @@
pendingRowCount = Math.max(
0,
bottomViewport -
(model.rowCount - model.pendingRowCount) -
model.floatingTopRowCount -
model.floatingBottomRowCount -
1
(model.rowCount - model.pendingRowCount) -

Check failure on line 3159 in packages/iris-grid/src/IrisGrid.tsx

View workflow job for this annotation

GitHub Actions / unit

Insert `··`
model.floatingTopRowCount -

Check failure on line 3160 in packages/iris-grid/src/IrisGrid.tsx

View workflow job for this annotation

GitHub Actions / unit

Insert `··`
model.floatingBottomRowCount -

Check failure on line 3161 in packages/iris-grid/src/IrisGrid.tsx

View workflow job for this annotation

GitHub Actions / unit

Insert `··`
1
);
}
}
Expand Down Expand Up @@ -3459,8 +3490,7 @@
this.clearAllFilters();

this.startLoading(
`Selecting distinct values in ${
columnNames.length > 0 ? columnNames.join(', ') : ''
`Selecting distinct values in ${columnNames.length > 0 ? columnNames.join(', ') : ''
}...`
);

Expand Down Expand Up @@ -4268,9 +4298,9 @@

const debounceMs = metrics
? Math.min(
Math.max(IrisGrid.minDebounce, Math.round(metrics.rowCount / 200)),
IrisGrid.maxDebounce
)
Math.max(IrisGrid.minDebounce, Math.round(metrics.rowCount / 200)),
IrisGrid.maxDebounce
)
: IrisGrid.maxDebounce;

if (isFilterBarShown && focusedFilterBarColumn != null && metrics != null) {
Expand Down Expand Up @@ -4466,19 +4496,19 @@
const xFilterBar = gridX + columnX + columnWidth - 20;
const style: CSSProperties = isFilterBarShown
? {
position: 'absolute',
top: columnHeaderHeight,
left: xFilterBar,
width: 20,
height: theme.filterBarHeight,
}
position: 'absolute',
top: columnHeaderHeight,
left: xFilterBar,
width: 20,
height: theme.filterBarHeight,
}
: {
position: 'absolute',
top: 0,
left: xColumnHeader,
width: columnWidth,
height: columnHeaderHeight,
};
position: 'absolute',
top: 0,
left: xColumnHeader,
width: columnWidth,
height: columnHeaderHeight,
};
const modelColumn = this.getModelColumn(columnIndex);
if (modelColumn != null) {
const column = model.columns[modelColumn];
Expand Down
3 changes: 1 addition & 2 deletions packages/iris-grid/src/IrisGridPartitionSelector.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
}
.partition-button-group {
display: flex;
border: 1px var(--dh-color-hr);
border-style: none solid;
border-right: 1px solid var(--dh-color-hr);
padding: 0 $spacer-2;
gap: $spacer-2;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/iris-grid/src/IrisGridPartitionSelector.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ function makeModel(
Promise.resolve(irisGridTestUtils.makeTable())
),
partitionColumns: columns,
partitionBaseTable: jest.fn(() =>
Promise.resolve(irisGridTestUtils.makeTable())
),
} as unknown as PartitionedGridModel;
return model;
}
Expand Down
Loading
Loading